Displaying Uptime
How can I go about adding my slackware box' uptime to my webpage? Any thoughts/ideas or any help really would be great.
|
Bump ... any help pls
|
I would have thought that there would be something in /proc you could use.
Cheers Amos |
A simple CGI with some sort of system-like call (depending on what language you use) to uptime should be fine. You need to be more specific with what kinds of tools you're willing to use.
|
Here is a snipet of code (php I believe) I cut out of our webserver pages that will do it. It puts the output of the system command uptime in the variable uptimereturn, reformats the variable, and extracts local time (the first variable) and uptime (the 3rd variable) w/units, (the 4th variable). These are printed in a table.
#server info stuff: $uptimereturn=exec(uptime); $systat=explode(",",$uptimereturn); $systat[0]=trim($systat[0]); $times=explode(" ",$systat[0]); <div align=\"center\"> <font size=\"+1\">Web Server Information:</font></div>< <table width=\"60%\" align=\"center\"> <tr><td width=\"40%\"> Local Time: </td><td width=\"60%\"> $times[0] </td></tr> <tr><td width=\"40%\"> Up Time: </td><td width=\"60%\"> $times[3] $times[4] </td></tr> </table> |
Pretty sure that uptime needs to be in quotes up there.
|
Ok thanks for the help I made a .cgi
#!/bin/sh echo "Content-Type: text/html\n\n" uptime |
All times are GMT -5. The time now is 03:42 PM. |