------------------------------------------------------
C# WMI开发,怎么取到
       每秒钟页读取数 (pages/s)
       Physical disk %disk time 磁盘时间,磁盘读写服务效率 ------------------------------------------------------用C#开发,取得CPU使用率,网络流量信息等等,很容易取到,但怎么取到“每秒钟页读取数”,“磁盘时间”,请高手指点?

解决方案 »

  1.   

    http://www.cnblogs.com/xh831213/archive/2008/06/12/1218234.html
    http://msdn.microsoft.com/zh-cn/library/system.diagnostics.performancecounter(v=vs.80).aspx
      

  2.   

    to caozhy,Performace Counters确实能取相关的一些信息。但是,WMI可以取到远程机器的这些信息。而PerformaceCoutners只是其本机。而本帖的需求,也是要通过WMI取到网内的机器的这些信息。 PerformaceCounters是做不到的。继续求解!
      

  3.   

    Performance Counter可以读远程机器的这些信息的
      

  4.   


    也可以远程访问,不过需要设置权限。http://haishibai.blogspot.com/2010/02/tiy-collect-remote-performance-counters.html
    (需要代理才能访问)
      

  5.   

    to caozhy,里面是什么好的sample啊? 找了一圈好的代理访问也没找到。能把Sample project或示例代码,发到 (@代替#)very appreciate
    ................................
      

  6.   

     通过,朋友找的见了。和全CSDN网民共享: TIY – Collect remote performance counters using C#The following code demonstrates how to impersonate another domain user (“DomainA\UserA”, with password “PasswordA”) and collect CPU utilization counters from a remote machine (“MachineA”). Try it youself!using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;
    using System.Security.Principal;
    using System.Runtime.InteropServices;namespace CPUCounterTest
    {
        class Program
        {
            public const int LOGON32_LOGON_INTERACTIVE = 2;
            public const int LOGON32_LOGON_SERVICE = 3;
            public const int LOGON32_PROVIDER_DEFAULT = 0;        [DllImport("advapi32.dll", CharSet=CharSet.Auto)]
            public static extern bool LogonUser(
                String lpszUserName,
                String lpszDomain,
                String lpszPassword,
                int dwLogonType,
                int dwLogonProvider,
                ref IntPtr phToken);        [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
            public extern static bool CloseHandle(IntPtr handle);        static void Main(string[] args)
            {
                IntPtr userHandle = new IntPtr(0);
                LogonUser("UserA", "DomainA", "PasswordA", LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref userHandle);
                WindowsIdentity identity = new WindowsIdentity(userHandle);
                WindowsImpersonationContext context = identity.Impersonate();
                PerformanceCounterCategory cat = new PerformanceCounterCategory("Processor","MachineA");
                List<PerformanceCounter> counters = new List<PerformanceCounter>();
                foreach (string instance in cat.GetInstanceNames())
                    counters.Add(new PerformanceCounter("Processor", "% Processor Time", instance,"MachineA"));
                for (int i = 0; i < 10000; i++)
                {
                    foreach (PerformanceCounter counter in counters)
                        Console.Write(counter.NextValue() + " ");
                }
                context.Undo();
            }
        }
    }
    这个那个网页上的信息