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/

raid

The status, space and hot spares of each storage pool and volume of a Synology NAS by SNMP.

  • storage
  • synology
  • dsm
  • nas
  • raid
  • pool
  • snmp

by banshee1 installation2 versions

Keen 1.0.0 · 55 lines
// The storage pools and volumes of a Synology NAS, by SNMP (SYNOLOGY-RAID-MIB): the status of each storage
// item Storage Manager lists, its used and free space, and, from DSM 7.0, its hot spare disks.
need('protocol:snmp');

per('storage', 'Storage items');
output('status', 'text', array('label' => 'Status', 'per' => 'storage'));
output('used', 'number', array('label' => 'Used space', 'unit' => '%', 'per' => 'storage'));
output('free', 'number', array('label' => 'Free space', 'unit' => 'GiB', 'per' => 'storage'));
output('hot-spares', 'number', array('label' => 'Hot spare disks', 'per' => 'storage'));

watch.state('degraded', 'Storage degraded', 'status', array('warning' => array('degraded', 'unknown'), 'critical' => array('crashed')));
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('no-spare', 'No hot spare left', 'hot-spares', array('warning' => 1, 'enabled' => false));
watch.missing('missing', 'Storage item missing', 'status', array('enabled' => false));

// SYNOLOGY-RAID-MIB, raidTable (1.3.6.1.4.1.6574.3.1), by raidIndex: raidName, raidStatus, raidFreeSize,
// raidTotalSize (Counter64, in bytes) and raidHotspareCnt.
$items = snmp.table(array(
    'name'   => '1.3.6.1.4.1.6574.3.1.1.2',
    'status' => '1.3.6.1.4.1.6574.3.1.1.3',
    'free'   => '1.3.6.1.4.1.6574.3.1.1.4',
    'total'  => '1.3.6.1.4.1.6574.3.1.1.5',
    'spares' => '1.3.6.1.4.1.6574.3.1.1.6',
));

// raidStatus in words: normal, a task in progress (repairing to the conversions of SHR), degraded,
// crashed (or read-only), and unknown.
$statuses = array(1 => 'normal', 2 => 'repairing', 3 => 'migrating', 4 => 'expanding', 5 => 'deleting',
    6 => 'creating', 7 => 'syncing', 8 => 'parity-checking', 9 => 'assembling', 10 => 'canceling',
    11 => 'degraded', 12 => 'crashed', 13 => 'scrubbing', 14 => 'deploying', 15 => 'undeploying',
    16 => 'mounting-cache', 17 => 'unmounting-cache', 18 => 'expanding-unfinished-shr',
    19 => 'converting-shr-to-pool', 20 => 'migrating-shr1-to-shr2', 21 => 'unknown');

$read = 0;
foreach ($items as $row) {
    if (!list.has($row, 'name') || !list.has($row, 'status')) {
        continue;
    }
    $read = $read + 1;
    $name = $row['name'];
    value('status', list.get($statuses, $row['status'], 'unknown'), $name);
    if (list.has($row, 'free') && list.has($row, 'total') && $row['total'] > 0) {
        value('used', number.round(100 * ($row['total'] - $row['free']) / $row['total'], 1), $name);
        value('free', number.round($row['free'] / 1073741824, 1), $name);
    }
    // A negative count says DSM could not count them.
    if (list.has($row, 'spares') && $row['spares'] >= 0) {
        value('hot-spares', $row['spares'], $name);
    }
}
if ($read == 0) {
    fail('misconfigured', 'The agent serves no storage item (raidTable, SYNOLOGY-RAID-MIB)',
        'Not a Synology, or a view that does not include 1.3.6.1.4.1.6574.');
}