Examples
banshee/examples-collection/examples/watches/
state
Example: the watch state, raised by a value in a list; a systemd service by SSH.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
Watch: state
watch.state raises when a value takes one of the states of a list: here, the state of a systemd service, failed critical, inactive a warning.
How to read it
watch.state('down', 'Service down', 'state', array('warning' => array(…), 'critical' => array(…))): an id, the title the administrator reads, the output it watches, and for each level the list of values that raise it. Any other value raises nothing.- The output can be a text or a number; a number in the list counts as its writing (
'2'and2are the same). systemctl is-activeexits non-zero for a service that is not active:ssh.runreturns that as an answer, and the collector reads the word printed.
To adapt it
- Change
sshdfor the service to watch, or return one state per service withper(seeexamples/mechanics/selection-only). - The opposite question, "anything but these values", is
watch.expect(seeexamples/watches/expect).