Linux
banshee/linux-collection/linux/snmp/
filesystems
Space of each mounted filesystem of a Linux host by SNMP, with the trend that says it will be full.
par banshee1 installation2 versions
v2Dernière
Publiée le 28 octobre 2026. One naming convention across collections; documentation completed.
// The space of each mounted filesystem of a Linux host, by SNMP, from hrStorageTable (HOST-RESOURCES-MIB):
// rows of type hrStorageFixedDisk only, so network mounts (hrStorageNetworkDisk) and the memory rows are
// left out. A filesystem is named by its mount point. An expected filesystem that disappears shows through
// the "Filesystem missing" watch.
// net-snmp does not tell a filesystem's type: it files tmpfs and overlay with the disks, and itself hides
// devtmpfs, proc, sysfs and squashfs. In-memory and container mounts are therefore left out by their mount
// point, in the default selection, which the probe can change.
need('protocol:snmp');
per('filesystem', 'Filesystems', array('ignore' => array(
'/dev', '/dev/*', '/run', '/run/*', '/sys/*',
'/var/lib/docker/*', '/var/lib/containers/*', '/var/lib/kubelet/*',
)));
output('used-percent', 'number', array('label' => 'Used space', 'unit' => '%', 'per' => 'filesystem'));
output('used', 'number', array('label' => 'Used space', 'unit' => 'GiB', 'per' => 'filesystem'));
output('free', 'number', array('label' => 'Free space', 'unit' => 'GiB', 'per' => 'filesystem'));
output('size', 'number', array('label' => 'Size', 'unit' => 'GiB', 'per' => 'filesystem'));
watch.above('used', 'Used space', 'used-percent', array('warning' => 80, 'critical' => 90));
watch.above('full-soon', 'Full within a week', 'used-percent', array('warning' => 99, 'ahead' => '7 d'));
watch.below('free', 'Little free space', 'free', array('critical' => 5, 'enabled' => false));
watch.missing('missing', 'Filesystem missing', 'used-percent', array('enabled' => false));
// hrStorageTable, by hrStorageIndex: hrStorageType (an OID), hrStorageDescr (the mount point),
// 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',
'descr' => '1.3.6.1.2.1.25.2.3.1.3',
'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',
));
// The types read, each once, to say what the agent served when no filesystem is returned.
$rows = 0;
$seen_types = array();
$types = array();
$filesystems = 0;
foreach ($storage as $row) {
$rows = $rows + 1;
$type = list.get($row, 'type', '');
if (!list.has($seen_types, $type)) {
$seen_types[$type] = true;
$types = list.add($types, $type);
}
// hrStorageFixedDisk is 1.3.6.1.2.1.25.2.1.4; the pattern accepts the OID with or without a leading dot.
// A filesystem of size zero has no space to judge.
if (!text.like($type, '*1.3.6.1.2.1.25.2.1.4') || list.get($row, 'size', 0) <= 0) {
continue;
}
$filesystems = $filesystems + 1;
$name = $row['descr'];
$total = $row['size'] * $row['unit'] / 1073741824;
$used = $row['used'] * $row['unit'] / 1073741824;
value('size', number.round($total, 1), $name);
value('used', number.round($used, 1), $name);
value('free', number.round($total - $used, 1), $name);
value('used-percent', number.round(100 * $used / $total, 1), $name);
}
// A Linux host always has its root: returning none would be a green light on nothing. An empty table, a
// type written in a form the pattern does not recognise, or no fixed disk of non-zero size therefore stop
// the collector, saying what it read.
if ($filesystems == 0) {
fail('misconfigured', 'No fixed disk read in hrStorageTable',
$rows . ' row(s) read; types: ' . text.join($types, ', '));
}