FreeBSD Uptime Script problem

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
mactfines
Posts: 9
Joined: Thu Apr 20, 2006 4:09 pm

FreeBSD Uptime Script problem

Post by mactfines »

Hi,

First, thank you to the developers and contributors for Cacti.

FreeBSD doesn't have /proc/uptime like Linux, so I wrote a small trivial script which takes no arguments, and prints out the uptime in days. Here it is:
#!/usr/bin/perl
my $boottime = `sysctl -h kern.boottime`;
$boottime =~ s/.* sec = ([0-9+].*)\,.*/$1/;
print int((time-$boottime)/86400);

I run it from the command line, and it does just what I want--print out the number of uptime days, no carriage return even:
shell# ./freebsd_uptime.pl
349shell#

(349 days is the correct number.)

This format is the same as the sample scripts included with Cacti, so far so good.

I then followed the very good "HowTo: Using Data Queries and Data Input Methods" to start graphing uptime. However, the graph (which I only started running today) is showing a value of 13.26k. I don't understand where this number is coming from. I did notice that 13,260 is evenly divisible by 60, to 221. Still that's nothing at all like 349.

Any ideas?

Thanks,
Ted

[/img]
Attachments
graph_image.php.png
graph_image.php.png (19.25 KiB) Viewed 1673 times
smeesmee
Posts: 1
Joined: Mon May 08, 2006 11:10 am

Check your path, use strict;

Post by smeesmee »

sysctl isn't in your path,
so $boottime is undefined,
so you are printing time/86400
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests