Storage
banshee/storage-collection/storage/truenas/snmp/core/
datasets
The space of each ZFS dataset of a TrueNAS CORE by SNMP (FREENAS-MIB).
par banshee1 installation2 versions
v2Dernière
Publiée le 28 octobre 2026. One naming convention across collections; documentation completed.
// The space of each ZFS dataset of a TrueNAS CORE, by SNMP (FREENAS-MIB, revision 2020-05-28): the layout of
// TrueNAS CORE 12 and 13 and of TrueNAS SCALE up to 22.12; TRUENAS-MIB, served by TrueNAS SCALE 23.10 to
// 25.10, has no dataset table.
// The sizes are counted in allocation units, which the agent chooses so that they fit in 32 bits: a size
// in bytes is the count times datasetAllocationUnits.
need('protocol:snmp');
per('dataset', 'Datasets');
output('used-percent', 'number', array('label' => 'Used space', 'unit' => '%', 'per' => 'dataset'));
output('free', 'number', array('label' => 'Free space', 'unit' => 'GiB', 'per' => 'dataset'));
output('size', 'number', array('label' => 'Size', 'unit' => 'GiB', 'per' => 'dataset'));
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' => 10, 'enabled' => false));
watch.missing('missing', 'Dataset missing', 'used-percent', array('enabled' => false));
// FREENAS-MIB, datasetTable (1.3.6.1.4.1.50536.1.2.1), by datasetIndex: datasetDescr ("tank/home"),
// datasetAllocationUnits, datasetUsed and datasetAvailable.
$datasets = snmp.table(array(
'name' => '1.3.6.1.4.1.50536.1.2.1.1.2',
'units' => '1.3.6.1.4.1.50536.1.2.1.1.3',
'used' => '1.3.6.1.4.1.50536.1.2.1.1.5',
'available' => '1.3.6.1.4.1.50536.1.2.1.1.6',
));
$read = 0;
foreach ($datasets as $row) {
if (!list.has($row, 'name') || !list.has($row, 'units') || !list.has($row, 'used') || !list.has($row, 'available')) {
continue;
}
$read = $read + 1;
$name = $row['name'];
// A dataset's size is its used space plus what it can still take: its quota, or what the pool has left.
$used = $row['used'] * $row['units'];
$available = $row['available'] * $row['units'];
if ($used + $available > 0) {
value('used-percent', number.round(100 * $used / ($used + $available), 1), $name);
}
value('free', number.round($available / 1073741824, 1), $name);
value('size', number.round(($used + $available) / 1073741824, 1), $name);
}
if ($read == 0) {
fail('misconfigured', 'The agent serves no dataset (datasetTable, FREENAS-MIB)',
'A TrueNAS SCALE 23.10 or later serves TRUENAS-MIB, which has no dataset table.');
}