kevc978 Posted January 15, 2007 Share Posted January 15, 2007 Hi all, Anyone know how to modify the status script to show uptime on a FreeBSD server? Everything else is working fine except the uptime part... i know its not the usual command that the status php uses, it comes from /usr/bin/uptime im just unsure how to get the script to parse the info. Any help very well appreciated!! 0 Quote Link to comment Share on other sites More sharing options...
s1rk3ls Posted January 15, 2007 Share Posted January 15, 2007 Take a look at the status.php that you put on the freebsd server, maybe modifying something in it? I've messed around with it a little for one server I used to have that I wanted to monitor and it didn't work right, but don't have it any more so I don't remember what all I had to do to get it to work. 0 Quote Link to comment Share on other sites More sharing options...
kevc978 Posted January 16, 2007 Author Share Posted January 16, 2007 its cool, got it fixed, if anyone else has a freebsd box and needs the script i'd be happy to distribute it 0 Quote Link to comment Share on other sites More sharing options...
BATeller Posted April 19, 2010 Share Posted April 19, 2010 its cool, got it fixed, if anyone else has a freebsd box and needs the script i'd be happy to distribute it I know this thread is old, but I'm trying to display uptime on a FreeBSD server. Can you post the code change? 0 Quote Link to comment Share on other sites More sharing options...
BATeller Posted April 19, 2010 Share Posted April 19, 2010 I think I got it. After the last "else" statement I removed what was there and added the following. $upstr = shell_exec("/sbin/sysctl -n kern.boottime");$outstr = explode(" ", $upstr); $uptime = $outstr[6]; load avgs. seems to work as well without any changes. 0 Quote Link to comment Share on other sites More sharing options...
BATeller Posted April 19, 2010 Share Posted April 19, 2010 Actually I did some more investigating and taking 'usec' is the wrong value. I needed to take 'sec' and subtract it from the current time in seconds format. So making some minor tweeking... adding this in place of the code in the last else statement currently works: $upstr = shell_exec("/sbin/sysctl -n kern.boottime"); $outstr = explode(" ", $upstr); $date = shell_exec("/bin/date +%s"); $uptim = $outstr[3]; $uptim= preg_replace('/[\,]/', '', $uptim); $uptime = ($date - $uptim); 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.