[Nagios-devel] Patch to make Nagios 3.0.1 more NEB module friendly

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Patch to make Nagios 3.0.1 more NEB module friendly

Post by Guest »

This is a multi-part message in MIME format.
--------------010903030202040609050307
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi Ethan,

I'm still patiently waiting to hear back from you regarding my patch to
the base/checks.c file (attached for your convenience). This patch makes
(only) the following 3 changes:

1. Causes Nagios to honor the NEBERROR_CALLBACKOVERRIDE return code in
the NEBTYPE_SERVICECHECK_INITIATE broker call back.

2. Moves the NEBTYPE_SERVICECHECK_INITIATE broker call back above the
opening and initialization of the check results file, so as to not have
to close and remove it in the case where the NEB module returns
NEBERROR_CALLBACKOVERRIDE.

3. Splits initialization of the *check_result_info* structure above and
below the NEB call back, so as to provide as much information as
possible to a NEB module, but without the results file being initialized.

I've made as few changes as possible in order to maintain the spirit of
your original code. These are good changes - these few changes open up a
world of possibilities for NEB modules that need to handle checks for
Nagios.

Thanks and regards,
John

--------------010903030202040609050307
Content-Type: text/plain;
name="nagios-3.0-dnx.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios-3.0-dnx.patch"

--- nagios-3.0/base/checks.c 2008-02-28 12:26:12.000000000 -0700
+++ nagios-3.0-patched/base/checks.c 2008-03-13 09:02:02.000000000 -0600
@@ -435,6 +435,32 @@
/* set the execution flag */
svc->is_executing=TRUE;

+ /* start save check info */
+ check_result_info.object_check_type=SERVICE_CHECK;
+ check_result_info.check_type=SERVICE_CHECK_ACTIVE;
+ check_result_info.check_options=check_options;
+ check_result_info.scheduled_check=scheduled_check;
+ check_result_info.reschedule_check=reschedule_check;
+ check_result_info.start_time=start_time;
+ check_result_info.finish_time=start_time;
+ check_result_info.early_timeout=FALSE;
+ check_result_info.exited_ok=TRUE;
+ check_result_info.return_code=STATE_OK;
+ check_result_info.output=NULL;
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ neb_result=broker_service_check(NEBTYPE_SERVICECHECK_INITIATE,NEBFLAG_NONE,NEBATTR_NONE,svc,SERVICE_CHECK_ACTIVE,start_time,end_time,svc->service_check_command,svc->latency,0.0,service_check_timeout,FALSE,0,processed_command,NULL);
+
+ /* neb module wants to override the service check - perhaps it will check the service itself */
+ if(neb_result==NEBERROR_CALLBACKOVERRIDE){
+ svc->latency=old_latency;
+ my_free(processed_command);
+ my_free(raw_command);
+ return OK;
+ }
+#endif
+
/* open a temp file for storing check output */
old_umask=umask(new_umask);
asprintf(&output_file,"%s/checkXXXXXX",temp_path);
@@ -450,21 +476,10 @@
log_debug_info(DEBUGL_CHECKS|DEBUGL_IPC,1,"Check result output will be written to '%s' (fd=%d)\n",output_file,check_result_info.output_file_fd);


- /* save check info */
- check_result_info.object_check_type=SERVICE_CHECK;
+ /* finish save check info */
check_result_info.host_name=(char *)strdup(svc->host_name);
check_result_info.service_description=(char *)strdup(svc->description);
- check_result_info.check_type=SERVICE_CHECK_ACTIVE;
- check_result_info.check_options=check_options;
- check_result_info.scheduled_check=scheduled_check;
- check_result_info.reschedule_check=reschedule_check;
check_result_info.output_file=(check_result_info.output_file_fdservice_check_command,svc->laten

...[email truncated]...


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