1. Howdy! Welcome to our community of more than 125.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
  2. Add your web host to our brand new web hosting directory (beta).

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

Discussion in 'Selected best free scripts' started by krakjoe, Nov 15, 2007.

  1. krakjoe

    krakjoe stop staring NLC

    Joined:
    May 19, 2006
    Messages:
    3,619
    Likes Received:
    83
    Trophy Points:
    0
    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: Nov 24, 2007
  2. Decker

    Decker Officially Old! NLC

    Joined:
    Dec 19, 2003
    Messages:
    10,158
    Likes Received:
    162
    Trophy Points:
    173
    Won't configure :crying5:

    in var/opt so that bits okay?!
     
  3. krakjoe

    krakjoe stop staring NLC

    Joined:
    May 19, 2006
    Messages:
    3,619
    Likes Received:
    83
    Trophy Points:
    0
    show me error ... I built a copy for your version of php in /home/intervio @ loadavg.so
     
  4. Decker

    Decker Officially Old! NLC

    Joined:
    Dec 19, 2003
    Messages:
    10,158
    Likes Received:
    162
    Trophy Points:
    173
    ./configure --enable-loadavg
    -bash: ./configure: No such file or directory
     
  5. krakjoe

    krakjoe stop staring NLC

    Joined:
    May 19, 2006
    Messages:
    3,619
    Likes Received:
    83
    Trophy Points:
    0
    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 ....
     
  6. Decker

    Decker Officially Old! NLC

    Joined:
    Dec 19, 2003
    Messages:
    10,158
    Likes Received:
    162
    Trophy Points:
    173
    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: Nov 15, 2007
  7. krakjoe

    krakjoe stop staring NLC

    Joined:
    May 19, 2006
    Messages:
    3,619
    Likes Received:
    83
    Trophy Points:
    0
    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
     
  8. Decker

    Decker Officially Old! NLC

    Joined:
    Dec 19, 2003
    Messages:
    10,158
    Likes Received:
    162
    Trophy Points:
    173
    Already done - I might change the landing page though :D maybe.
     
  9. krakjoe

    krakjoe stop staring NLC

    Joined:
    May 19, 2006
    Messages:
    3,619
    Likes Received:
    83
    Trophy Points:
    0
    its not loaded .... don't see it added in php.ini ....
     
  10. Decker

    Decker Officially Old! NLC

    Joined:
    Dec 19, 2003
    Messages:
    10,158
    Likes Received:
    162
    Trophy Points:
    173
    Haven't restarted httpd yet ;)

    Don't tell me you were going to test it out ??
     
  11. krakjoe

    krakjoe stop staring NLC

    Joined:
    May 19, 2006
    Messages:
    3,619
    Likes Received:
    83
    Trophy Points:
    0
    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 ) ....
     
  12. Decker

    Decker Officially Old! NLC

    Joined:
    Dec 19, 2003
    Messages:
    10,158
    Likes Received:
    162
    Trophy Points:
    173
    Try it now :)
     
  13. krakjoe

    krakjoe stop staring NLC

    Joined:
    May 19, 2006
    Messages:
    3,619
    Likes Received:
    83
    Trophy Points:
    0
    now it's loaded :) I feel much better ....
     
  14. Decker

    Decker Officially Old! NLC

    Joined:
    Dec 19, 2003
    Messages:
    10,158
    Likes Received:
    162
    Trophy Points:
    173
    So do I for some strange reason - cough.....

    Nice work Joe :D
     
  15. JonnyH

    JonnyH The Hosting Tool NLC

    Joined:
    Oct 21, 2006
    Messages:
    2,616
    Likes Received:
    61
    Trophy Points:
    0
    That could really come into play for people like us, running free hosts. Cheers Joe once again.
     
  16. Decker

    Decker Officially Old! NLC

    Joined:
    Dec 19, 2003
    Messages:
    10,158
    Likes Received:
    162
    Trophy Points:
    173
    Just don't ask what inspired it :lol:
     
  17. krakjoe

    krakjoe stop staring NLC

    Joined:
    May 19, 2006
    Messages:
    3,619
    Likes Received:
    83
    Trophy Points:
    0
    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 ....
     
    Decker likes this.
  18. serverorigin

    serverorigin ServerOrigin.Com NLC

    Joined:
    Jun 21, 2006
    Messages:
    1,158
    Likes Received:
    19
    Trophy Points:
    0
    Agreed. Nice contribution!

    Dropped in on 8 servers -- guess we can see real fast how well it works :p
     
    Last edited: Nov 16, 2007
  19. krakjoe

    krakjoe stop staring NLC

    Joined:
    May 19, 2006
    Messages:
    3,619
    Likes Received:
    83
    Trophy Points:
    0
    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
     
  20. JonnyH

    JonnyH The Hosting Tool NLC

    Joined:
    Oct 21, 2006
    Messages:
    2,616
    Likes Received:
    61
    Trophy Points:
    0
    After i've installed ASP.NET on this CentOS Server I'll get busy with this.
     

Share This Page