C # Reading remote host performance counters,
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 is required;
2. Create an account and password the same as that on the remote host on the local server. The account and password of the remote host must be in the Performance Monitor Users and Administrators groups;
(You may need to enable the Remote host Registry service)
public PerformanceCounter(string categoryName,string counterName,string instanceName,string machineName)
-
CategoryName
-
Type: System. String
Name of the performance counter category (performance object) associated with this performance counter.
-
CounterName
-
Type: System. String
The name of the performance counter.
-
InstanceName
-
Type: System. String
Name of the performance counter category instance, or an empty string ("") (if this category contains a single instance ).
-
MachineName
-
Type: System. String
The computer where the performance counter and its associated category are located.