The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Script to e-mail me when load is certain point

Discussion in 'E-mail Discussions' started by noimad1, Sep 28, 2008.

  1. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    Does anyone have a script, or know how to create one that I could have that could e-mail me when the server load reaches a certain point?

    It e-mails me when the load is high over a period of time. But I want one that triggers at a specific point, that I could run every 2 minutes or so.
     
  2. wa4fat

    wa4fat Well-Known Member

    Joined:
    Dec 30, 2001
    Messages:
    51
    Likes Received:
    1
    Trophy Points:
    8
    Load alert shell script

    Here ya go:

    ----------------

    #!/bin/sh
    load=`uptime | awk -F'load average: ' '{print $2}' | awk -F'.' '{print $1}'`;
    if [ $load -gt 10 ];
    then
    echo "`hostname` load is high: $load" | mail -s "`hostname` load alert" your_email@domain.com
    fi

    ----------------

    As you can see, the load trigger on this particular script is 10, but you may change to whatever value you wish. Also, be sure to change your_email@domain.com to your desired destination email address.

    I run this sort of script from /root

    All the best - Bill
     
  3. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    Bill,

    Thank you so much!
     
  4. Bailey

    Bailey Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    120
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Wisconsin
    ConfigServer's free firewall server emails you when the load goes up, too. You can choose what # you want the threshold to be. And you get a kick-butt firewall to boot. :)

    :D Bailey
     
  5. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    I do have that firewall as well. but I believe it only e-mails you after the load has been high for a while.

    I was trying to catch it right away. This particular server's load generally stays under .50. However, at random times it would jump up to 30-40.

    So far I think i've tracked it down to search engine bots. Some obscure bots were trashing the server load. This is 500,000+ post message forum. So they were going nuts crawling it.
     
  6. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,448
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Not correct, go over your settings a bit closer.
     
  7. Bailey

    Bailey Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    120
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Wisconsin
    This setting is fully customizable. Adjust the settings to what you need them to be for your use. ;)

    :D Bailey
     
  8. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    One thing to consider. If your server's load is so high that it is about to break, then its doubtful that the server will have enough resources available to send you that e-mail.

    Depending on e-mail notification for when a server is about to go down isn't going to be very reliable. You would be better served to use remote monitoring or third-party monitoring to tell you that the server is offline.

    If you just want to monitor the load, then something like this, or the LFD+CSF monitoring, should be really helpful. Just don't put all of your eggs into this basket hoping that you can circumvent server outages with something like this.
     
  9. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    Not what I was trying to do. I'm not trying to see when the load hits 90+. This server normally ran with a load of 0.50. Then would spike to the 20-30 mark. So all i wanted to do is have the server e-mail me when the load was say 2.0. That would tell me the load was starting to climb. Then maybe give me a chance to ssh into the server before it did get to the point where everything locked up.

    This worked with the script provided by bill earlier on in the forum. And I was able to ssh in and find out what was killing my load.....darn random search engine spiders.
     
Loading...

Share This Page