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.

Storage

banshee/storage-collection/storage/synology/snmp/

volumes

The used and free space of each volume of a Synology NAS by SNMP (HOST-RESOURCES-MIB).

  • storage
  • synology
  • dsm
  • nas
  • volume
  • snmp
  • disk

by banshee1 installation2 versions

Keen 1.0.0 · 47 lines
// The space of each volume of a Synology NAS (/volume1, /volume2...), by SNMP: the mounts of
// HOST-RESOURCES-MIB, hrStorageTable, that Synology's MIB guide gives for the disk space of DSM. The other
// mounts of the table (memory, the system partition, USB disks) are left out.
// 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 hrStorageAllocationUnits.
need('protocol:snmp');

per('volume', 'Volumes');
output('used', 'number', array('label' => 'Used space', 'unit' => '%', 'per' => 'volume'));
output('free', 'number', array('label' => 'Free space', 'unit' => 'GiB', 'per' => 'volume'));
output('size', 'number', array('label' => 'Size', 'unit' => 'GiB', 'per' => 'volume'));

watch.above('used', 'Used space', 'used', array('warning' => 80, 'critical' => 90));
watch.above('full-soon', 'Full within a week', 'used', array('warning' => 99, 'ahead' => '7 d'));
watch.below('free', 'Little free space', 'free', array('critical' => 10, 'enabled' => false));
watch.missing('missing', 'Volume missing', 'used');

// HOST-RESOURCES-MIB, hrStorageTable, by hrStorageIndex: hrStorageDescr (the mount point),
// hrStorageAllocationUnits, hrStorageSize and hrStorageUsed.
$storages = snmp.table(array(
    'descr' => '1.3.6.1.2.1.25.2.3.1.3',
    'units' => '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',
));

$read = 0;
foreach ($storages as $row) {
    if (!list.has($row, 'descr') || !list.has($row, 'units') || !list.has($row, 'size') || !list.has($row, 'used')) {
        continue;
    }
    // A volume of DSM is mounted on /volume followed by its number.
    if (list.count(text.match($row['descr'], '^/volume[0-9]+$')) == 0 || $row['size'] <= 0) {
        continue;
    }
    $read = $read + 1;
    $name = $row['descr'];
    $size = $row['size'] * $row['units'];
    $used = $row['used'] * $row['units'];
    value('used', number.round(100 * $used / $size, 1), $name);
    value('free', number.round(($size - $used) / 1073741824, 1), $name);
    value('size', number.round($size / 1073741824, 1), $name);
}
if ($read == 0) {
    fail('misconfigured', 'No /volume mount in hrStorageTable (HOST-RESOURCES-MIB)',
        'A view that does not include 1.3.6.1.2.1.25.2, or a NAS without a volume.');
}