c# 读取远程主机性能计数器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)
categoryName类型:System.String此性能计数器关联的性能计数器类别(性能对象)的名称。counterName类型:System.String性能计数器的名称。instanceName类型:System.String性能计数器类别实例的名称,或者为空字符串 ("")(如果该类别包含单个实例)。machineName类型:System.String性能计数器及其关联的类别所在的计算机。