Server load monitoring script
Increasing the server load will cause serious issues like downtime & service outage. Here is a simple bash script to monitor the server load so you can aware about load on your servers.
server load monitoring script
Step1. Create file /root/load.sh
Add the following script on the file
#!/bin/bash trigger=10.00 load=`cat /proc/loadavg | awk '{print $1}'` response=`echo | awk -v T=$trigger -v L=$load 'BEGIN{if ( L > T){ print "greater"}}'` if [[ $response = "greater" ]] then sar -q | mail -s"High load on `hostname` - [ $load ]" [email protected] fi
In this script,it will notify you via mail, if the server load went above 10.
chmod 755 /root/load.sh
If you would like to add it as cron
crontab -e
5 * * * * /root/load.sh
FYI : You can adjust the trigger value as you like. Change the mail account name in the script.