<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>AW: [Nagios-users] Event Handlers</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2 FACE="Arial">hi nathan.</FONT>
<BR><FONT SIZE=2 FACE="Arial">the whole script (htp-restart) is placed in the documentation. just copy into the eventhandler-dir.</FONT>
<BR><FONT SIZE=2 FACE="Arial">as eventhandlers you may use any shell-scripts, perl-scripts or compiled programs.</FONT>
<BR><FONT SIZE=2 FACE="Arial">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.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">i attached the "switch-script" to this mail. it shows how to handle with Nagios -$macros$ and uses the Nagios-commandfile ("nagios.cmd").</FONT></P>

<P><FONT SIZE=2 FACE="Arial">i hope this helps.</FONT>
<BR><FONT SIZE=2 FACE="Arial">greetz,</FONT>
<BR><FONT SIZE=2 FACE="Arial">thomas.</FONT>
<BR><FONT FACE="Arial" SIZE=2 COLOR="#000000"> <<switch_server.sh>> </FONT><FONT FACE="Arial" SIZE=2 COLOR="#000000"> <<server.config>> </FONT>
<BR><FONT SIZE=2 FACE="Arial">surely they´re not perfect, but they work :-)</FONT>
<BR><FONT SIZE=2 FACE="Arial">i should post the service/command defs too:</FONT>
</P>
<BR>

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

<P>                <FONT SIZE=2 FACE="Arial">}</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial"># a "control service-check" to determine the case the main-nagiosserver gets a production-machine</FONT>
<BR><FONT SIZE=2 FACE="Arial">define service {</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">host_name                      ...</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">service_description            SERVER_SWITCH</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">check_command                  check_nrpe!check_procs!-w 0:0 -c 0:0 -C ...-a ...</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">register                       1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">max_check_attempts             2</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">normal_check_interval          1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">retry_check_interval           1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">active_checks_enabled          1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">check_period                   24x7</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">passive_checks_enabled         1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">parallelize_check              1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">event_handler                  switch_server</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">event_handler_enabled          1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">flap_detection_enabled         1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">retain_status_information      1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">retain_nonstatus_information   1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">notification_interval          0</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">notification_period            24x7</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">notifications_enabled          1</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">contact_groups                 nagios</FONT>
<BR>                <FONT SIZE=2 FACE="Arial">}</FONT>
</P>

</BODY>
</HTML>