Tuesday, May 20, 2014

Shell Script to send email alerts when the server load average is more than 5

World of Linux Server Management, Windows Server Management, Kernel Programming, Ethical Hacking, Cloud Solutions, Vmware Vsphere ESXi, Xen Servers, Server hardening, Server administration etc.,
#!/bin/bash
avg=`uptime | awk ‘{print $8″ ” $9 ” “$10 $11 $12 }’ | tr -s , ” “`
cur=`uptime | awk ‘{print $10}’ | tr -d , | cut -d. -f1`
str=”=============================”
info=”Curent $avg”
if [ $cur -ge 5 ]; then
info1=”Server load is high presently”
echo -e “$str\n$info\n$info1\n$str” | mail -s “Alert: Load Average for `hostname` on `date`” abc@yourdom.com
else
# echo -e “$str\n$info\n$str”
fi

0 comments: