コード例 #1
0
ファイル: broker.c プロジェクト: a3linux/nagios-amq-perf
/* brokers aggregated status dumps */
void broker_aggregated_status_data(int type, int flags, int attr, struct timeval *timestamp) {
	nebstruct_aggregated_status_data ds;

	if(!(event_broker_options & BROKER_STATUS_DATA))
		return;

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	ds.timestamp = get_broker_timestamp(timestamp);

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_AGGREGATED_STATUS_DATA, (void *)&ds);

	return;
	}
コード例 #2
0
ファイル: broker.c プロジェクト: atj/nagios
/* brokers retention data */
void broker_retention_data(int type, int flags, int attr, struct timeval *timestamp) {
	nebstruct_retention_data ds;

	if(!(event_broker_options & BROKER_RETENTION_DATA))
		return;

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	ds.timestamp = get_broker_timestamp(timestamp);

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_RETENTION_DATA, (void *)&ds);

	return;
	}
コード例 #3
0
ファイル: broker.c プロジェクト: a3linux/nagios-amq-perf
/* sends program data (starts, restarts, stops, etc.) to broker */
void broker_program_state(int type, int flags, int attr, struct timeval *timestamp) {
	nebstruct_process_data ds;

	if(!(event_broker_options & BROKER_PROGRAM_STATE))
		return;

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	ds.timestamp = get_broker_timestamp(timestamp);

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_PROCESS_DATA, (void *)&ds);

	return;
	}
コード例 #4
0
ファイル: broker.c プロジェクト: a3linux/nagios-amq-perf
/* send contact notification data to broker */
int broker_contact_notification_data(int type, int flags, int attr, int notification_type, int reason_type, struct timeval start_time, struct timeval end_time, void *data, contact *cntct, char *ack_author, char *ack_data, int escalated, struct timeval *timestamp) {
	nebstruct_contact_notification_data ds;
	host *temp_host = NULL;
	service *temp_service = NULL;
	int return_code = OK;

	if(!(event_broker_options & BROKER_NOTIFICATIONS))
		return return_code;

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	ds.timestamp = get_broker_timestamp(timestamp);

	ds.notification_type = notification_type;
	ds.start_time = start_time;
	ds.end_time = end_time;
	ds.reason_type = reason_type;
	ds.contact_name = cntct->name;
	if(notification_type == SERVICE_NOTIFICATION) {
		temp_service = (service *)data;
		ds.host_name = temp_service->host_name;
		ds.service_description = temp_service->description;
		ds.state = temp_service->current_state;
		ds.output = temp_service->plugin_output;
		}
	else {
		temp_host = (host *)data;
		ds.host_name = temp_host->name;
		ds.service_description = NULL;
		ds.state = temp_host->current_state;
		ds.output = temp_host->plugin_output;
		}
	ds.object_ptr = data;
	ds.contact_ptr = (void *)cntct;
	ds.ack_author = ack_author;
	ds.ack_data = ack_data;
	ds.escalated = escalated;

	/* make callbacks */
	return_code = neb_make_callbacks(NEBCALLBACK_CONTACT_NOTIFICATION_DATA, (void *)&ds);

	return return_code;
	}
コード例 #5
0
ファイル: broker.c プロジェクト: Elbandi/nagios3
/* sends contact status updates to broker */
void broker_contact_status(int type, int flags, int attr, contact *cntct, struct timeval *timestamp){
	nebstruct_service_status_data ds;

	if(!(event_broker_options & BROKER_STATUS_DATA))
		return;

	/* fill struct with relevant data */
	ds.type=type;
	ds.flags=flags;
	ds.attr=attr;
	ds.timestamp=get_broker_timestamp(timestamp);

	ds.object_ptr=(void *)cntct;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_CONTACT_STATUS_DATA,(void *)&ds);

	return;
        }
コード例 #6
0
ファイル: broker.c プロジェクト: ipstatic/naemon-core
/* sends service status updates to broker */
void broker_service_status(int type, int flags, int attr, service *svc)
{
	nebstruct_service_status_data ds;

	if (!(event_broker_options & BROKER_STATUS_DATA))
		return;

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	get_broker_timestamp(&ds.timestamp);

	ds.object_ptr = (void *)svc;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_SERVICE_STATUS_DATA, (void *)&ds);

	return;
}
コード例 #7
0
ファイル: broker.c プロジェクト: Elbandi/nagios3
/* send log data to broker */
void broker_log_data(int type, int flags, int attr, char *data, unsigned long data_type, time_t entry_time, struct timeval *timestamp){
	nebstruct_log_data ds;

	if(!(event_broker_options & BROKER_LOGGED_DATA))
		return;

	/* fill struct with relevant data */
	ds.type=type;
	ds.flags=flags;
	ds.attr=attr;
	ds.timestamp=get_broker_timestamp(timestamp);

	ds.entry_time=entry_time;
	ds.data_type=data_type;
	ds.data=data;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_LOG_DATA,(void *)&ds);

	return;
        }
コード例 #8
0
ファイル: broker.c プロジェクト: Elbandi/nagios3
/* send flapping data to broker */
void broker_flapping_data(int type, int flags, int attr, int flapping_type, void *data, double percent_change, double high_threshold, double low_threshold, struct timeval *timestamp){
	nebstruct_flapping_data ds;
	host *temp_host=NULL;
	service *temp_service=NULL;

	if(!(event_broker_options & BROKER_FLAPPING_DATA))
		return;

	if(data==NULL)
		return;

	/* fill struct with relevant data */
	ds.type=type;
	ds.flags=flags;
	ds.attr=attr;
	ds.timestamp=get_broker_timestamp(timestamp);

	ds.flapping_type=flapping_type;
	if(flapping_type==SERVICE_FLAPPING){
		temp_service=(service *)data;
		ds.host_name=temp_service->host_name;
		ds.service_description=temp_service->description;
		ds.comment_id=temp_service->flapping_comment_id;
	        }
	else{
		temp_host=(host *)data;
		ds.host_name=temp_host->name;
		ds.service_description=NULL;
		ds.comment_id=temp_host->flapping_comment_id;
	        }
	ds.object_ptr=data;
	ds.percent_change=percent_change;
	ds.high_threshold=high_threshold;
	ds.low_threshold=low_threshold;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_FLAPPING_DATA,(void *)&ds);

	return;
        }
コード例 #9
0
ファイル: broker.c プロジェクト: Harbie34/nagioscore
/* send state change data to broker */
void broker_statechange_data(int type, int flags, int attr, int statechange_type, void *data, int state, int state_type, int current_attempt, int max_attempts, struct timeval *timestamp) {
	nebstruct_statechange_data ds;
	host *temp_host = NULL;
	service *temp_service = NULL;

	if(!(event_broker_options & BROKER_STATECHANGE_DATA))
		return;

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	ds.timestamp = get_broker_timestamp(timestamp);

	ds.statechange_type = statechange_type;
	if(statechange_type == SERVICE_STATECHANGE) {
		temp_service = (service *)data;
		ds.host_name = temp_service->host_name;
		ds.service_description = temp_service->description;
		ds.output = temp_service->plugin_output;
		ds.longoutput = temp_service->long_plugin_output;
		}
	else {
		temp_host = (host *)data;
		ds.host_name = temp_host->name;
		ds.service_description = NULL;
		ds.output = temp_host->plugin_output;
		ds.longoutput = temp_host->long_plugin_output;
		}
	ds.object_ptr = data;
	ds.state = state;
	ds.state_type = state_type;
	ds.current_attempt = current_attempt;
	ds.max_attempts = max_attempts;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_STATE_CHANGE_DATA, (void *)&ds);

	return;
	}
コード例 #10
0
ファイル: broker.c プロジェクト: ipstatic/naemon-core
/* send notification data to broker */
neb_cb_resultset * broker_notification_data(int type, int flags, int attr, int notification_type, int reason_type, struct timeval start_time, struct timeval end_time, void *data, char *ack_author, char *ack_data, int escalated, int contacts_notified)
{
	nebstruct_notification_data ds;
	host *temp_host = NULL;
	service *temp_service = NULL;

	if (!(event_broker_options & BROKER_NOTIFICATIONS))
		return NULL;

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	get_broker_timestamp(&ds.timestamp);

	ds.notification_type = notification_type;
	ds.start_time = start_time;
	ds.end_time = end_time;
	ds.reason_type = reason_type;
	if (notification_type == SERVICE_NOTIFICATION) {
		temp_service = (service *)data;
		ds.host_name = temp_service->host_name;
		ds.service_description = temp_service->description;
		ds.state = temp_service->current_state;
		ds.output = temp_service->plugin_output;
	} else {
		temp_host = (host *)data;
		ds.host_name = temp_host->name;
		ds.service_description = NULL;
		ds.state = temp_host->current_state;
		ds.output = temp_host->plugin_output;
	}
	ds.object_ptr = data;
	ds.ack_author = ack_author;
	ds.ack_data = ack_data;
	ds.escalated = escalated;
	ds.contacts_notified = contacts_notified;

	return neb_make_callbacks_full(NEBCALLBACK_NOTIFICATION_DATA, (void *)&ds);
}
コード例 #11
0
ファイル: broker.c プロジェクト: Elbandi/nagios3
/* send acknowledgement data to broker */
void broker_acknowledgement_data(int type, int flags, int attr, int acknowledgement_type, void *data, char *ack_author, char *ack_data, int subtype, int notify_contacts, int persistent_comment, struct timeval *timestamp){
	nebstruct_acknowledgement_data ds;
	host *temp_host=NULL;
	service *temp_service=NULL;

	if(!(event_broker_options & BROKER_ACKNOWLEDGEMENT_DATA))
		return;
	
	/* fill struct with relevant data */
	ds.type=type;
	ds.flags=flags;
	ds.attr=attr;
	ds.timestamp=get_broker_timestamp(timestamp);

	ds.acknowledgement_type=acknowledgement_type;
	if(acknowledgement_type==SERVICE_ACKNOWLEDGEMENT){
		temp_service=(service *)data;
		ds.host_name=temp_service->host_name;
		ds.service_description=temp_service->description;
		ds.state=temp_service->current_state;
	        }
	else{
		temp_host=(host *)data;
		ds.host_name=temp_host->name;
		ds.service_description=NULL;
		ds.state=temp_host->current_state;
	        }
	ds.object_ptr=data;
	ds.author_name=ack_author;
	ds.comment_data=ack_data;
	ds.is_sticky=(subtype==ACKNOWLEDGEMENT_STICKY)?TRUE:FALSE;
	ds.notify_contacts=notify_contacts;
	ds.persistent_comment=persistent_comment;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_ACKNOWLEDGEMENT_DATA,(void *)&ds);

	return;
        }
コード例 #12
0
ファイル: broker.c プロジェクト: Elbandi/nagios3
/* sends external commands to broker */
void broker_external_command(int type, int flags, int attr, int command_type, time_t entry_time, char *command_string, char *command_args, struct timeval *timestamp){
	nebstruct_external_command_data ds;

	if(!(event_broker_options & BROKER_EXTERNALCOMMAND_DATA))
		return;

	/* fill struct with relevant data */
	ds.type=type;
	ds.flags=flags;
	ds.attr=attr;
	ds.timestamp=get_broker_timestamp(timestamp);

	ds.command_type=command_type;
	ds.entry_time=entry_time;
	ds.command_string=command_string;
	ds.command_args=command_args;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_EXTERNAL_COMMAND_DATA,(void *)&ds);

	return;
        }
コード例 #13
0
ファイル: broker.c プロジェクト: Elbandi/nagios3
/* sends adaptive service updates to broker */
void broker_adaptive_service_data(int type, int flags, int attr, service *svc, int command_type, unsigned long modattr, unsigned long modattrs, struct timeval *timestamp){
	nebstruct_adaptive_service_data ds;

	if(!(event_broker_options & BROKER_ADAPTIVE_DATA))
		return;

	/* fill struct with relevant data */
	ds.type=type;
	ds.flags=flags;
	ds.attr=attr;
	ds.timestamp=get_broker_timestamp(timestamp);

	ds.command_type=command_type;
	ds.modified_attribute=modattr;
	ds.modified_attributes=modattrs;
	ds.object_ptr=(void *)svc;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_ADAPTIVE_SERVICE_DATA,(void *)&ds);

	return;
        }
コード例 #14
0
ファイル: broker.c プロジェクト: calestyo/icinga
/* sends program status updates to broker */
void broker_program_status(int type, int flags, int attr, struct timeval *timestamp) {
	nebstruct_program_status_data ds;

	if (!(event_broker_options & BROKER_STATUS_DATA))
		return;

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	ds.timestamp = get_broker_timestamp(timestamp);

	ds.program_start = program_start;
	ds.pid = nagios_pid;
	ds.daemon_mode = daemon_mode;
	ds.last_command_check = last_command_check;
	ds.last_log_rotation = last_log_rotation;
	ds.notifications_enabled = enable_notifications;
	ds.disable_notifications_expire_time = disable_notifications_expire_time;
	ds.active_service_checks_enabled = execute_service_checks;
	ds.passive_service_checks_enabled = accept_passive_service_checks;
	ds.active_host_checks_enabled = execute_host_checks;
	ds.passive_host_checks_enabled = accept_passive_host_checks;
	ds.event_handlers_enabled = enable_event_handlers;
	ds.flap_detection_enabled = enable_flap_detection;
	ds.failure_prediction_enabled = enable_failure_prediction;
	ds.process_performance_data = process_performance_data;
	ds.obsess_over_hosts = obsess_over_hosts;
	ds.obsess_over_services = obsess_over_services;
	ds.modified_host_attributes = modified_host_process_attributes;
	ds.modified_service_attributes = modified_service_process_attributes;
	ds.global_host_event_handler = global_host_event_handler;
	ds.global_service_event_handler = global_service_event_handler;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_PROGRAM_STATUS_DATA, (void *)&ds);

	return;
}
コード例 #15
0
ファイル: broker.c プロジェクト: ipstatic/naemon-core
/* sends adaptive host updates to broker */
void broker_adaptive_host_data(int type, int flags, int attr, host *hst, int command_type, unsigned long modattr, unsigned long modattrs)
{
	nebstruct_adaptive_host_data ds;

	if (!(event_broker_options & BROKER_ADAPTIVE_DATA))
		return;

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	get_broker_timestamp(&ds.timestamp);

	ds.command_type = command_type;
	ds.modified_attribute = modattr;
	ds.modified_attributes = modattrs;
	ds.object_ptr = (void *)hst;

	/* make callbacks */
	neb_make_callbacks(NEBCALLBACK_ADAPTIVE_HOST_DATA, (void *)&ds);

	return;
}
コード例 #16
0
ファイル: broker.c プロジェクト: a3linux/nagios-amq-perf
/* send event handler data to broker */
int broker_event_handler(int type, int flags, int attr, int eventhandler_type, void *data, int state, int state_type, struct timeval start_time, struct timeval end_time, double exectime, int timeout, int early_timeout, int retcode, char *cmd, char *cmdline, char *output, struct timeval *timestamp) {
	service *temp_service = NULL;
	host *temp_host = NULL;
	char *command_buf = NULL;
	char *command_name = NULL;
	char *command_args = NULL;
	nebstruct_event_handler_data ds;
	int return_code = OK;

	if(!(event_broker_options & BROKER_EVENT_HANDLERS))
		return return_code;

	if(data == NULL)
		return ERROR;

	/* get command name/args */
	if(cmd != NULL) {
		command_buf = (char *)strdup(cmd);
		command_name = strtok(command_buf, "!");
		command_args = strtok(NULL, "\x0");
		}

	/* fill struct with relevant data */
	ds.type = type;
	ds.flags = flags;
	ds.attr = attr;
	ds.timestamp = get_broker_timestamp(timestamp);

	ds.eventhandler_type = eventhandler_type;
	if(eventhandler_type == SERVICE_EVENTHANDLER || eventhandler_type == GLOBAL_SERVICE_EVENTHANDLER) {
		temp_service = (service *)data;
		ds.host_name = temp_service->host_name;
		ds.service_description = temp_service->description;
		}
	else {
		temp_host = (host *)data;
		ds.host_name = temp_host->name;
		ds.service_description = NULL;
		}
	ds.object_ptr = data;
	ds.state = state;
	ds.state_type = state_type;
	ds.start_time = start_time;
	ds.end_time = end_time;
	ds.timeout = timeout;
	ds.command_name = command_name;
	ds.command_args = command_args;
	ds.command_line = cmdline;
	ds.early_timeout = early_timeout;
	ds.execution_time = exectime;
	ds.return_code = retcode;
	ds.output = output;

	/* make callbacks */
	return_code = neb_make_callbacks(NEBCALLBACK_EVENT_HANDLER_DATA, (void *)&ds);

	/* free memory */
	my_free(command_buf);

	return return_code;
	}