| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# REDUNDANCY EVENT HANDLER SCRIPT |
| 4 |
# Written By: Ethan Galstad ([email protected]) |
| 5 |
# Last Modified: 02-19-2004 |
| 6 |
# |
| 7 |
# This is an example script for implementing redundancy. |
| 8 |
# Read the HTML documentation on redundant monitoring for more |
| 9 |
# information on what this does. |
| 10 |
|
| 11 |
# Location of the echo and mail commands |
| 12 |
echocmd="/bin/echo" |
| 13 |
mailcmd="/bin/mail" |
| 14 |
|
| 15 |
# Location of the event handlers |
| 16 |
eventhandlerdir="/usr/local/nagios/libexec/eventhandlers" |
| 17 |
|
| 18 |
|
| 19 |
# Only take action on hard host states... |
| 20 |
case "$2" in |
| 21 |
HARD) |
| 22 |
|
| 23 |
case "$1" in |
| 24 |
DOWN) |
| 25 |
# The master host has gone down! |
| 26 |
# We should now become the master host and take |
| 27 |
# over the responsibilities of monitoring the |
| 28 |
# network, so enable notifications... |
| 29 |
|
| 30 |
`$eventhandlerdir/enable_notifications` |
| 31 |
|
| 32 |
|
| 33 |
# Notify someone of what has happened with the original |
| 34 |
# master server and our taking over the monitoring |
| 35 |
# responsibilities. No one was notified of the master |
| 36 |
# host going down, since the notification would have |
| 37 |
# occurred while we were in standby mode, so this is a good idea... |
| 38 |
|
| 39 |
#`$echocmd "Master Nagios host is down!" | /bin/mail -s "Master Nagios Host Is Down" root@localhost` |
| 40 |
#`$echocmd "Slave Nagios host has entered ACTIVE mode and taken over network monitoring responsibilities!" | $mailcmd -s "Slave Nagios Host Has Entered ACTIVE Mode" root@localhost` |
| 41 |
|
| 42 |
;; |
| 43 |
|
| 44 |
UP) |
| 45 |
# The master host has recovered! |
| 46 |
# We should go back to being the slave host and |
| 47 |
# let the master host do the monitoring, so |
| 48 |
# disable notifications... |
| 49 |
|
| 50 |
`$eventhandlerdir/disable_notifications` |
| 51 |
|
| 52 |
|
| 53 |
# Notify someone of what has happened. Users were |
| 54 |
# already notified of the master host recovery because we |
| 55 |
# were in active mode at the time the recovery happened. |
| 56 |
# However, we should let someone know that we're switching |
| 57 |
# back to standby mode... |
| 58 |
|
| 59 |
#`$echocmd "The master Nagios host has recovered, so the slave Nagios host has returned to standby mode..." | $mailcmd -s "Slave Nagios Host Has Returned To STANDBY Mode" root@localhost` |
| 60 |
|
| 61 |
;; |
| 62 |
|
| 63 |
esac |
| 64 |
;; |
| 65 |
|
| 66 |
esac |
| 67 |
exit 0 |
| 68 |
|