linux 負載報警腳本第一版

linux 負載報警腳本,系統負載超過一定數值,就重啓php-cgi,併發送報警短信。

 

  1. #!/bin/sh  
  2. #description:system load average  
  3. #author:coralzd powered by www.freebsdsystem.org  
  4. host=$(hostname)  
  5. channel=$(hostname | sed 's/[0-9]//g')  
  6. runday=$(date "+%Y-%m-%d")  
  7. IPhost=$(/sbin/ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')  
  8. i=10  
  9.   while [ 1 ];do 
  10. rundaytime=$(date "+%Y-%m-%d %H:%M:%S")  
  11. L=$(cat /proc/loadavg|cut -c1-4)  
  12. RESULT=$(echo "$L > $i"|bc)  
  13. if [ "${RESULT}" == "$i" ]; then  
  14. echo "$runday" >> /var/tmp/${host}.txt  
  15. 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 
  16. /usr/local/php52/sbin/php-fpm restart  
  17. echo "${runday}" >> /var/log/${host}.txt  
  18. echo "The system load average is 10+ ,php-fpm already restart" >> /var/log/${host}.txt  
  19. fi  
  20. sleep 600  
  21. done 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章