Linux
banshee/linux-collection/linux/snmp/
swap
Swap of a Linux host by SNMP: size, used and free.
par banshee1 installation2 versions
v2Dernière
Publiée le 28 octobre 2026. One naming convention across collections; documentation completed.
// 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));