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

use strict;

my $arg = shift();

if ($arg eq 'config') {
    print("graph_title Uptime
graph_args --base 1000 -l 0
graph_vlabel uptime in days
uptime.label uptime
uptime.draw AREA
");
    exit;
} elsif ($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;

