Monitor cpu performance of a process Filed Under: Perl
Hello,
Another Perl script for Cacti. This script came about as I wanted to monitor a specific process in a server rather than the general CPU usage.
While looking at the available data returned from SNMP I found the following objects that were exactly what I needed:
hrSWRunName:A textual description of this running piece of software, including the manufacturer, revision, and the name by which it is commonly known. If this software was installed locally, this should be the same string as used in the corresponding hrSWInstalledName.
hrSWRunPerfCPU: The number of centi-seconds of the total system’s CPU resources consumed by this process. Note that on a multi-processor system, this value may increment by more than one centi-second in one centi-second of real (wall clock) time.
From there I managed to create a very basic Perl script that will return the value of the hrSWRunPerfCPU by giving the process name that we want to monitor. I found this quite useful as the lookup is using the PID of the actual application so in the case that the application is restarted the PID will change and therefore the output will change (not good if you are trying to graph something).
You can get the script from here.
Parameters
This are the parameters taken by the application:
-h "hostname"
-c "SNMP community"
-p "process name"
For example:
cpu-perf.pl -h 10.1.1.1 -c testSNMP -p firefox.exe
Tags: cpu performance, Perl, process, snmp
- Permalink
- Alberto Diaz
- 8 Dec 2008 8:48 PM
- Comments (0)