FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


[PHP] Server Load





Marston
Heyo, I got this script from a website (it didnt provide too much documentation) to "shut off" your website when it's too busy. So here's what I 'm asking - what's the "limit" variable supposed to represent? Like, 1.25 of what? Here's the code, hope you guys can help me out.
Code:
<?PHP
// Change the Limit to what you want (defailt : 2.00)
// MUST CONTACT to digits after at dot!!!
$limit = "1.25";

$load = @exec('uptime');
preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/",$load,$avgs);

echo "<!-- Server Load: ".$avgs[1].". Server Load Limit: ".$limit.". -->\n\n";

if($avgs[1] > $limit){
echo "<h1>Server Too Busy</h1><hr />";
echo "<img src=\"/icons/ball.gray.gif\" border=\"0\" />Current Server Load ".$avgs[1].".<br /><img src=\"/icons/ball.gray.gif\" border=\"0\" />The limit is ".$limit."<br /><hr />". $_SERVER['SERVER_SIGNATURE'];
die();
}
?>
PatTheGreat42
How did the site want you to use this code - was it supposed to be it's own PHP file, or be at the top of every page, or what? That might help.
Marston
Top of every page. It's not that I don't know where to use it, it's just that I don't know what I shut put in the $limit variable.
n0obie4life
Limit is

if the server load is above 1.25, it will shut off your website.

if it's below 1.25, your website will work.

I recommend placing it at 1.50 Smile
Marston
Razz I already knew that if the serverload reaches $limit, it shuts down, but, I was wondering how the server load is calculated? I've asked a few other people in the 'biz, but none knew the answer... Sad
Related topics
does the firhost.net php server have PEAR?
server load
Server Load
[RESOLVED] Server Load
PHP-Server at localhost
Is there any local php server program?
access active directory ldap server with php
Search function server load relief.
What time is Server 2 load lower?
Whats the best PHP server?
Running PHP Script without PHP Server?
very very basic php editor (only WRITING)
Server Load
Apache/Php5/MySql = Complete Fustration
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.