File: uptime.in

package info (click to toggle)
munin 2.0.76-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,068 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (51 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!@@PERL@@
# -*- mode: cperl; cperl-indent-level: 8; -*-

=head1 NAME

uptime - Plugin to measure uptime on solaris

=head1 CONFIGURATION

No configuration

=head1 AUTHOR

Adam J. Baker (adam@unb.ca)

=head1 LICENSE

GPLv2

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf

=cut

use strict;
use Munin::Plugin;

my $KSTAT = '/usr/bin/kstat -p';
my $STATISTIC = 'unix:0:system_misc:boot_time';

if ($ARGV[0] eq 'autoconf') {
        print "yes\n";
} elsif ($ARGV[0] eq 'config') {
        print "graph_title Uptime\n";
        print "graph_args --base 1000 -l 0 \n";
        print "graph_scale no\n";
        print "graph_category system\n";
        print "graph_vlabel uptime in days\n";
        print "uptime.label uptime\n";
        print "uptime.draw AREA\n";
        print_thresholds("uptime");
} else {
        my $uptime = `$KSTAT $STATISTIC`;

        $uptime =~ m/^$STATISTIC\s*(\d*)$/;

        # uptime in days
        printf "uptime.value %0.2f\n", ((time() - $1) / (60 * 60 * 24));
}