LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Displaying Uptime (https://www.linuxquestions.org/questions/programming-9/displaying-uptime-146634/)

Das0 02-16-2004 03:13 AM

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.

Das0 02-16-2004 06:06 AM

Bump ... any help pls

amos 02-16-2004 07:13 AM

I would have thought that there would be something in /proc you could use.

Cheers
Amos

Strike 02-16-2004 07:19 AM

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.

fsbooks 02-16-2004 07:35 AM

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>

Strike 02-16-2004 02:56 PM

Pretty sure that uptime needs to be in quotes up there.

Das0 02-16-2004 04:37 PM

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.