nagios 监控shell脚本

                             线上应用shell脚本                         

参考链接:http://os.51cto.com/art/201301/376725.htm

 

  • 0--各方面都正常,检查成功完成。
  • 1--资源处于警告状态。某个地方不太妙。
  • 2--资源处于临界状态。原因可能是主机宕机或服务未运行。
  • 3--未知状态,这未必表明就有问题,而是表明检查没有给出一个清楚明确的状态。

 

nagios监控游戏注册人数:

#!/bin/bash
REG=$(cat /data/bobo_online/res2.txt | grep "^3" | cut -d , -f 2)
if [ $REG -gt 8500 ];then
        echo "Android ID:3,regist num is $REG man,Critical"
exit 2
elif [ $REG -gt 7500 ];then
        echo "Android ID:3,regist num is $REG man,Warning"
exit 1
else
        echo "Android ID:3,regist num is $REG man,OK"
exit 0
fi

 

nagios监控mysql主从状态:

#!/bin/sh
slave_is=($(mysql -S /tmp/mysql3306.sock -uroot -e "show slave status\G"|grep "Slave_.*_Running" |awk '{print $2}')) 
if [ "${slave_is[0]}" = "Yes" -a "${slave_is[1]}" = "Yes" ]
     then
     echo "OK SDK-slave3307 connect master3306 is running"
     exit 0
else
     echo "Critical SDK-slave3307 connect master3306 is not running"
     exit 2
fi 

 

nagios监控keepalived进程:

#!/bin/sh 
KPD=`ps aux | grep 'keepalived -D' |grep -v grep |wc -l` 
if [ $KPD -ne 3 ]
then 
echo "Critical!Keepalived process count is $KPD" 
exit 2 
fi 
echo "OK . Keepalived process count is $KPD" 
exit 0 

 

posted @ 2016-01-20 13:38  唐胜伟  阅读(774)  评论(0编辑  收藏  举报