CPU utilization in linux script alert

Hi,

This below script will update you whenever the server load goes beyond 15 with the load and the top 10 process which uses maximum CPU.

#!/bin/bash
SUBJECT="`hostname`server load is high"
TO=user@host.com
uptime > /tmp/load
if [ `uptime | awk '{ print$10 }' | cut -d. -f1` -gt 15 ];
then
echo "============================================" >> /tmp/load
`ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 >> /tmp/load `
mail -s "$SUBJECT" $TO < /tmp/load
exit
fi

Thanks for viewing helpinlinux.com

2 comments

  1. Free Stuff says:

    Hi there, just became aware of your weblog thru Google, and found that it’s truly informative. I? going to be careful for brussels. I?l appreciate if you happen to proceed this in future. Numerous other folks will likely be benefited out of your writing. Cheers!

  2. Fashion Trends says:

    Hello very cool site!! Man .. Beautiful .. Amazing .. I’ll bookmark your website and take the feeds additionally?I am glad to find numerous helpful info right here in the publish, we’d like develop extra techniques in this regard, thank you for sharing. . . . . .

Leave a Reply

Protected by WP Anti Spam