Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / other / uptime_bsd @ e803e46a

Historique | Voir | Annoter | Télécharger (1,02 ko)

1 e803e46a Sec
#!/usr/local/bin/perl -w
2
# -*- perl -*-
3
# Plugin to monitor number of irqs
4
#
5
#%# family=auto
6
#%# capabilities=autoconf
7
8
use strict;
9
10
my %IN;
11
12
my $sysctl = defined($ENV{sysctl}) ? $ENV{sysctl} : '/sbin/sysctl';
13
14
if (defined($ARGV[0]) and ($ARGV[0] eq 'autoconf')) {
15
	if ( -x $sysctl ) {
16
		print "yes\n";
17
	}else{
18
		print "no (sysctl binary not found)\n";
19
	};
20
	exit;
21
};
22
23
if (defined($ARGV[0]) and ($ARGV[0] eq 'config')) {
24
print <<EOT ;
25
graph_title Uptime
26
graph_args --base 1000 -l 0
27
graph_vlabel days
28
graph_category system
29
compile.label kernel age
30
compile.type GAUGE
31
compile.min 0
32
compile.max 1000
33
compile.draw AREA
34
uptime.label uptime
35
uptime.type GAUGE
36
uptime.min 0
37
uptime.max 1000
38
uptime.draw AREA
39
EOT
40
exit;
41
}
42
43
use Date::Parse;
44
45
my $kern=`sysctl -n kern.version`;
46
$kern=~ /:\s+(.*\S)\s+\w+\@/;
47
print "Compile: $1\n";
48
$kern=str2time($1);
49
50
my $boot=`sysctl -n kern.boottime`;
51
$boot=~ / sec = (\d+)/;
52
print "Boot: $1\n";
53
$boot=$1;
54
55
my $now=time;
56
57
print "compile.value ",($now-$kern)/60/60/24,"\n";
58
print "uptime.value ",($now-$boot)/60/60/24,"\n";