Révision 6272ca0c
Make the uptime_bsd plugin OpenBSD friendly.
| plugins/system/uptime_bsd | ||
|---|---|---|
| 1 |
#!/usr/local/bin/perl -w
|
|
| 1 |
#!/usr/bin/env perl
|
|
| 2 | 2 |
# -*- perl -*- |
| 3 |
# Plugin to monitor number of irqs
|
|
| 3 |
# Plugin to monitor the system uptime
|
|
| 4 | 4 |
# |
| 5 | 5 |
#%# family=auto |
| 6 | 6 |
#%# capabilities=autoconf |
| 7 | 7 |
|
| 8 | 8 |
use strict; |
| 9 |
use warnings; |
|
| 9 | 10 |
|
| 10 | 11 |
my %IN; |
| 11 | 12 |
|
| 12 | 13 |
my $sysctl = defined($ENV{sysctl}) ? $ENV{sysctl} : '/sbin/sysctl';
|
| 14 |
my $ostype = `uname -s`; |
|
| 15 |
chomp ($ostype); |
|
| 13 | 16 |
|
| 14 | 17 |
if (defined($ARGV[0]) and ($ARGV[0] eq 'autoconf')) {
|
| 15 | 18 |
if ( -x $sysctl ) {
|
| ... | ... | |
| 26 | 29 |
graph_args --base 1000 -l 0 |
| 27 | 30 |
graph_vlabel days |
| 28 | 31 |
graph_category system |
| 29 |
compile.label kernel age
|
|
| 32 |
compile.label Kernel age
|
|
| 30 | 33 |
compile.type GAUGE |
| 31 | 34 |
compile.min 0 |
| 32 | 35 |
compile.max 1000 |
| 33 | 36 |
compile.draw AREA |
| 34 |
uptime.label uptime
|
|
| 37 |
uptime.label Uptime
|
|
| 35 | 38 |
uptime.type GAUGE |
| 36 | 39 |
uptime.min 0 |
| 37 | 40 |
uptime.max 1000 |
| ... | ... | |
| 47 | 50 |
print "Compile: $1\n"; |
| 48 | 51 |
$kern=str2time($1); |
| 49 | 52 |
|
| 50 |
my $boot=`sysctl -n kern.boottime`; |
|
| 51 |
$boot=~ / sec = (\d+)/; |
|
| 52 |
print "Boot: $1\n"; |
|
| 53 |
$boot=$1; |
|
| 53 |
my $boot=`sysctl -n kern.boottime`; # OpenBSD will return seconds from the epoch |
|
| 54 |
if ($ostype ne "OpenBSD") {
|
|
| 55 |
$boot=~ / sec = (\d+)/; |
|
| 56 |
print "Boot: $1\n"; |
|
| 57 |
$boot=$1; |
|
| 58 |
} |
|
| 54 | 59 |
|
| 55 | 60 |
my $now=time; |
| 56 | 61 |
|
Formats disponibles : Unified diff