linux 负载报警脚本,系统负载超过一定数值,就重启php-cgi,并发送报警短信。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#!/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 |
发表评论
要发表评论,您必须先登录。