grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}'
#!/bin/bash
limit=2
email_destination="whatever@gmail.com"
email_body="WARNING the CPU usage on server `hostname` exceeded the limit you set ($limit)%"
email_subject="WARNING cpu usage"
usage=`grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}' | bc`
if echo $usage $limit | awk '{exit $1>$2?0:1}'
then
echo -e $email_body | mail -s "$email_subject" $email_destination
#echo 'alarm'
fi
_____________________________________________________
Disk space not updating in linux df -h after deleted files
ls -ld /proc/*/fd/* 2>&1 | fgrep '(deleted)'
restart the process that hold it
No comments:
Post a Comment