Win32::PerfMon is unable to enum objects with multiple instances

I’ve been looking for some easy ways to enumerate all of the available performance counters on a Win32 platform programatically.

Rather than trawl through the PerfMon counter GUI, or regress back into the millions of raw counters available via WMI, I was looking for a solution somewhere in between.

The ActiveState version of Perl has a Win32::PerfMon module which lets you enumerate cooked performance counter metrics on a Win32 platform. So I started to write a simple script that would list all Objects->Instances->Counters recursively. Sounds simple right?

Unfortunately I found that the module appears faulty when trying to enum Objects that have multiple instances, such as PhysicalDisk and LogicalDisk. Naturally, these are the counters I’m most interested in! After googling to the end of the known universe, I couldn’t find a solution to this problem.

Windows comes with a command line utility called Typeperf which is great for what I ultimately need to script (an unattended batch job that collects performance metrics).

But in order to develop a list of ALL available counters I wrote a mashup in Perl using the Win32::Perfmon module and calls to Typeperf to discover performance counters related to any particular object. That way, I can top and tail the output to my chosen performance counters and not have to worry about the exact typing of these finicky little buggers.

Read More

Chasing symptoms, not cause

Any job in which you need to ‘fix’ something requires you to correctly analyze the root cause. Treat just the symptoms and you’ll find yourself on the never-get-fixed roundabout …

Performance tuning fits this profile neatly. In an array of available metrics, how do you avoid chasing the symptoms and never identifying root cause?

Read More