Email notifications for server resources

Posted October 20, 2013 9.5k views
I've got a centOS/nginx droplet running many WordPress sites. I can use command line tools to see my resources like RAM, CPU, disk space but I am wondering if there's a way or a tool that'd alert me via email or text if they hit an upper limit, like 80% or 90%? Thanks all.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
7 answers

I suggest you monitor load rather than cpu usage, it gives you the overall state of the machine...
You can create your own script to notify you in cases that high loads occur:


load=`w | head -n1 | awk '{print$10}' | cut -d"," -f1`

if [ $load -gt $maxload ]; then
echo "Oh no, system load higher than $maxload detected..."
echo "Alerting $mail"
echo "$hn High Load Found." | mail -s "$hn High Load Found." -- $mail
echo "OK"
Apologies for jumping in here.

@yoavz.z - what exactly is 'load' and presumably there is a command to view the current load in Linux?

You can install "monit":
by Etel Sverdlov
Monit is a helpful program that automatically monitors and manages server programs to ensure that they not only stay online consistently, but that the file size, checksum, or permissions are always correct. This tutorial covers monit installation and provides an example of how to configure it for some common programs.
"... what exactly is 'load'..."

From From Wikipedia:

In UNIX computing, the system load is a measure of the amount of computational work that a computer system performs. The load average represents the average system load over a period of time. It conventionally appears in the form of three numbers which represent the system load during the last one-, five-, and fifteen-minute periods.

CPU load vs CPU utilization

The comparative study of different load indices carried out by Ferrari et al.[4] reported that CPU load information based upon the CPU queue length does much better in load balancing compared to CPU utilization. The reason CPU queue length did better is probably because when a host is heavily loaded, its CPU utilization is likely to be close to 100% and it is unable to reflect the exact load level of the utilization. In contrast, CPU queue lengths can directly reflect the amount of load on a CPU. As an example, two systems, one with 3 and the other with 6 processes in the queue, are both very likely to have utilizations close to 100% although they obviously differ.
Thanks @yoavz.z! I've implemented exactly that.
Just installed monit too. thank you drapko.

Would you mind adding your script to DigitalOcean User Projects | GitHub?