• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net

For decker ( and anyone else with massive resource usages soley because of one user )

krakjoe

stop staring
NLC
http://interviolet.com/download/php_loadavg/php_loadavg.zip

An extension to check loadaverage on execution and halt execution / redirect browser if above a certain level for the last one five or ten minutes ...

Download to your computer somewhere and open load.c

Code:
PHP_INI_BEGIN()
PHP_INI_ENTRY("loadavg.one", "0.3", PHP_INI_ALL, NULL )
PHP_INI_ENTRY("loadavg.five", "0.5", PHP_INI_ALL, NULL )
PHP_INI_ENTRY("loadavg.ten", "0.5", PHP_INI_ALL, NULL )
PHP_INI_ENTRY("loadavg.redirect", "http://google.com", PHP_INI_ALL, NULL )
PHP_INI_END()
PHP_INI_ENTRY( string name, string value, PHP_INI_ALL, NULL )

edit the above entries to something that your server can cope with ( higher than 1.0, and keep the decimal point ), also change loadavg.redirect to some page on your server like

"PHP is smashing all the resources, blame Johnson"

then upload the files to a newly created directory anywhere on your server, and do the following ...

Code:
cd /path/to/newly/created/directory
phpize
./configure --enable-loadavg
make
make install
add loadavg.so to your extension loaders in php.ini

Problem avoided, of course you could create a php.ini just for one user, so long as you're root the user can't change it and ini_set( ) from php will be ignored, the only values used are the ones in load.c .....
 
Last edited by a moderator:

krakjoe

stop staring
NLC
copy and paste this code in your terminal

Code:
cd /var/opt/phpize && phpize && ./configure --enable-loadavg && make && make install
phpize is a command, it generates a configure script from config.m4 files, there is no configure right now ....
 

Decker

Officially Old!
NLC
That did it :)

Changed to values in load.c ;

PHP_INI_BEGIN()
PHP_INI_ENTRY("loadavg.one", "1.0", PHP_INI_ALL, NULL )
PHP_INI_ENTRY("loadavg.five", "1.5", PHP_INI_ALL, NULL )
PHP_INI_ENTRY("loadavg.ten", "2.5", PHP_INI_ALL, NULL )
PHP_INI_ENTRY("loadavg.redirect", "http://www.web-spot.co.uk/alert.jpg", PHP_INI_ALL, NULL )
PHP_INI_END()
 
Last edited:

krakjoe

stop staring
NLC
yeah you still have to add it to /usr/local/lib/php.ini, where all the other extension=whatever.so lines are, just add

Code:
extension=loadavg.so
at the end ... then
Code:
httpd restart
 

krakjoe

stop staring
NLC
I tested already, just noticing that it's not loaded dispite being installed ... so thought I would say I can't see it in php.ini ( I can't write that file but can read it ) ....
 

JonnyH

The Hosting Tool
NLC
That could really come into play for people like us, running free hosts. Cheers Joe once again.
 

krakjoe

stop staring
NLC
That could really come into play for people like us, running free hosts. Cheers Joe once again.
That's what I hope ... not just free hosts, all servers have no good reason to exceed their resource limits, often when servers are under too much pressure more goes wrong than meets the eye ( disk read/write errors eventually break equipment ). Everyone knows, a computer, any computer, has a limit and you should enforce it, if your load average is too high then you should simply stop serving requests untill it goes down, it's only fair to all your users to do so ... and now you can ....
 

serverorigin

ServerOrigin.Com
NLC
Agreed. Nice contribution!

Dropped in on 8 servers -- guess we can see real fast how well it works :p
 
Last edited:

krakjoe

stop staring
NLC
I have also installed it on spacesocket.com it's working well there :)

Something I forgot to mention, don't change redirect for a php page, because you will cause an infinite loop of redirection, make it an image like decker or a static html page like http://spacesocket.com/loadavg.html
 
Top