[MOD] Server Uptime

Modifications for phpBB3.
Try the Mods here and share Your own Mods
Forum rules
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support

[MOD] Server Uptime

Post by martin123456 »

If the server (machine) gets rebooted the counter will reset ;)

Cut it short it's counted all the time the server is running any form of reboot will reset it now an internet loss will not reset the counter

here is mine after i rebooted my own server 10 days ago

Server uptime: 10 days, 17 hours, 36 minutes and 29 seconds

now if i turn off my internet and turn it back on i will still get the Server uptime: 10 days, 17 hours, 36 minutes and 29 seconds

make sense ?
Last edited by martin123456 on 28 Feb 2012, 13:16, edited 1 time in total.

[MOD] Server Uptime

Post by Cable Player »

Ok thanks for the info :)

[MOD] Server Uptime

Post by martin123456 »

edited my last post for you

[MOD] Server Uptime

Post by Cable Player »

Yep sure does, thank you :)
I might change the text to "Host Gator has been kind to us for......." :-D

[MOD] Server Uptime

Post by DoYouSpeakWak »

i like the idea of showing the server health on your forum. But some how it feel incomplete. I miss the php,kernel,mysql version. Not sure it can be added to this but this works perfect. Just needs to be adapted to html and phpbb.

Code: Select all

<?php 
// Operating system and release name
echo 'Operating System:' . php_uname(s) . ' ' . php_uname(r);
echo '<br />';
// Prints current PHP version
echo 'PHP Version:' .  phpversion();
echo '<br />';
// Prints current MySQL version
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
printf("MySQL server version: %s\n", mysql_get_server_info());
?>

[MOD] Server Uptime

Post by Stoker »

Im sure it can be done. But I would consider it a security threat.
But I can take a look if you want?

[MOD] Server Uptime

Post by DoYouSpeakWak »

It can be but only for very few, im sure fbi.gov would not have it listed. But if your on a big shared server the hackers can always spend 2 euros to get an account and get the info themself or hack some out dated script on one of the accounts. So yes it might be a security issue, but only for the high risk servers.

Thx, i have so little time atm to develop ideas its sad but irl matters more. I would love to see this added to my site site.dk/serverinfo/ page with alot of info on it.

[MOD] Server Uptime

Post by martin123456 »

Interesting thought i have it showing this so far on a private server.
server.png
You do not have the required permissions to view the files attached to this post.

[MOD] Server Uptime

Post by Stoker »

Code: Select all

$server_software = $_SERVER['SERVER_SOFTWARE'];
$php_version = PHP_VERSION;
$os = PHP_OS;
and

Code: Select all

'SERVER_SOFTWARE'	=> $server_software,
	'PHP_VERSION'		=> $php_version,
	'PHP_OS'			=> $os,

[MOD] Server Uptime

Post by DoYouSpeakWak »

Thx Stoker. The kernel would be nice to have as well. Played around with it a bit. But not quite done.

Results
phpbb_server_load_test1.jpg
Index.php

Code: Select all

$uptimeindex    = shell_exec("cut -d. -f1 /proc/uptime");
$daysindex       = floor($uptimeindex/60/60/24);
$hoursindex    = $uptimeindex/60/60%24;
$minsindex       = $uptimeindex/60%60;
$secsindex       = $uptimeindex%60;
$load          = sys_getloadavg();
$server_software = $_SERVER['SERVER_SOFTWARE'];
$php_version = PHP_VERSION;
$os = php_uname(s) . ' ' . php_uname(r);
$link = mysql_connect('localhost', 'root', '123456') . ' ' . mysql_get_server_info();

And

   'UPTIME_DAYS'      => $daysindex,
   'UPTIME_HOURS'      => $hoursindex,
   'UPTIME_MINS'      => $minsindex,
   'UPTIME_SECS'      => $secsindex,
   'AVG_LOAD0'         => $load[0],
   'AVG_LOAD1'         => $load[1],
   'AVG_LOAD2'         => $load[2],
	'SERVER_SOFTWARE'   => $server_software,
   'PHP_VERSION'      => $php_version,
   'PHP_OS'         => $os,
	'MYSQL_VERSION'    => $link,  
index_body.html

Code: Select all

{L_SERVER_UPTIME}: <strong>{UPTIME_DAYS}</strong> days, <strong>{UPTIME_HOURS}</strong> hours, <strong>{UPTIME_MINS}</strong> minutes and <strong>{UPTIME_SECS}</strong> seconds<br />
   {L_AVERAGE_LOAD}: <strong>{AVG_LOAD0}</strong> &bull; <strong>{AVG_LOAD1}</strong> &bull; <strong>{AVG_LOAD2}</strong>
   {L_SERVER_INFO}: Webserver:<strong>{SERVER_SOFTWARE}</strong> &bull; PHP version:<strong>{PHP_VERSION}</strong> &bull; Type and kernel:<strong>{PHP_OS}</strong> &bull; mysql:<strong>{MYSQL_VERSION}</strong>
You do not have the required permissions to view the files attached to this post.