I’ll be discussing server load in an upcoming post, so I wanted to provide everyone with this handy little bash script for automatically checking your server load and sending you an email and a text message if it goes over the maximum load you’ll accept.
This really is a simply one. All you have to do is copy and paste the below script into a new .sh file on your server (e.g., nano checkload.sh) , edit it where indicated and then save it, give it execute permissions (e.g., chmod 755 checkload.sh), and then set up a line in your crontab to run it as often as you like – I run mine every 2 minutes (e.g., */2 * * * * ~/checkload.sh > /dev/null 2>&1).
Click the link below for the file. You’ll need to change the top section, which contains six variables, to suit your needs. There are instructions in the file, so it should be super-simple.
Like this script? Made improvements or have suggestions? Let us know in the comments below!