Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2009

    Kill all processes running under user X if server load is >Y... How to?


    I run a dedicated server with WHM/cPanel on CentOS 5 installed. From time to time, the gallery script running under user account "X" freaks out and server load grows to unresonable values. Most of the time, the script just works great, so I do not want to replace it.

    But I would like to accomplish to following:
    A script should get executed every 30mins (e.g. as cronjob) to check the 15min server load value. If this value is above 10, the script should kill all processes running under the account name "X". Additionally, receiving an eMail when this happened would be great.

    Would it be complicated to do this? I, myself, am unfortunately not good enough in script coding do have any idea...

    Or is there there any possibility to do this via CSF?

    Any help or suggestion is very much appreciated!
    Kind regards
    Last edited by Amitz; 05-21-2011 at 06:32 PM.

  2. #2
    Join Date
    Mar 2003
    checkload=`uptime | cut -d, -f4 | cut -d: -f2 | cut -d. -f1`
    if [ $checkload -ge 10 ]
    pkill -u user
    echo "High Load: $checkload" | mail -s "Load Monitor" [email protected]
    It's a crude script but it works under FreeBSD... I would test it out under Linux first before assuming it works. Basically if the load is 10 or higher, it will kill the user and all of their processes then send you an email of the load value. You can adjust accordingly..
    Patrick William | RACK911 Labs | Software Security Auditing
    400+ Vulnerabilities Found - Quote @ - Security notices for the hosting community.

  3. #3
    Join Date
    Jun 2009
    Bristol, UK
    Running Cloud Linux would best help your problem.

    In short it will limit the resources (CPU/RAM & Processes) that each account can use therefore reduces the likely hood of one account hogging all of your services resources and causing server slow down or crash.

    I use it on my boxes and it's made a heck of a difference. They offer a free trial, so you can always try it out, and it takes a few minutes to install as you're already running Centos which is what Cloud Linux was built around.


  4. #4

    Ditto on CloudLinux.

    Thank you.
    Peter M. Abraham
    LinkedIn Profile

  5. #5
    Join Date
    Jun 2009
    Please apologize for my delay in answering to your helpful posts.

    Thank you very much. In the end, it was your script example that solved my problem. I adopted it like this to work on my CentOS cPanel system (checking the 15min average load):

    checkload=`uptime | cut -d" " -f15 | cut -d. -f1`
    if [ $checkload -ge 6 ]
    pkill -u username
    echo "High Load: $checkload" | mail -s "Load Monitor" [email protected]
    Then, I found the option in ConfigServer Firewall (CSF) to execute a script when a certain server load is reached. I set the values
    "PT_LOAD" to "30" (so it checks the load every 30secs),
    "PT_LOAD_AVG" to "5" (5min average load value)
    "PT_LOAD_LEVEL" to "6" and
    "PT_LOAD_ACTION" to a little script that is simply based on the above code:

    pkill -u username
    echo "High Load:  Killed all processes running under username" | mail -s "Load Monitor" [email protected]
    This does exactly what I wanted to achieve...

    @Ricky-GWS and dynamicnet:
    I took a look at Cloud Linux and, indeed, it does what it should. If it would not just be 1 account that I have to keep under control, then this would be my weapon of choice to fight the problem. Thank you for the hint. I will keep that in mind in case that one day, I will have to tame several accounts!
    Last edited by Amitz; 05-24-2011 at 03:09 PM.

  6. #6
    Join Date
    Apr 2009
    I am looking for the exact script, will try to use this, thanks!

Similar Threads

  1. Lots of MySQL processes running, help me tweak server
    By chasebug in forum Hosting Security and Technology
    Replies: 2
    Last Post: 09-11-2010, 10:12 AM
  2. How can I kill all the PHP processes belonging to a specific user?
    By robotwink in forum Hosting Security and Technology
    Replies: 6
    Last Post: 10-11-2009, 02:14 PM
  3. Could any of these processes kill my server?
    By MartynD in forum Hosting Security and Technology
    Replies: 7
    Last Post: 11-16-2007, 03:22 PM
  4. Server load of over 2 without any known processes running
    By dotdoms in forum Dedicated Server
    Replies: 9
    Last Post: 03-25-2005, 10:41 AM
  5. What is happening here? Processes running, high load
    By nogi in forum Hosting Security and Technology
    Replies: 3
    Last Post: 10-19-2003, 05:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts