示例#1
0
/* 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;
}
示例#2
0
/* 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;
}