fdfdfwe 发表于 2015-5-8 09:10:02

nagios监控redis端口、监控url接口告警脚本

监控redis端口如下:
#!/bin/sh
#Created by hys 20140823
declare -a master_is
master_is=($(redis-cli -h 192.168.0.76 -p 7711 INFO |grep role |awk -F: '{print $2}'))
echo $master_is
if [ ${master_is} == "master" ];then
      echo "OK -slave is running"
      exit 0
else
      echo "Critical -slave is error"
      exit 2
fi

监控url地址如下:
#!/bin/sh
#Created by hys 20140823
ttl=`curl -o /dev/null -s -L --connect-timeout 60 http://192.168.0.161:8080 -w %{http_code}`
if [ "$ttl" == 200 ];
then
         echo "OK url is running"
         exit 0
else
      echo "Critical url is error"
      exit 2
fi

页: [1]
查看完整版本: nagios监控redis端口、监控url接口告警脚本