Welcome to Geeklog, Anonymous Friday, March 29 2024 @ 04:23 am EDT

Geeklog Forums

Server Uptime Block


Status: offline

efarmboy

Forum User
Moderator
Registered: 02/26/02
Posts: 147
I have created a block that displays Server Uptime (UNIX only) and will graphically display the status of key services. You can see the block running here

The block can be configured to just display the server uptime and/or the graphical status of the services.
I would normally not enable this block for all users. I have disabled the remote access (socket) for mySQL since GL runs locally, so RED in this case is a good indication.

The block and readme install notes are available for download - check it out using the download block (bottom right on my site).

 Quote

Anonymous

Anonymous
im getting this error when i enable the server uptime Warning: Failed opening '/var/www/ChkService/ChkService.php' for inclusion (include_path='.:/usr/share/pear') in /var/www/system/lib-custom.php on line 79 Fatal error: Call to undefined function: get_uptime() in /var/www/system/lib-custom.php on line 82 i check the lines and on line 79 its the path and its right.... on line 82 its a error with get_uptime() not sure why theres a error now....i remember i usto have this enabled a long time ago...but now dosent seem to work... also "YES" i did set the path and IP in the ChkService.php
 Quote

Jeremy1701

Anonymous
I can't find anywhere to d/l this block. Is it still available?

Jeremy
 Quote

Jeremy1701

Anonymous
Since I couldn't find it anywhere, I wrote my own.

Add this to the lib-custom.php file and create a block to it.

Text Formatted Code

/* Jeremy's attempt at an uptime block */
function phpblock_uptime() {
    $retval .= ' ';

    $uptime = exec("cut -d. -f1 /proc/uptime");
    $days = floor($uptime/60/60/24);
    $hours = $uptime/60/60%24;
    $mins = $uptime/60%60;
    $secs = $uptime%60;
    $retval .= $days . ' days' . $hours . ' hours' . $mins . ' minutes' . $secs . ' seconds';  

    return $retval;
}

 


Obviously, this only works on Linux/Unix and you have to be able exec using PHP.

Jeremy
 Quote

Jeremy1701

Anonymous
For some reason, the br tags not showing up in the above code segment. It should be

/* Jeremy's attempt at an uptime block */
function phpblock_uptime() {
$retval .= ' ';

$uptime = exec("cut -d. -f1 /proc/uptime&quotWink;
$days = floor($uptime/60/60/24);
$hours = $uptime/60/60%24;
$mins = $uptime/60%60;
$secs = $uptime%60;
$retval .= $days . ' days<br />' . $hours . ' hours<br />' . $mins . ' minutes<br />' . $secs . ' seconds';

return $retval;
}
 Quote

Status: offline

jhackwith

Forum User
Chatty
Registered: 07/24/04
Posts: 63
Location:Lewiston, Idaho
cheerful
Excellent block; works great. Thanks!
Jason
"Beauty... is the shadow of God on the universe." ~ Gabriela Mistral -- Desolacíon
 Quote

thetransient

Anonymous
Here's an alternative for the "code challenged" such as myself....Hahaha

The Uptime Project
http://en.uptime-project.net/

Can someone help me
 Quote

ironmax

Anonymous
Here is a server uptime that that fits right in the block and works on windows IIS servers. you will have to enable the extension=php_w32api.dll in the php.ini file though.

?php
$api = new win32;
$api->registerfunction("bool QueryPerformanceCounter (float &lpPerformanceCount) From kernel32.dll");
$api->registerfunction("bool QueryPerformanceFrequency (float &lpPerformanceFrequency) From kernel32.dll");

$api->QueryPerformanceCounter($a);
$api->QueryPerformanceFrequency($b);
$c = $a/$b;
$days = floor($c / 86400);
echo gmstrftime("System uptime is:
$days Days
%H Hr
%M Min
%S Sec
", $c);
?>
 Quote

All times are EDT. The time is now 04:23 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content