Ubuntu linux google Windows nginx shell mysql 微软 php apache java wordpress 程序员 linux命令 Firefox HTML5 Python Android 开源 centos

Linux 系统负载报警Shell脚本第一版

Linux 负载报警脚本,系统负载超过一定数值,就重启PHP-cgi,并发送报警短信。

#!/bin/sh
#description:system load average
#author:coralzd powered by www.freebsdsystem.org
host=$(hostname)
channel=$(hostname | sed 's/[0-9]//g')
runday=$(date "+%Y-%m-%d")
IPhost=$(/sbin/ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')
i=10
while [ 1 ];do
rundaytime=$(date "+%Y-%m-%d %H:%M:%S")
L=$(cat /proc/loadavg|cut -c1-4)
RESULT=$(echo "$L > $i"|bc)
if [ "${RESULT}" == "$i" ]; then
echo "$runday" >> /var/tmp/${host}.txt
wget http: -O /dev/null >/dev/null 2>&1 //10.10.10.10/phpsms/smsu.php?phone=15012345678&msg=warning%20${IPhost}%20Load%20avarage%20is%20high
/usr/local/php52/sbin/php-fpm restart
echo "${runday}" >> /var/log/${host}.txt
echo "The system load average is 10+ ,php-fpm already restart" >> /var/log/${host}.txt
fi
sleep 600
done

转自:http://coralzd.blog.51cto.com/90341/667145

延伸阅读

评论