ロードアベレージを監視するスクリプト

簡易的な負荷を監視するスクリプトです。

yum install bc mailx
vim cpu-load-check.sh
---
#!/bin/sh

email={address}
Subject="domain NG CPULoad5"

if [ "$1" != "" ]; then
        email=$1
fi

load5=`uptime | grep "load average" | sed -e 's/^.*load\saverage:\s//g' | awk '{print $2}' | sed -e 's/,//g'`
bool=`echo "${load5} > 4.00" | bc `

if [ $bool -eq 1 ]; then

(
cat << EOF

CPU Load Average ${load5}

If you worried about , please check domain 

top or uptime

EOF
) | /bin/mail -s "$Subject" ${email}

fi
---