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.

Linux

banshee/linux-collection/linux/ssh/

uptime

Time since boot of a Linux by SSH, and a recent reboot.

  • linux
  • ssh
  • uptime
  • reboot
  • alpine
  • debian
  • fedora

by banshee1 installation2 versions

Keen 1.0.0 · 16 lines
// The time since boot of a Linux, by SSH. A reboot shows as a time since boot shorter than the threshold
// of "Recent reboot".
// Reads /proc/uptime with cat: the kernel writes it the same way on Alpine, Debian and Fedora,
// "350735.47 1374566.28", the seconds since boot then the idle time of all cores.
need('protocol:ssh');

output('uptime', 'number', array('label' => 'Time since boot', 'unit' => 'h'));

watch.below('rebooted', 'Recent reboot', 'uptime', array('warning' => 0.5));

$read = ssh.run('cat /proc/uptime');
$words = text.words($read['output']);
if (list.count($words) < 1 || !text.is_number($words[0])) {
    fail('misconfigured', 'No time since boot found in /proc/uptime', $read['output'] . $read['errors']);
}
value('uptime', number.round($words[0] / 3600, 2));