- 论坛徽章:
- 0
|
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 #负载为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://172.19.2.61/phpsms/smsu.php?phone=15012345678\&msg=warning%20${IPhost}%20Load%20avarage%20is%20high -O /dev/null >/dev/null 2>&1
- /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
复制代码 |
评分
-
查看全部评分
|