Examples
banshee/examples-collection/examples/mechanics/
durations
Example: for, in passes and in time; the response time of a web page.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
// Durations in for: a watch raises only when its condition holds for a while, counted in passes
// ('3 runs') or in time ('10 min'). Without for, the default '1 run', it raises at once.
// The collector reads the response time of a web page.
need('protocol:http');
$url = variable('example:page:url', 'text', array(
'label' => 'Address of the page',
'help' => 'For example https://www.example/.',
));
output('response-time', 'number', array('label' => 'Response time', 'unit' => 'ms'));
// Slow for 3 passes in a row: a warning. One slow pass alone raises nothing.
watch.above('slow', 'Slow', 'response-time', array('warning' => 500, 'for' => '3 runs'));
// Very slow for 10 minutes: critical, whatever the interval of the probe.
watch.above('very-slow', 'Very slow', 'response-time', array('critical' => 2000, 'for' => '10 min'));
$answer = http.get($url);
value('response-time', $answer['time']);