Jump to content

Status on FreeBSD


kevc978

Recommended Posts

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!!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 years later...

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.

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated