views:

84

answers:

2

I would like to monitor the performance of the Memory (RAM) and Physical Disk, what are all the counters in Perfmon that I have to monitor?

+1  A: 

The performance information for a Windows machine is stored in a particular part of the registry. You use the registry API's to enumerate the counters and get their names and values.

Theres a tutorial here: http://www.tenouk.com/ModuleP1.html

John Knoeller
A: 

You didn't state whether you are using managed or unmanaged code. If the latter, you can use the PerformanceCounter object and initialise it like so.

Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
PerformanceCounter pc = new PerformanceCounter();
pc.CategoryName = "Process";
pc.CounterName = "Working Set - Private";
pc.InstanceName = currentProcess.ProcessName;
var myProcessMemoryUsage = (long)pc.NextValue();

As an example, the above code retrieves the private working set performance counter information for the the current process.

PerformanceCounter pcRam = new PerformanceCounter();
pcRam.CategoryName = "Memory";
pcRam.CounterName = "Available MBytes";
int mem = (int)pcRam.NextValue();

This counter will show you the amount of RAM available on the machine in megabytes.

You can have a look at all the performance counters in Performance Monitor itself. You should be able to see both the categories and the counter name.

Joshua Hayes