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.

Examples

banshee/examples-collection/examples/mechanics/

selection

Example: per and its default selection, all but ignore; the space used per file system.

  • example
  • per
  • selection
  • ignore
  • disk
  • ssh

by banshee1 installation2 versions

Keen 1.0.0 · 22 lines
// per: the collector returns one value per element, here per file system, and declares the default
// selection: all of them except those that match a pattern of ignore. The administrator changes the
// selection on the probe. The code never filters: it returns everything, and the poller sets aside what
// the selection leaves out.
need('protocol:ssh');

per('filesystem', 'File systems', array('ignore' => array('/boot*', '/snap/*')));
output('used', 'number', array('label' => 'Space used', 'unit' => '%', 'per' => 'filesystem'));

watch.above('full', 'File system almost full', 'used', array('warning' => 85, 'critical' => 95));

// A header line, then one line per file system: "/dev/sda1 30832548 12056700 17186124 42% /".
$df = ssh.run('df -P -k');
$lines = text.lines($df['output']);
for ($i = 1; $i < list.count($lines); $i = $i + 1) {
    $f = text.words($lines[$i]);
    // File systems in memory, and pseudo ones of size zero, are not disks.
    if ($f[0] != 'tmpfs' && $f[0] != 'devtmpfs' && $f[1] > 0) {
        // The third argument of value names the element: here, the mount point.
        value('used', number.round(100 * $f[2] / $f[1], 1), $f[5]);
    }
}