Windows
banshee/windows-collection/windows/snmp/
processes
The processes of a Windows: their number, and the instances, memory and processor time of the ones followed, by SNMP
by banshee1 installation2 versions
// The processes of a Windows, by SNMP: their total number, and for each process name followed
// ("lsass.exe", "sqlservr.exe") the number of its instances, their memory and their processor time,
// from hrSWRunTable and hrSWRunPerfTable (HOST-RESOURCES-MIB).
need('protocol:snmp');
per('process', 'Processes', array('only' => array('lsass.exe', 'services.exe')));
output('processes', 'number', array('label' => 'Number of processes'));
output('instances', 'number', array('label' => 'Number of instances', 'per' => 'process'));
output('memory', 'number', array('label' => 'Memory', 'unit' => 'MiB', 'per' => 'process'));
output('cpu', 'number', array('label' => 'Processor time, as a share of one processor', 'unit' => '%', 'per' => 'process'));
watch.missing('missing', 'Process missing', 'instances', array('critical' => array('lsass.exe', 'services.exe')));
watch.above('too-many', 'Too many processes', 'processes', array('enabled' => false));
watch.above('memory-high', 'Memory of a process', 'memory', array('enabled' => false));
watch.above('cpu-high', 'Processor of a process', 'cpu', array('warning' => 90, 'for' => '3 runs', 'enabled' => false));
// hrSystemProcesses: the number of processes loaded or running.
value('processes', snmp.get('1.3.6.1.2.1.25.1.6.0'));
// Indexed by hrSWRunIndex: hrSWRunName ("svchost.exe"), hrSWRunPerfCPU (the processor time consumed
// since the start, in hundredths of a second) and hrSWRunPerfMem (the real memory, in KiB).
$run = snmp.table(array(
'name' => '1.3.6.1.2.1.25.4.2.1.2',
'cpu' => '1.3.6.1.2.1.25.5.1.1.1',
'memory' => '1.3.6.1.2.1.25.5.1.1.2',
));
// The instances of one name add up; a process that ended between two columns lacks some of
// its own, and counts for zero in what it lacks.
$count = array();
$memory = array();
$cpu = array();
foreach ($run as $row) {
if (!list.has($row, 'name')) {
continue;
}
$name = $row['name'];
$count[$name] = list.get($count, $name, 0) + 1;
$memory[$name] = list.get($memory, $name, 0) + list.get($row, 'memory', 0);
$cpu[$name] = list.get($cpu, $name, 0) + list.get($row, 'cpu', 0);
}
foreach ($count as $name => $instances) {
value('instances', $instances, $name);
value('memory', number.round($memory[$name] / 1024, 1), $name);
// Hundredths of a second consumed per second are percents of one processor. Nothing at the first
// run, nor when an instance has ended and the sum went back.
$rate = counter.rate('cpu', $cpu[$name], $name);
if ($rate != '') {
value('cpu', number.round($rate, 1), $name);
}
}