Examples
banshee/examples-collection/examples/mechanics/
selection
Example: per and its default selection, all but ignore; the space used per file system.
by banshee1 installation2 versions
v2Latest
Published on October 28, 2026. One naming convention across collections; documentation completed.
// 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 only leaves out what is not a disk; it never filters on the selection: it
// returns every disk, and the poller sets aside what the selection leaves out.
need('protocol:ssh');
per('filesystem', 'File systems', array('ignore' => array('/boot*', '/snap/*')));
output('used-percent', 'number', array('label' => 'Used space', 'unit' => '%', 'per' => 'filesystem'));
watch.above('used', 'Used space', 'used-percent', array('warning' => 80, 'critical' => 90));
// 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-percent', number.round(100 * $f[2] / $f[1], 1), $f[5]);
}
}