Mr. Black Posted January 1, 2003 Share Posted January 1, 2003 I was wondering if anyone could throw something together like a Site Load script I saw on DSLReports. (www.dslreports.com - on topbar on far right) If anyone can make a PHP or Perl Script just like that, i'm willing to float $10 to them. Thanks! Link to comment Share on other sites More sharing options...
0 john smith 1924 Veteran Posted January 1, 2003 Veteran Share Posted January 1, 2003 I presume its a straight php variable you can pull... what- i dont know. msg redmak Link to comment Share on other sites More sharing options...
0 m0fo Posted January 2, 2003 Share Posted January 2, 2003 i assume that u can make a script using php by just dividing the number of current visitors (within, say, 10 mins or so) by the total number u believe the server can support (say 100 users at the same time... just estimate this number) and just display a different image depending upon the percentage of users currently online Link to comment Share on other sites More sharing options...
0 Tim Dorr Veteran Posted January 2, 2003 Veteran Share Posted January 2, 2003 one sec... $uptime = @exec( "uptime" ); preg_match( "/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime, $avgs ); Access the avgs like: print $avgs[1];. Indices 1-3 will have the uptime stats for 1 minute, 10 minutes and 15 minutes. Paypal $10 to timdorr&timdorr,com :) Link to comment Share on other sites More sharing options...
0 BxBoy Posted January 2, 2003 Share Posted January 2, 2003 cool, now is there a way to put the output in my sig or somewhere else? Link to comment Share on other sites More sharing options...
0 Mr. Black Posted January 2, 2003 Author Share Posted January 2, 2003 Timdor, need it to do this, but I'm not very PHP Literate (am with BASIC though hehe)... I need it to display certain text around certain averages, see below. Can you fix this so it works right? Then you get your money. <?php $uptime = @exec( "uptime" ); preg_match( "/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime, $avgs ); if ( $avgs < "0.50" ) { echo ( "<b>Very Low</b>" ); } if ( $avgs < "0.79" ) { echo ( "<b>Lo</b>" ); } if ( $avgs > "0.80" ) { echo ( "<b>High</b>" ); } print $avgs[1]; ?> Link to comment Share on other sites More sharing options...
0 Mr. Black Posted January 2, 2003 Author Share Posted January 2, 2003 Actually, N/M. Here is the complete script - free for anyone's use. Please give me and Timdor credit. <?php $uptime = @exec( "uptime" ); preg_match( "/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime, $avgs ); echo ( "<a href=/misc/system_status.htm style=text-decoration: none>sysload:</a> " ); if ( $avgs[1] < "0.75" ) { echo ( "□□□□□□" ); exit; } if ( $avgs[1] < "1.00" ) { echo ( "<font color=green>■</font>□□□□□" ); exit; } if ( $avgs[1] < "2.00" ) { echo ( "<font color=green>■■</font>□□□□" ); exit; } if ( $avgs[1] < "3.00" ) { echo ( "<font color=green>■■<font color=yellow>■</font>□□□" ); exit; } if ( $avgs[1] < "4.00" ) { echo ( "<font color=green>■■<font color=yellow>■■</font>□□" ); exit; } if ( $avgs[1] < "6.00" ) { echo ( "<font color=green>■■<font color=yellow>■■<font color=red>■</font>□" ); exit; } if ( $avgs[1] < "7.00" ) { echo ( "<font color=green>■■<font color=yellow>■■<font color=red>■■</font>" ); exit; } if ( $avgs[1] > "8.00" ) { echo ( "<font color=red>OVERLOAD!!!</font>" ); exit; } ?> Link to comment Share on other sites More sharing options...
0 Tim Dorr Veteran Posted January 2, 2003 Veteran Share Posted January 2, 2003 I dunno about the exit's though. They stop the script cold. So, if you want to have stuff after this, you can't. Here's how to fix that: <?php $uptime = @exec( "uptime" ); preg_match( "/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime, $avgs ); echo ( "<a href=/misc/system_status.htm style=text-decoration: none>sysload:</a> " ); if ( $avgs[1] < "0.75" ) { echo ( "□□□□□□" ); } if ( $avgs[1] < "1.00" && $avgs[1] >= "0.75" ) { echo ( "<font color=green>■</font>□□□□□" ); } if ( $avgs[1] < "2.00" && $avgs[1] >= "1.00" ) { echo ( "<font color=green>■■</font>□□□□" ); } if ( $avgs[1] < "3.00" && $avgs[1] >= "2.00" ) { echo ( "<font color=green>■■<font color=yellow>■</font>□□□" ); } if ( $avgs[1] < "4.00" && $avgs[1] >= "3.00" ) { echo ( "<font color=green>■■<font color=yellow>■■</font>□□" ); } if ( $avgs[1] < "6.00" && $avgs[1] >= "4.00" ) { echo ( "<font color=green>■■<font color=yellow>■■<font color=red>■</font>□" ); } if ( $avgs[1] < "7.00" && $avgs[1] >= "6.00" ) { echo ( "<font color=green>■■<font color=yellow>■■<fontcolor=red>■■</font>" ); } if ( $avgs[1] > "8.00" && $avgs[1] >= "7.00" ) { echo ( "<font color=red>OVERLOAD!!!</font>" ); } ?> Link to comment Share on other sites More sharing options...
0 john smith 1924 Veteran Posted January 2, 2003 Veteran Share Posted January 2, 2003 timdorr- how do you use that script to do what neowins done- just echo the current serverload- how would you do that? Thanks Link to comment Share on other sites More sharing options...
0 john smith 1924 Veteran Posted January 2, 2003 Veteran Share Posted January 2, 2003 ps- the only thing i'll be paypalling you is my gratitude and eternal love :D :D Link to comment Share on other sites More sharing options...
0 Mr. Black Posted January 3, 2003 Author Share Posted January 3, 2003 Magoo - I wrote 95% of the script - the top line is his, all the rest was written by me, FYI... ;) Link to comment Share on other sites More sharing options...
0 Redmak Administrators Posted January 3, 2003 Administrators Share Posted January 3, 2003 timdorr- how do you use that script to do what neowins done- just echo the current serverload- how would you do that?Thanks Tom, if you mean the server load averages in admin then yes just echo them $uptime = @exec( "uptime" ); preg_match( "/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime, $avgs ); echo ("Server Load Averages: <b>$avgs[1], $avgs[2], $avgs[3]</b>"); Link to comment Share on other sites More sharing options...
0 john smith 1924 Veteran Posted January 3, 2003 Veteran Share Posted January 3, 2003 ah ok - superb. edit strange- this just gives this output "Server Load Averages: , , " why do you think that is? Link to comment Share on other sites More sharing options...
0 Redmak Administrators Posted January 3, 2003 Administrators Share Posted January 3, 2003 'uptime' is a linux command. Are you on a linux server? Link to comment Share on other sites More sharing options...
0 john smith 1924 Veteran Posted January 3, 2003 Veteran Share Posted January 3, 2003 yeah - i searched php.net on exec() and it kinda gave the impression it was used to execute perl scripts- is there someting else other than the snip of code above that i need? Link to comment Share on other sites More sharing options...
0 john smith 1924 Veteran Posted January 3, 2003 Veteran Share Posted January 3, 2003 btw- http://www.zeebit.com/beta/load.php Link to comment Share on other sites More sharing options...
0 Redmak Administrators Posted January 3, 2003 Administrators Share Posted January 3, 2003 Maybe you're not allowed to execute commands. script should be ok but you can try echo $uptime; to see if 'uptime' does anything Link to comment Share on other sites More sharing options...
Question
Mr. Black
I was wondering if anyone could throw something together like a Site Load script I saw
on DSLReports.
(www.dslreports.com - on topbar on far right)
If anyone can make a PHP or Perl Script just like that, i'm willing to float $10 to them.
Thanks!
Link to comment
Share on other sites
16 answers to this question
Recommended Posts