nagios監控 ogg同步狀態

czxin788發表於2017-04-29

nagios監控 ogg同步狀態
最近我用ogg搭建了sqlserver to mysql的生產環境,但是為了及時瞭解ogg的同步狀態,我用nagios進行了監控。具體指令碼如下。


在源端,如果源資料庫是sqlserver:
cat C:\NSClient++\scripts\check_run.bat
@echo off
tasklist |find "%1" >NUL
IF ERRORLEVEL 1 GOTO err
IF ERRORLEVEL 0 GOTO ok

:err
echo CRITICAL: %1 process does not exist
exit /B 1

:ok
echo OK:%1 process of normal
exit /B 0


C:\NSClient++\NSC.ini檔案裡面:
[External Scripts]標籤下,新增一行:
check_ogg_mgr=scripts\check_run.bat  mgr
check_ogg_ext=scripts\check_run.bat  extract

在nagios server上,
define service{
        use                     hr,srv-pnp
        host_name               kaoqin-24.4
        service_description     ogg-mgr_status
        check_command           check_nrpe!check_ogg_mgr
        }
 
define service{
        use                     hr,srv-pnp
        host_name               kaoqin-24.4
        service_description     ogg-ext_status
        check_command           check_nrpe!check_ogg_ext
        }






在目標端,我的目標端是MySQL:
[root@Manger ~]# crontab -l
#給nagios用的,定時檢查ogg的狀態
*/5 * * * * /usr/local/nagios/libexec/ogg.sh > /tmp/check_ogg.txt

[root@Manger ~]# cat /usr/local/nagios/libexec/ogg.sh
#!/bin/bash
/usr/local/ogg/ggsci << eof
info all
eof

[root@Manger ~]# cat /usr/local/nagios/etc/nrpe.cfg
command[check_ogg_status]=/usr/local/nagios/libexec/ogg_status.sh


[root@Manger ~]# cat /usr/local/nagios/libexec/ogg_status.sh
#!/bin/bash
ogg_status=`cat /tmp/check_ogg.txt  |grep -E 'REPLICAT|MANAGER' |grep -c RUNNING`
if [ $ogg_status -eq 2 ];then
 echo "ogg_status: OK:  |USED=$ogg_status;1;1;;"
 $(exit 0)
else
echo "ogg_status: CRITICAL:  |USED=$ogg_status;0;0;;"
    $(exit 2)
fi

在nagios server上:
define service{
        use                          mysql,srv-pnp
        host_name                    mysql02-2.111
        service_description          check_ogg_status
        check_command                check_nrpe!check_ogg_status
        }

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28916011/viewspace-2138205/,如需轉載,請註明出處,否則將追究法律責任。

相關文章