banshee is under active development: collectors will keep changing, and a version you publish will likely need adjustments. For stable use, wait for version 1.0.0.

Windows

banshee/windows-collection/windows/snmp/

swap

The virtual memory of a Windows, committed and free against its commit limit, by SNMP

  • windows
  • snmp
  • swap
  • virtual memory

by banshee1 installation2 versions

Keen 1.0.0 · 50 lines
// The virtual memory of a Windows, by SNMP, from the "Virtual Memory" row of hrStorageTable
// (HOST-RESOURCES-MIB). Windows counts physical memory and the paging file together there: it is
// the commit limit of the system, and what is committed; the agent does not serve the paging file alone.
need('protocol:snmp');

output('total', 'number', array('label' => 'Virtual memory', 'unit' => 'MiB'));
output('used', 'number', array('label' => 'Virtual memory committed', 'unit' => 'MiB'));
output('free', 'number', array('label' => 'Free virtual memory', 'unit' => 'MiB'));
output('used-percent', 'number', array('label' => 'Virtual memory committed', 'unit' => '%'));

watch.above('used-percent', 'Virtual memory saturated', 'used-percent', array('warning' => 85, 'critical' => 95, 'for' => '3 runs'));
watch.below('free', 'Little free virtual memory', 'free', array('critical' => 1024, 'enabled' => false));

// hrStorageTable, indexed by hrStorageIndex: hrStorageType (an OID), hrStorageAllocationUnits (in bytes),
// hrStorageSize and hrStorageUsed (in allocation units).
$storage = snmp.table(array(
    'type'  => '1.3.6.1.2.1.25.2.3.1.2',
    'unit'  => '1.3.6.1.2.1.25.2.3.1.4',
    'size'  => '1.3.6.1.2.1.25.2.3.1.5',
    'used'  => '1.3.6.1.2.1.25.2.3.1.6',
));

// Virtual memory is of the type hrStorageVirtualMemory (1.3.6.1.2.1.25.2.1.3); the pattern accepts the OID
// written with or without a leading dot.
// An empty table, a type in a form the pattern does not recognise, or a zero size stop the
// collector, saying which types were read: never a green light without a measure.
$found = false;
$types = array();
foreach ($storage as $row) {
    $types = list.add($types, list.get($row, 'type', ''));
    if (text.like(list.get($row, 'type', ''), '*1.3.6.1.2.1.25.2.1.3')) {
        $found = true;
        $virtual = $row;
        break;
    }
}
if (!$found) {
    fail('misconfigured', 'Virtual memory (hrStorageVirtualMemory) missing from hrStorageTable',
        list.count($types) . ' row(s) read; types: ' . text.join($types, ', '));
}
if (list.get($virtual, 'size', 0) <= 0) {
    fail('misconfigured', 'Virtual memory of zero size in hrStorageTable');
}

$total = $virtual['size'] * $virtual['unit'] / 1048576;
$used = $virtual['used'] * $virtual['unit'] / 1048576;
value('total', number.round($total));
value('used', number.round($used));
value('free', number.round($total - $used));
value('used-percent', number.round(100 * $used / $total, 1));