nagios如何适用平台centos6.6
来自:网络#! /bin/bash
#
#
#
#监控mysql主从同步状态 nagios培训
#
#
#
STATE_OK=0 #正常
STATE_WARNING=1#警告 nagios实施
STATE_CRITICAL=2 #危险
STATE_UNKNOWN=3 #未知 监控软件
SLAVE_IO_STATUS=0
SLAVE_SQL_STATUS=0
MYSQL=$(which mysql)
SLAVE_IO=`$MYSQL -e "show slave status\G"|grep -i Slave_IO_Running |awk -F: '{print $2}'`
SLAVE_SQL=`$MYSQL -e "show slave status\G"|grep -i Slave_SQL_Running|awk -F: '{print $2}'`
IO_ERROR=`$MYSQL -e "show slave status\G"|grep -i Last_IO_Error|awk -F: '{print $2}'`
SQL_ERROR=`$MYSQL -e "show slave status\G"|grep -i Last_SQL_Error|awk -F: '{print $2}'`
#if [ "`echo ${SLAVE_IO%% .*}`" == "Yes" ];then nagios配置
# echo "slave_io is OK"
if [ "`echo ${SLAVE_IO%% .*}`" == "No" ];then
#echo "slave_io is $IO_ERROR"
SLAVE_IO_STATUS=2
fi
#if [ "`echo ${SLAVE_SQL%% .*}`" == "Yes" ];then 开源监控软件
# echo "slave_sql is OK"
if [ "`echo ${SLAVE_SQL%% .*}`" == "No" ];then
#echo "slave_sql is $SQL_ERROR"
SLAVE_SQL_STATUS=2
fi
if [ $SLAVE_IO_STATUS -ne 0 -o $SLAVE_SQL_STATUS -ne 0 ];then nagios安装
echo "error $IO_ERROR $SQL_ERROR"
exit $STATE_CRITICAL
else
echo "SLAVE STATUS OK"
exit $STATE_OK
fi
想做Nagios, Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流QQ群号 :476809427
页:
[1]