2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Make the uptime_bsd plugin OpenBSD friendly.

This commit is contained in:
iangregory 2012-02-18 18:51:33 +00:00
parent 921de33575
commit 6272ca0c22

View File

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