View Full Version : Server Uptime
Etcher
06-27-2002, 10:00 PM
Not really a HACK, but nice little script for information...
I added "System Uptime" to the footer of my site:
Save this as uptime.php:
<?PHP
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
echo "<center><font size=1>";
echo "System Uptime: ";
echo $wholeday . " Days ";
echo $wholehour . " Hours ";
echo $wholeminute . " Minutes <br>";
echo "</font></center>";
?>
Then "include" that file in your footer, or anywhere else you want it displayed.
The actual uptime is a check of mySQL dB.
Enjoy!
filburt1
06-28-2002, 02:53 PM
You can also put that in your phpinclude template and then write the variables in the footer template.
Chris M
06-28-2002, 02:59 PM
Cool!
Satan
Chris M
06-28-2002, 03:07 PM
I think you will find that if you wanted add it to the Admin CP, you could do this :
in admin/index.php
Find :
makenavselect("Options","<hr>");
// *************************************************
And add below :
makenavoption("Uptime","uptime.php?s=");
makenavselect("Database");
// ***
Then create a new file called uptime.php, and enter :
<html>
<head>
<link rel="stylesheet" href="../cp.css">
</head>
</html>
<?PHP
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
echo "<center><font size=1>";
echo "System Uptime: ";
echo $wholeday . " Days ";
echo $wholehour . " Hours ";
echo $wholeminute . " Minutes <br>";
echo "</font></center>";
?>
(The difference is, that this takes the CP colours and uses them instead of just white and black)
Satan
Chris M
06-28-2002, 03:08 PM
Just incase you want to know:)
Satan
Boofo
06-28-2002, 05:02 PM
How would I use the code for this? Where would I put the code and how would I call it in here?
makelabelcode('Server Uptime', uptime.php);
Chris M
06-28-2002, 06:29 PM
Just put the php in a file called "uptime.php", and upload it to your admin folder...
Satan
TheWulff
06-28-2002, 09:43 PM
How would I change the text color to white ? Sorry newbie to PHP..
Chris M
06-28-2002, 10:00 PM
I believe you would enter this :
<html>
<head>
<link rel="stylesheet" href="../cp.css">
</head>
</html>
<?PHP
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
echo "<center><font color="#FFFFFF"><font size=1>";
echo "System Uptime: ";
echo $wholeday . " Days ";
echo $wholehour . " Hours ";
echo $wholeminute . " Minutes <br>";
echo "</font></font></center>";
?>
Satan
TheWulff
06-28-2002, 10:08 PM
Thanks for the reply but nope, bot this error...
Parse error: parse error, expecting `','' or `';'' in /home/sites/site33/web/uptime.php on line 15
Bluemann
06-28-2002, 10:25 PM
Ok well im a newbie at this, i created the uptime.php and uploaded it but how do i "include" that in my footer, is there a code?
Chris M
06-28-2002, 10:31 PM
include("./uptime.php");
Assuming that uptime.php is located in the root folder...
TheWulff - Hmmm...
Try :
<html>
<head>
<link rel="stylesheet" href="../cp.css">
</head>
</html>
<?PHP
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
echo "<center><font color=#FFFFFF><font size=1>";
echo "System Uptime: ";
echo $wholeday . " Days ";
echo $wholehour . " Hours ";
echo $wholeminute . " Minutes <br>";
echo "</font></font></center>";
?>
Satan
Bluemann
06-28-2002, 11:06 PM
<a href="http://www.mwgclan.net/forums/" target="_blank">http://www.mwgclan.net/forums/ </a> php is in the root.php is in the root.i included your code at the bototm where it says server uptime: but it dosent work, and yes the file is in the root
Boofo
06-28-2002, 11:10 PM
I am trying to put it in the Quick Stats between Server type and MySQL. I want it to display the time there.
Originally posted by hellsatan
Just put the php in a file called "uptime.php", and upload it to your admin folder...
Satan
TheWulff
06-29-2002, 02:47 AM
hellsatan code worked this time, but still lost as to the include ? do I have to include it in phpinclude ? or copy the code above in the footer ? Thanks for the help, much apperciated.
Chris M
06-29-2002, 12:30 PM
What...
You mean :
include("./uptime.php");
That wasnt for you, it was for the person who replied after you:)
Satan
Chris M
06-29-2002, 12:30 PM
What...
You mean :
include("./uptime.php");
That wasnt for you, it was for the person who replied after you:)
Satan
Chris M
06-29-2002, 12:30 PM
What...
You mean :
include("./uptime.php");
That wasnt for you, it was for the person who replied after you:)
Satan
TheWulff
06-29-2002, 01:47 PM
hehe I now that but I dont know how to include it in my footer ;(
SemperFidelis
06-29-2002, 02:53 PM
Now this is a pretty cool idea
Cheers to evryone for their input so far
:)
Does anyone have an idea on what the best way would be to integrate this with Admin Quick Stats ?
This is what currently is displayed in my /admin/index.php
http://www.vianet.net.au/~daren/vbulletin/quickstats.jpg
And I would like to add its content directly below
-Server Type
-MYSQL
entries if possible
firewars
06-29-2002, 02:54 PM
Neither way is working.
I tried including it in the footer: how would that work anyway? No PHP parsing down there.
I tried parsing the code in the phpinclude-template and then used echo to show the values: there are none.
Somehow I just can't get values to show - not even running "uptime.php" directly gives me valid numbers (0 0 0 must be wrong).
*gee* :eek:
paste this into your phpinclude template
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
paste this into your footer template, right after $copyrighttext<br>
<smallfont>System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes
</smallfont>
All done :)
firewars
06-29-2002, 03:27 PM
I told you I did that.
And as I said, it's (still) not working.
firewars
06-29-2002, 03:34 PM
Ok, it's somehow my fault.
I've already got a "script" in my phpinclude-template and it looks like it doesn't really like yours.
Any way to let the vB know where one "script" ends and where another one starts?
firewars
06-29-2002, 03:36 PM
Never mind.
I just cut the script there was out and pasted it back in - it seems to work now.
Thanks ;)
Boofo
06-29-2002, 05:19 PM
How would you make a single variable out of it so you can call it like this:
$sysuptime
I'm trying to put it in my Quick Stats in the admin cp. And where would I call the variable from? Still in my phpinclude?
Originally posted by nuno
*gee* :eek:
paste this into your phpinclude template
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
paste this into your footer template, right after $copyrighttext<br>
<smallfont>System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes
</smallfont>
All done :)
firewars
06-29-2002, 05:33 PM
For those that want seconds as well, here you go :)
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
$seconds = (($minutes - $wholeminute)*60);
$wholesecond = (int) $seconds;
..for those who want 1 variable that has all the stuff in it, add this line below all the code:
$sysuptime = "System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes";
..with seconds (see my code):
$sysuptime = "System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes $wholesecond Seconds";
..then put $sysuptime where you want that line to show - enjoy.
You can also call it via its own template. use nuno's code then do this
in global.php find
$header='';
$footer='';
under that code add
eval("\$uptime = \"".gettemplate('uptime')."\";");
go to your admin cp and add a new template called uptime and paste this into it
<smallfont>System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes
</smallfont>
in the footer replace this
$copyrighttext<br>
with this
$copyrighttext<br>$uptime
untested but sould work :)
Boofo
06-29-2002, 08:46 PM
How would I use this in the admin cp in the index file? It doesn't seem to like it when I try to call it from phpinclude...nothing show up.
SemperFidelis
07-01-2002, 12:06 AM
Has anyone come up with a way to do this
https://vborg.vbsupport.ru/showthread.php?postid=267264#post267264
Boofo
07-01-2002, 12:17 AM
Do the following:
In your admin/index.php add this:
//Server Uptime Code
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$a='s';
if (intval($wholeday)<1){
$wholeday=0;
}if (intval($wholeday)==1){
$a='';
}
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$b='s';
if (intval($wholehour)<1){
$wholehour=0;
}if (intval($wholehour)==1){
$b='';
}
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
$c='s';
if (intval($wholeminute)<1){
$wholeminute=0;
}if (intval($wholeminute)==1){
$c='';
}
$seconds = (($minutes - $wholeminute)*60);
$wholesecond = (int) $seconds;
$d='s';
if (intval($wholesecond)<1){
$wholesecond=0;
}if (intval($wholesecond)==1){
$d='';
}
makelabelcode('Server Uptime', "$wholeday day$a, $wholehour hour$b, $wholeminute minute$c and $wholesecond second$d.");
right above this:
makelabelcode('MySQL', 'v' . $mysqlversion['version']);
and you'll be all set. I even added code that will make it say 1 day or 1 minute instead of days or minutes (plural).
Enjoy! :)
Originally posted by v-net
Has anyone come up with a way to do this
https://vborg.vbsupport.ru/showthread.php?postid=267264#post267264
SemperFidelis
07-01-2002, 12:34 AM
Cheers Boofo
Worked like a charm
:)
Server Type Linux / PHP v4.1.2
MySQL v3.23.49-log
Server Uptime 149 days, 6 hours, 7 minutes and 23 seconds.
Boofo
07-01-2002, 01:02 AM
I'm also working on an extention to the Quick Stats that will give you even more information. This is just a start.
Server Type
Linux / PHP v4.2.1 | Protocol:HTTP/1.0 | Port:80
Server Load Averages
0.85, 1.01, 0.81
Server Uptime
2 days, 1 hour, 55 minutes and 41 seconds.
Current Online Users
1 users online (1 members & 0 guests).
MySQL
v3.23.45
By the way, notice the "1 hour" above instead of "1 hours" with an s. :)
Originally posted by v-net
Cheers Boofo
Worked like a charm
:)
SemperFidelis
07-01-2002, 01:12 AM
Looks pretty cool so far
Good luck
:)
Boofo
07-01-2002, 01:17 AM
Here's the top part of it that I have done and working so far. It is in a table like the Quick Stas but shorter. :)
vBulletin Extra Options Menu
vBulletin Options
Modify Replacements
Private Messages
View Main Forum
View Memberlist
Run a SQL query
Modify Templates
Spin Threads
New Message Posts
View Online Users
Quick Template Search
hypedave
07-01-2002, 11:39 AM
jus moved my forum over to a new forum, and now the uptime is stuck on my last server's uptime, any suggestions
Boofo
07-01-2002, 11:52 AM
Use myphpadmin and go to the table and delete the row, I think. Look in the database and it should be pretty self-explanatory.
freakyshiat
07-02-2002, 03:55 AM
The uptime info doesnt match the 'top' command
webhost
07-03-2002, 12:47 AM
Here is what we use.
http://www.realwebhost.net/netstatus/
Wildthinks
07-04-2002, 08:48 AM
Originally posted by Etcher
Not really a HACK, but nice little script for information...
...cut.....
The actual uptime is a check of mySQL dB.
Enjoy!
I have enjoid, very nice hack, but waht mean uptime? The uptime from the mysql-Database?
How detected?
My server works over 40 days online and my uptime is 8 days?
I dont understand what uptime mean...please explain :alien: :knockedout:
a43079
09-16-2002, 02:51 PM
I tried the hack and this is the error i get...
Warning: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) in /home/www/eroweb/admin/uptime.php on line 8
Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) in /home/www/eroweb/admin/uptime.php on line 8
Warning: MySQL: A link to the server could not be established in /home/www/eroweb/admin/uptime.php on line 8
Warning: Supplied argument is not a valid MySQL result resource in /home/www/eroweb/admin/uptime.php on line 9
System Uptime: 0 Days 0 Hours 0 Minutes
------------------------------------------------------------------------------
This is from the admin menu
Erwin
09-16-2002, 10:49 PM
Originally posted by Wildthinks
I have enjoid, very nice hack, but waht mean uptime? The uptime from the mysql-Database?
How detected?
My server works over 40 days online and my uptime is 8 days?
I dont understand what uptime mean...please explain :alien: :knockedout:
Uptime = how long your server has been running before it had downtime ie. went offline because of a reboot, crash etc.
Also, correct me if I'm wrong, but this would an extra query to every page if you place this in your footer, wouldn't it?
pjgoncalves
02-15-2003, 04:12 PM
tks :)
Originally posted by nuno
*gee* :eek:
paste this into your phpinclude template
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
paste this into your footer template, right after $copyrighttext<br>
<smallfont>System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes
</smallfont>
All done :)
chr@nox
02-15-2003, 07:17 PM
Originally posted by Erwin
Uptime = how long your server has been running before it had downtime ie. went offline because of a reboot, crash etc.
Also, correct me if I'm wrong, but this would an extra query to every page if you place this in your footer, wouldn't it?
as far as i can see yea..looks like it adds an extra query for every page :)
but anyhow...very nice hack :)
thanx!
Snapperhaed
03-21-2003, 10:02 PM
Worked fine on v2.3.3 (Nunos Method) - Thanks!
Intex
03-31-2003, 10:59 AM
Worked great - thx for the hack :).
Dean C
03-31-2003, 12:11 PM
Can the original hack author please put the hack in a textfile to prevent unlicensed users from seeing the code :)
Thanks
- miSt
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.