首页 > 学院 > 开发设计 > 正文

c# 读取远程主机性能计数器

2019-11-17 02:34:22
字体:
来源:转载
供稿:网友

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性能计数器及其关联的类别所在的计算机。


上一篇:md5加密

下一篇:5、继承和多态

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表