/* handles a change in the status of a host */ int handle_host_event(host *hst) { nagios_macros mac; if (hst == NULL) return ERROR; broker_statechange_data(NEBTYPE_STATECHANGE_END, NEBFLAG_NONE, NEBATTR_NONE, HOST_STATECHANGE, (void *)hst, hst->current_state, hst->state_type, hst->current_attempt, hst->max_attempts); /* bail out if we shouldn't be running event handlers */ if (enable_event_handlers == FALSE) return OK; if (hst->event_handler_enabled == FALSE) return OK; /* update host macros */ memset(&mac, 0, sizeof(mac)); grab_host_macros_r(&mac, hst); /* run the global host event handler */ run_global_host_event_handler(&mac, hst); /* run the event handler command if there is one */ if (hst->event_handler != NULL) run_host_event_handler(&mac, hst); return OK; }
/* handles a change in the status of a host */ int handle_host_event(host *hst) { icinga_macros mac; log_debug_info(DEBUGL_FUNCTIONS, 0, "handle_host_event()\n"); if (hst == NULL) return ERROR; #ifdef USE_EVENT_BROKER /* send event data to broker */ broker_statechange_data(NEBTYPE_STATECHANGE_END, NEBFLAG_NONE, NEBATTR_NONE, HOST_STATECHANGE, (void *)hst, hst->current_state, hst->state_type, hst->current_attempt, hst->max_attempts, NULL); #endif /* bail out if we shouldn't be running event handlers */ if (enable_event_handlers == FALSE) return OK; if (hst->event_handler_enabled == FALSE) return OK; /* update host macros */ memset(&mac, 0, sizeof(mac)); grab_host_macros_r(&mac, hst); /* run the global host event handler */ run_global_host_event_handler(&mac, hst); /* run the event handler command if there is one */ if (hst->event_handler != NULL) run_host_event_handler(&mac, hst); /* check for external commands - the event handler may have given us some directives... */ check_for_external_commands(); return OK; }
/* handles changes in the state of a service */ int handle_service_event(service *svc) { nagios_macros mac; if (svc == NULL) return ERROR; broker_statechange_data(NEBTYPE_STATECHANGE_END, NEBFLAG_NONE, NEBATTR_NONE, SERVICE_STATECHANGE, (void *)svc, svc->current_state, svc->state_type, svc->current_attempt, svc->max_attempts); /* bail out if we shouldn't be running event handlers */ if (enable_event_handlers == FALSE) return OK; if (svc->event_handler_enabled == FALSE) return OK; /* update service macros */ memset(&mac, 0, sizeof(mac)); grab_service_macros_r(&mac, svc); /* run the global service event handler */ run_global_service_event_handler(&mac, svc); /* run the event handler command if there is one */ if (svc->event_handler != NULL) run_service_event_handler(&mac, svc); clear_volatile_macros_r(&mac); return OK; }
/* handles changes in the state of a service */ int handle_service_event(service *svc) { host *temp_host = NULL; icinga_macros mac; log_debug_info(DEBUGL_FUNCTIONS, 0, "handle_service_event()\n"); if (svc == NULL) return ERROR; #ifdef USE_EVENT_BROKER /* send event data to broker */ broker_statechange_data(NEBTYPE_STATECHANGE_END, NEBFLAG_NONE, NEBATTR_NONE, SERVICE_STATECHANGE, (void *)svc, svc->current_state, svc->state_type, svc->current_attempt, svc->max_attempts, NULL); #endif /* bail out if we shouldn't be running event handlers */ if (enable_event_handlers == FALSE) return OK; if (svc->event_handler_enabled == FALSE) return OK; /* find the host */ if ((temp_host = (host *)svc->host_ptr) == NULL) return ERROR; /* update service macros */ memset(&mac, 0, sizeof(mac)); grab_host_macros_r(&mac, temp_host); grab_service_macros_r(&mac, svc); /* run the global service event handler */ run_global_service_event_handler(&mac, svc); /* run the event handler command if there is one */ if (svc->event_handler != NULL) run_service_event_handler(&mac, svc); clear_volatile_macros_r(&mac); /* check for external commands - the event handler may have given us some directives... */ check_for_external_commands(); return OK; }