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/

errors

Example: errors= to decide what a failed call means; a site down said critical.

  • example
  • errors
  • failure
  • http

by banshee1 installation1 version

v1Latest

Published on October 27, 2026. First version in this collection.

Keen 1.0.0 · 25 lines
// errors=: decide yourself what a failed call means. Without it, a call that fails stops the collector.
// With it, the call returns '' and fills the variable it names with code, text and details; the collector
// goes on, and tests $err['code'] != ''.
// The collector says a site that does not answer is down, rather than unreachable.
need('protocol:http');

$url = variable('example:site:url', 'text', array(
    'label' => 'Address of the site',
    'help'  => 'For example https://www.example/.',
));

output('status', 'number', array('label' => 'Answer code'));

watch.expect('error', 'Site in error', 'status', array('critical' => array(200)));

$answer = http.get($url, errors=$err);
// Nobody listens, or nobody answers in time: the site is down.
if ($err['code'] == 'connection_refused' || $err['code'] == 'timeout') {
    fail('critical', 'Site down', $err['text']);
}
// Any other failure: unreachable, as without errors=.
if ($err['code'] != '') {
    fail('unreachable', 'Site unreachable', $err['text']);
}
value('status', $answer['status']);