PerformanceCounter pc = new PerformanceCounter("Web Service", "Current Connections", "Default Web Site","10.1.254.103"); Response.WriteLine(pc.NextValue()); Thread.Sleep(1000); Response.WriteLine(pc.NextValue());
1.需要using System.Diagnostics;
2.在本地服务器建立一个与远程主机上一样的账号密码即可,远程主机的账号密码需要在Performance Monitor Users和Administrators组下;
(可能需要开启远程主机 Remote Registry 服务)
public PerformanceCounter( string categoryName, string counterName, string instanceName, string machineName )