Examples
banshee/examples-collection/examples/watches/
above
Example: the watch above, and its trend ahead; the space used on / by SSH.
by banshee1 installation2 versions
// The watch "above": it raises when a value is strictly above a threshold. With "ahead", it judges the
// value the trend will reach, and raises before the threshold is crossed.
// The collector reads the space used on the root file system of a Linux, by SSH.
need('protocol:ssh');
output('used', 'number', array('label' => 'Space used on /', 'unit' => '%'));
watch.above('full', 'Disk almost full', 'used', array('warning' => 80, 'critical' => 90));
// ahead: the value judged is the one the trend reaches in 7 days. It learns the trend first, and says so.
watch.above('full-soon', 'Full within a week', 'used', array('warning' => 99, 'ahead' => '7 d'));
// A header line, then "/dev/sda1 30832548 12056700 17186124 42% /", the sizes in KiB.
$df = ssh.run('df -P -k /');
$lines = text.lines($df['output']);
if (list.count($lines) < 2) {
fail('misconfigured', 'df gave no line for /', $df['errors']);
}
$f = text.words($lines[1]);
value('used', number.round(100 * $f[2] / $f[1], 1));