#!/usr/bin/perl
#
# Plugin to monitor uptime in FreeBSD hosts.
#
# Parameters:
#
#       config
#       autoconf
#
#%# family=auto
#%# capabilities=autoconf

use strict;
use warnings;

my $arg = shift();

if (defined($arg) && $arg eq 'config') {
        print("graph_title Uptime
graph_args --base 1000 -l 0
graph_vlabel uptime in days
graph_scale no
graph_category system
uptime.label uptime
uptime.draw AREA
");
        exit;
} elsif (defined($arg) && $arg eq 'autoconf') {
        print "yes\n";
        exit;
}

my $boottime = `/sbin/sysctl kern.boottime`;
$boottime =~ s/.* sec = ([0-9+].*)\,.*/$1/;
printf "uptime.value %.03f\n", (time-$boottime)/86400;

