I want to get the performance data like in the performance tab in the task manager window.
I got this code:
using (PerformanceCounter pCounter = new PerformanceCounter())
{
pCounter.CategoryName = "Processor"; //this get me the cpu usage
pCounter.CounterName = "% Processor Time";
pCounter.InstanceName = "_Total";
// will always start at 0
pCounter.NextValue();
System.Threading.Thread.Sleep(1000);
//now matches task manager reading
float cpuUsage = pCounter.NextValue();
pCounter.CategoryName = "Memory";
pCounter.CounterName = "Available MBytes"; //this gets me the available memory
pCounter.InstanceName = string.Empty;
}
I also need:
- The up time (time the server is active HH:mm:ss)
- Number of processes
- Number of threads
- Ethernet usage
I have no idea how to get this data...