Examples
banshee/examples-collection/examples/protocols/
ssh-run
Example: ssh.run, its output, errors and exit, and arguments=; the size of a file.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
// ssh.run: run a command on the host by SSH. It returns three things: output, errors and exit.
// A command that exits non-zero is an answer, not a failure: the collector reads exit and decides.
// The collector reads the size of one file of a Linux.
need('protocol:ssh');
$path = variable('example:file:path', 'text', array(
'label' => 'File',
'help' => 'The full path of the file to watch, for example /var/log/syslog.',
));
output('size', 'number', array('label' => 'Size of the file', 'unit' => 'MiB'));
watch.above('too-big', 'File too big', 'size', array('warning' => 1024));
// arguments= sends each argument apart and protected: a path with a blank or a ; in it stays one
// argument, never read as a command.
$answer = ssh.run('stat -c %s', arguments=array($path));
if ($answer['exit'] != 0) {
fail('critical', 'File missing: ' . $path, $answer['errors']);
}
value('size', number.round(text.trim($answer['output']) / 1048576, 1));