I’m setting up a failover nagios solution with two servers, one master and one as a slave. The master currently carries out all the monitoring and sends passive check results to the slave. However, I need it to send acknowledgments/comments as well and can’t see a way of doing that off hand.
Has anyone else got this setup before I start to reinvent the wheel with some script?
Ok, first a disclaimer: This is probably not the right way to solve this problem, but a quick-and-dirty method I came up with is using the following script. It is pretty “brute force”. You will need to set up an ssh-key so that your master server can access the slave without a password, then run the script in a cron every so often on the master.
now=`date +%s`
slave="slavehostname"
cmd_file="/usr/local/nagios/var/rw/nagios.cmd"
ssh $slave "service nagios stop 2>&1 >/dev/null"
cd /usr/local/nagios/var
cp retention.dat slave.dat
sed -i 's/enable_notifications=1/enable_notifications=0/' slave.dat
sed -i 's/enable_event_handlers=1/enable_event_handlers=0/' slave.dat
sed -i 's/obsess_over_services=1/obsess_over_services=0/' slave.dat
sed -i 's/obsess_over_hosts=1/obsess_over_hosts=0/' slave.dat
scp slave.dat $slave:/usr/local/nagios/var/retention.dat
scp comments.dat $slave:/usr/local/nagios/var/comments.dat
rm -f slave.dat
ssh $slave "service nagios start 2>&1 >/dev/null"
Obviously, the right way to do it would be to replicate the acks individually from the master, but that is a little more complex. For now, this works for me and I don’t see any ill effects from copying over the dat files. YMMV.