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-only

Example: per with only, a default selection of named elements; systemd services by SSH.

  • example
  • per
  • selection
  • only
  • systemd
  • ssh

by banshee1 installation2 versions

Keen 1.0.0 · 17 lines
// per with only: the default selection is "only these elements". Of all the systemd services of a Linux,
// sshd and cron are watched by default; the administrator adds others on the probe, by name or by pattern.
need('protocol:ssh');

per('service', 'Services', array('only' => array('sshd', 'cron')));
output('state', 'text', array('label' => 'State', 'per' => 'service'));

watch.expect('stopped', 'Service not running', 'state', array('critical' => array('active')));

// One line per service, "cron.service loaded active running Regular background program processing daemon".
$units = ssh.run('systemctl list-units --type=service --all --plain --no-legend');
foreach (text.lines($units['output']) as $line) {
    $m = text.match($line, '([^ ]+)\.service +[^ ]+ +([^ ]+)');
    if (list.count($m) > 0) {
        value('state', $m[2], $m[1]);
    }
}