diff --git a/plugins/system/uptime_bsd b/plugins/system/uptime_bsd index c0f8f20c..840d61bb 100755 --- a/plugins/system/uptime_bsd +++ b/plugins/system/uptime_bsd @@ -1,15 +1,18 @@ -#!/usr/local/bin/perl -w +#!/usr/bin/env perl # -*- perl -*- -# Plugin to monitor number of irqs +# Plugin to monitor the system uptime # #%# family=auto #%# capabilities=autoconf use strict; +use warnings; my %IN; my $sysctl = defined($ENV{sysctl}) ? $ENV{sysctl} : '/sbin/sysctl'; +my $ostype = `uname -s`; +chomp ($ostype); if (defined($ARGV[0]) and ($ARGV[0] eq 'autoconf')) { if ( -x $sysctl ) { @@ -26,12 +29,12 @@ graph_title Uptime graph_args --base 1000 -l 0 graph_vlabel days graph_category system -compile.label kernel age +compile.label Kernel age compile.type GAUGE compile.min 0 compile.max 1000 compile.draw AREA -uptime.label uptime +uptime.label Uptime uptime.type GAUGE uptime.min 0 uptime.max 1000 @@ -47,10 +50,12 @@ $kern=~ /:\s+(.*\S)\s+\w+\@/; print "Compile: $1\n"; $kern=str2time($1); -my $boot=`sysctl -n kern.boottime`; -$boot=~ / sec = (\d+)/; -print "Boot: $1\n"; -$boot=$1; +my $boot=`sysctl -n kern.boottime`; # OpenBSD will return seconds from the epoch +if ($ostype ne "OpenBSD") { + $boot=~ / sec = (\d+)/; + print "Boot: $1\n"; + $boot=$1; +} my $now=time;