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 )