Page 1 of 1

[Nagios-devel] Event handlers functionality reapplied to Nagios 4

Posted: Mon Feb 25, 2013 3:52 pm
by Guest
--Apple-Mail-7--900472350
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="us-ascii"

Andreas,

We've noticed that the event handlers do not currently work in Nagios 4 =
trunk. It seems that there is a FIXME message where the worker part was =
not implemented.

We've now implemented this, so I think this is now working as expected.

Please find the patch below, nagios_4_support_event_handlers.patch. This =
applies on top of the envvar support we added for Nagios 4 (subject "Fix =
default value for enable_environment_macros") which is reattached as =
nagios_macro_environents_in_command_definition.patch.

Are there any other things that are not implemented yet that you would =
like some assistance with?

Ton



--Apple-Mail-7--900472350
Content-Disposition: attachment;
filename="nagios_4_support_event_handlers.patch"
Content-Type: application/octet-stream;
name="nagios_4_support_event_handlers.patch"
Content-Transfer-Encoding: 7bit

diff -ur nagios-4.0.20130107.original/base/sehandlers.c nagios-4.0.20130107/base/sehandlers.c
--- nagios-4.0.20130107.original/base/sehandlers.c 2013-02-20 08:43:04.000000000 +0000
+++ nagios-4.0.20130107/base/sehandlers.c 2013-02-20 09:01:44.000000000 +0000
@@ -301,8 +301,7 @@
add_command_environment_to_kvv(&kvv, global_service_event_handler_ptr, mac);

/* run the command through a worker */
- /* XXX FIXME make base/workers.c handle the eventbroker stuff below */
- result = wproc_run(WPJOB_GLOBAL_SVC_EVTHANDLER, processed_command, event_handler_timeout, &kvv);
+ result = wproc_run_event_handler(WPJOB_GLOBAL_SVC_EVTHANDLER, event_handler_timeout, svc->host_name, svc->description, processed_command, &kvv);

/* check to see if the event handler timed out */
if(early_timeout == TRUE)
@@ -408,8 +407,7 @@
add_command_environment_to_kvv(&kvv, svc->event_handler_ptr, mac);

/* run the command through a worker */
- /* XXX FIXME make base/workers.c handle the eventbroker stuff below */
- result = wproc_run(WPJOB_SVC_EVTHANDLER, processed_command, event_handler_timeout, &kvv);
+ result = wproc_run_event_handler(WPJOB_SVC_EVTHANDLER, event_handler_timeout, svc->host_name, svc->description, processed_command, &kvv);

/* check to see if the event handler timed out */
if(early_timeout == TRUE)
@@ -559,8 +557,7 @@
add_command_environment_to_kvv(&kvv, global_host_event_handler_ptr, mac);

/* run the command through a worker */
- /* XXX FIXME make base/workers.c handle the eventbroker stuff below */
- wproc_run(WPJOB_GLOBAL_HOST_EVTHANDLER, processed_command, event_handler_timeout, &kvv);
+ wproc_run_event_handler(WPJOB_GLOBAL_HOST_EVTHANDLER, event_handler_timeout, hst->name, NULL, processed_command, &kvv);

/* check for a timeout in the execution of the event handler command */
if(early_timeout == TRUE)
@@ -664,7 +661,7 @@
add_command_environment_to_kvv(&kvv, hst->event_handler_ptr, mac);

/* run the command through a worker */
- result = wproc_run(WPJOB_HOST_EVTHANDLER, processed_command, event_handler_timeout, &kvv);
+ result = wproc_run_event_handler(WPJOB_HOST_EVTHANDLER, event_handler_timeout, hst->name, NULL, processed_command, &kvv);

/* check to see if the event handler timed out */
if(early_timeout == TRUE)
diff -ur nagios-4.0.20130107.original/base/workers.c nagios-4.0.20130107/base/workers.c
--- nagios-4.0.20130107.original/base/workers.c 2013-02-20 08:43:04.000000000 +0000
+++ nagios-4.0.20130107/base/workers.c 2013-02-20 08:51:06.000000000 +0000
@@ -966,6 +966,19 @@
return wproc_run_job(job, kvv);
}

+int wproc_run_event_handler(int jtype, int timeout, char *hname, char *sdesc, char *cmd, struct kvvec *kvv)
+{
+ worker_job *job;
+ wproc_object_job *oj;
+
+ if (!(oj = create_object_job(NULL, hname, sdesc)))
+ return ERROR;
+
+ job = create_job(jtype, oj, timeout, cmd);
+
+ return wproc_run_job(job, kvv);
+}
+
int wproc_run_service_job(int jtype, int timeout, service *svc, char *cmd, struct kvvec *kvv)
{
worker_job *job;
diff -ur nagios-4.0.20130107.original/include/workers.h nagios-4.0.20130107/include/workers.h
--- nagios-4.0.20130107.original/include/workers.h 2013

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]