Long ago a guy gave me the following but I never got to try it.  I would love to hear what actually works.  Maybe a howto

 

Configuration doc on slave server...

 

 

 

Failover Configuration:

Master Server (10.1.1.3):

Configure NSCA:

            Install Libmcrypt:

                        tar -xzvf libmcrypt-2.5.7.tar.gz

                        cd libmcrypt-2.5.7

                        ./configure

                        make

                        make install

            Update system to find the library:

                        vi /etc/ld.so.conf

                        add the following line:

                                    /usr/local/lib/

                        run ldconfig:

                                    /sbin/ldconfig

                       

 

tar -xzvf nsca-2.4.tar.gz

cd nsca-2.4

./configure --prefix=/usr/local/nagios --with-nsca-user=nagios --with-nsca-grp=nagios

            output should be the following:

General Options:

-------------------------

                        NSCA port:  5667

                        NSCA user:  nagios

                        NSCA group: nagios

make all           

cp src/nsca /usr/local/nagios/bin/

cp nsca.cfg /usr/local/nagios/etc/

vi /usr/local/nagios/etc/nsca.cfg

            modify the following:

                        allowed_hosts=10.1.1.3

                        password=password

                        decryption_method=2

 

start the service

            /usr/local/nagios/bin/nsca -c /usr/local/nagios/etc/nsca.cfg

 

Slave Server (10.1.1.4):

Disable the following in nagios.cfg:

            retain_state_information=0

            execute_service_checks=0

            enable_notifications=0

 

Enable the the following in nagios.cfg:

            check_external_commands=1

            retention_update_interval=30

use_retained_program_state=0

 

Create enable/disable service checks script:

vi /usr/local/nagios/libexec/eventhandlers/disable_active_service_checks

#!/bin/sh

 

echocmd="/bin/echo"

 

CommandFile="/usr/local/nagios/var/rw/nagios.cmd"

 

# get the current date/time in seconds since UNIX epoch

datetime=`date +%s`

 

# create the command line to add to the command file

cmdline="[$datetime] STOP_EXECUTING_SVC_CHECKS"

 

# append the command to the end of the command file

`$echocmd $cmdline >> $CommandFile`

write the file

chown nagios:nagios /usr/local/nagios/libexec/eventhandlers/disable_active_service_checks

 

vi /usr/local/nagios/libexec/eventhandlers/enable_active_service_checks

#!/bin/sh

 

echocmd="/bin/echo"

 

CommandFile="/usr/local/nagios/var/rw/nagios.cmd"

 

# get the current date/time in seconds since UNIX epoch

datetime=`date +%s`

 

# create the command line to add to the command file

cmdline="[$datetime] START_EXECUTING_SVC_CHECKS"

 

# append the command to the end of the command file

`$echocmd $cmdline >> $CommandFile`

write the file

chown nagios:nagios /usr/local/nagios/libexec/eventhandlers/enable_active_service_checks

 

Create enable/disable notifications scripts:

vi /usr/local/nagios/libexec/eventhandlers/enable_notifications

#!/bin/sh

 

echocmd="/bin/echo"

 

CommandFile="/usr/local/nagios/var/rw/nagios.cmd"

 

# get the current date/time in seconds since UNIX epoch

datetime=`date +%s`

 

# create the command line to add to the command file

cmdline="[$datetime] ENABLE_NOTIFICATIONS;$datetime"

 

# append the command to the end of the command file

`$echocmd $cmdline >> $CommandFile`

write the file

chown nagios:nagios /usr/local/nagios/libexec/eventhandlers/enable_notifications

 

vi /usr/local/nagios/libexec/eventhandlers/disable_notifications

#!/bin/sh

 

echocmd="/bin/echo"

 

CommandFile="/usr/local/nagios/var/rw/nagios.cmd"

 

# get the current date/time in seconds since UNIX epoch

datetime=`date +%s`

 

# create the command line to add to the command file

cmdline="[$datetime] DISABLE_NOTIFICATIONS;$datetime"

 

# append the command to the end of the command file

`$echocmd $cmdline >> $CommandFile`

write the file

chown nagios:nagios /usr/local/nagios/libexec/eventhandlers/disable_notifications

 

Create monitoring enable script:

vi /usr/local/nagios/libexec/eventhandlers/check_master_host_enable

#!/bin/sh

 

RES=`/usr/local/nagios/libexec/check_nrpe -H 10.1.1.3 -c check_nagios_proc`

        STATUS=$?

        if [ $STATUS != 0 ]; then

           sleep 35

RES=`/usr/local/nagios/libexec/check_nrpe -H 10.1.1.3 -c check_nagios_proc`

        STATUS=$?

        if [ $STATUS != 0 ]; then

           echo "Activate Sentinel Local : RES=$RES ; Status=$STATUS"

 

/usr/local/nagios/libexec/eventhandlers/enable_active_service_checks

        sleep 5

/usr/local/nagios/libexec/eventhandlers/enable_notifications

 

   fi

fi

exit

 

write the file

 

Setup a cron job to call the above script every 1 min

 

vi /usr/local/nagios/libexec/eventhandlers/check_master_host_disable

#!/bin/sh

 

RES=`/usr/local/nagios/libexec/check_nrpe -H 10.1.1.3 -c check_nagios_proc`

        STATUS=$?

        if [ $STATUS != 1 ]; then

           sleep 35

RES=`/usr/local/nagios/libexec/check_nrpe -H 10.1.1.3 -c check_nagios_proc`

        STATUS=$?

        if [ $STATUS != 1 ]; then

     

           echo "De-activate Sentinel Local : RES=$RES ; Status=$STATUS"

 

/usr/local/nagios/libexec/eventhandlers/disable_active_service_checks

        sleep 5

/usr/local/nagios/libexec/eventhandlers/disable_notifications

 

   fi

fi

exit

 

write the file

make the files executable:

chmod 755 /usr/local/nagios/libexec/eventhandlers/*

Setup a cron job to call the above script every 1 minute.

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lehman, John
Sent: Wednesday, October 25, 2006 15:39
To: Nagios Users mailinglist
Subject: *****SPAM***** [Nagios-users] failover

 

Question for everyone.

 

I have 2 nagios servers and one is active all the time and the other is standby.

 

I have read the documentation on implementing failover but I am finding it difficult implementing.

 

Is there anyone that could give me sample scripts which “on the standby host” would “check the nagios master” and if the nagios master were down then the standby would become the active host?

 

 

I am losing my mind trying to implement from the documentation and I would appreciate any advice on this one.

 

John

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Reply via email to