AW: Event Handlers

Thomas.Zimmer at oppenheim.de Thomas.Zimmer at oppenheim.de
Wed Dec 8 10:02:20 CET 2004


hi nathan.
the whole script (htp-restart) is placed in the documentation. just copy
into the eventhandler-dir.
as eventhandlers you may use any shell-scripts, perl-scripts or compiled
programs.
i wrote some scripts to e.g. restart my nrpe-clients via ssh, or to switch
my redundant monitoring environment. the redundant environment is based of a
main Nagiosserver which is executing the service-checks, a redundancy-server
controls the work of the main server and vice versa. the Nagiosservers are
running on productive Backupservers. in the case of getting a productive
machine i have to switch my whole Nagios-environment to other servers.
therefore the attached script copies the nagios-configuration to the
"Nagios-backup-server", starts the Nagios-backup and the new
redundancy-server, and shuts down the Main Nagiosserver.
i attached the "switch-script" to this mail. it shows how to handle with
Nagios -$macros$ and uses the Nagios-commandfile ("nagios.cmd").
i hope this helps.
greetz,
thomas.
 <<switch_server.sh>>  <<server.config>> 
surely they´re not perfect, but they work :-)
i should post the service/command defs too:


# the eventhandler, defined in "misccommands.cfg" (maybe placed as any
configurations in any configuration file)
# $USER2$ has to be replaced by your Path-variable to your
eventhandler-scripts
define command {
		command_name                   switch_server
		command_line                   $USER2$/switch_server.sh
$SERVICEDESC$ $SERVICESTATE$ $STATETYPE$ $SERVICEATTEMPT$ `uname -n` 
		}

# a "control service-check" to determine the case the main-nagiosserver gets
a production-machine
define service {
		host_name                      ...
		service_description            SERVER_SWITCH
		check_command                  check_nrpe!check_procs!-w 0:0
-c 0:0 -C ...-a ...
		register                       1
		max_check_attempts             2
		normal_check_interval          1
		retry_check_interval           1
		active_checks_enabled          1
		check_period                   24x7
		passive_checks_enabled         1
		parallelize_check              1
		event_handler                  switch_server
		event_handler_enabled          1
		flap_detection_enabled         1
		retain_status_information      1
		retain_nonstatus_information   1
		notification_interval          0
		notification_period            24x7
		notifications_enabled          1
		contact_groups                 nagios
		}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20041208/524dcdc5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: switch_server.sh
Type: application/octet-stream
Size: 6468 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20041208/524dcdc5/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: server.config
Type: application/octet-stream
Size: 585 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20041208/524dcdc5/attachment-0001.obj>


More information about the Users mailing list