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.

Linux

banshee/linux-collection/linux/snmp/

swap

Swap of a Linux host by SNMP: size, used and free.

  • linux
  • snmp
  • swap
  • memory
  • net-snmp

by banshee1 installation2 versions

v2Latest

Published on October 28, 2026. One naming convention across collections; documentation completed.

Keen 1.0.0 · 25 lines
// The swap of a Linux host, by SNMP, from the memory group of UCD-SNMP-MIB (net-snmp). A machine without
// swap says so by a size of zero, and returns zero everywhere: that is a measurement, not a failure.
// These values are 31 bits wide, in KiB: beyond 2 TiB, the agent itself miscounts them.
need('protocol:snmp');

output('total', 'number', array('label' => 'Swap size', 'unit' => 'MiB'));
output('used', 'number', array('label' => 'Used swap', 'unit' => 'MiB'));
output('free', 'number', array('label' => 'Free swap', 'unit' => 'MiB'));
output('used-percent', 'number', array('label' => 'Used swap', 'unit' => '%'));

watch.above('swap-high', 'Swap saturated', 'used-percent', array('warning' => 80, 'critical' => 95, 'for' => '3 runs'));
watch.below('free', 'Little free swap', 'free', array('critical' => 512, 'enabled' => false));

// memTotalSwap and memAvailSwap (the free swap), in KiB.
$total = snmp.get('1.3.6.1.4.1.2021.4.3.0') / 1024;
$free = snmp.get('1.3.6.1.4.1.2021.4.4.0') / 1024;

$percent = 0;
if ($total > 0) {
    $percent = 100 * ($total - $free) / $total;
}
value('total', number.round($total));
value('used', number.round($total - $free));
value('free', number.round($free));
value('used-percent', number.round($percent, 1));