Examples
banshee/examples-collection/examples/watches/
state
Example: the watch state, raised by a value in a list; a systemd service by SSH.
par banshee1 installation1 version
Publiée le 27 octobre 2026. First version in this collection.
// The watch "state": it raises when a value takes one of the states of a list.
// The collector reads whether a systemd service is running, by SSH.
need('protocol:ssh');
output('state', 'text', array('label' => 'State of the service'));
// failed raises critical, inactive a warning; any other state (active, activating...) raises nothing.
watch.state('down', 'Service down', 'state', array('warning' => array('inactive'), 'critical' => array('failed')));
// systemctl is-active prints one word, and exits non-zero when the service is not active: that is an
// answer, read in output, not a failure.
$answer = ssh.run('systemctl is-active sshd');
value('state', text.trim($answer['output']));