Ejemplo n.º 1
0
/* send contact notification data to broker */
int broker_contact_notification_method_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 *cmd, char *ack_author, char *ack_data, int escalated, struct timeval *timestamp) {
	nebstruct_contact_notification_method_data ds;
	host *temp_host = NULL;
	service *temp_service = NULL;
	char *command_buf = NULL;
	char *command_name = NULL;
	char *command_args = NULL;
	int return_code = OK;

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

	/* 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.notification_type = notification_type;
	ds.start_time = start_time;
	ds.end_time = end_time;
	ds.reason_type = reason_type;
	ds.contact_name = cntct->name;
	ds.command_name = command_name;
	ds.command_args = command_args;
	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_METHOD_DATA, (void *)&ds);

	/* free memory */
	my_free(command_buf);

	return return_code;
	}
Ejemplo n.º 2
0
/* send timed event data to broker */
void broker_timed_event(int type, int flags, int attr, timed_event *event, struct timeval *timestamp){
	nebstruct_timed_event_data ds;

	if(!(event_broker_options & BROKER_TIMED_EVENTS))
		return;

	if(event==NULL)
		return;

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

	ds.event_type=event->event_type;
	ds.recurring=event->recurring;
	ds.run_time=event->run_time;
	ds.event_data=event->event_data;
	ds.event_ptr=(void *)event;

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

	return;
        }
Ejemplo n.º 3
0
/* send comment data to broker */
void broker_comment_data(int type, int flags, int attr, int comment_type, int entry_type, char *host_name, char *svc_description, time_t entry_time, char *author_name, char *comment_data, int persistent, int source, int expires, time_t expire_time, unsigned long comment_id, struct timeval *timestamp){
	nebstruct_comment_data ds;

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

	ds.comment_type=comment_type;
	ds.entry_type=entry_type;
	ds.host_name=host_name;
	ds.service_description=svc_description;
	ds.object_ptr=NULL; /* not implemented yet */
	ds.entry_time=entry_time;
	ds.author_name=author_name;
	ds.comment_data=comment_data;
	ds.persistent=persistent;
	ds.source=source;
	ds.expires=expires;
	ds.expire_time=expire_time;
	ds.comment_id=comment_id;

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

	return;
        }
Ejemplo n.º 4
0
/* send downtime data to broker */
void broker_downtime_data(int type, int flags, int attr, int downtime_type, char *host_name, char *svc_description, time_t entry_time, char *author_name, char *comment_data, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long downtime_id, struct timeval *timestamp){
	nebstruct_downtime_data ds;

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

	ds.downtime_type=downtime_type;
	ds.host_name=host_name;
	ds.service_description=svc_description;
	ds.object_ptr=NULL; /* not implemented yet */
	ds.entry_time=entry_time;
	ds.author_name=author_name;
	ds.comment_data=comment_data;
	ds.start_time=start_time;
	ds.end_time=end_time;
	ds.fixed=fixed;
	ds.duration=duration;
	ds.triggered_by=triggered_by;
	ds.downtime_id=downtime_id;

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

	return;
        }
Ejemplo n.º 5
0
/* sends adaptive contact updates to broker */
void broker_adaptive_contact_data(int type, int flags, int attr, contact *cntct, int command_type, unsigned long modattr, unsigned long modattrs, unsigned long modhattr, unsigned long modhattrs, unsigned long modsattr, unsigned long modsattrs, struct timeval *timestamp){
	nebstruct_adaptive_contact_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.modified_host_attribute=modhattr;
	ds.modified_host_attributes=modhattrs;
	ds.modified_service_attribute=modsattr;
	ds.modified_service_attributes=modsattrs;
	ds.object_ptr=(void *)cntct;

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

	return;
        }
Ejemplo n.º 6
0
/* send system command data to broker */
void broker_system_command(int type, int flags, int attr, struct timeval start_time, struct timeval end_time, double exectime, int timeout, int early_timeout, int retcode, char *cmd, char *output, struct timeval *timestamp){
	nebstruct_system_command_data ds;

	if(!(event_broker_options & BROKER_SYSTEM_COMMANDS))
		return;
	
	if(cmd==NULL)
		return;

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

	ds.start_time=start_time;
	ds.end_time=end_time;
	ds.timeout=timeout;
	ds.command_line=cmd;
	ds.early_timeout=early_timeout;
	ds.execution_time=exectime;
	ds.return_code=retcode;
	ds.output=output;

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

	return;
        }
Ejemplo n.º 7
0
/* send event handler data to broker */
void 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;

	if(!(event_broker_options & BROKER_EVENT_HANDLERS))
		return;
	
	if(data==NULL)
		return;

	/* 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 */
	neb_make_callbacks(NEBCALLBACK_EVENT_HANDLER_DATA,(void *)&ds);

	/* free memory */
	my_free(command_buf);

	return;
        }
Ejemplo n.º 8
0
/* send service check data to broker */
int broker_service_check(int type, int flags, int attr, service *svc, int check_type, struct timeval start_time, struct timeval end_time, char *cmd, double latency, double exectime, int timeout, int early_timeout, int retcode, char *cmdline, check_result *cr)
{
	char *command_buf = NULL;
	char *command_name = NULL;
	char *command_args = NULL;
	nebstruct_service_check_data ds;
	int return_code = OK;

	if (!(event_broker_options & BROKER_SERVICE_CHECKS))
		return OK;

	if (svc == NULL)
		return ERROR;

	/* get command name/args */
	if (cmd != NULL) {
		command_buf = nm_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;
	get_broker_timestamp(&ds.timestamp);

	ds.host_name = svc->host_name;
	ds.service_description = svc->description;
	ds.object_ptr = (void *)svc;
	ds.check_type = check_type;
	ds.current_attempt = svc->current_attempt;
	ds.max_attempts = svc->max_attempts;
	ds.state = svc->current_state;
	ds.state_type = svc->state_type;
	ds.timeout = timeout;
	ds.command_name = command_name;
	ds.command_args = command_args;
	ds.command_line = cmdline;
	ds.start_time = start_time;
	ds.end_time = end_time;
	ds.early_timeout = early_timeout;
	ds.execution_time = exectime;
	ds.latency = latency;
	ds.return_code = retcode;
	ds.output = svc->plugin_output;
	ds.long_output = svc->long_plugin_output;
	ds.perf_data = svc->perf_data;
	ds.check_result_ptr = cr;

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

	/* free data */
	nm_free(command_buf);

	return return_code;
}
Ejemplo n.º 9
0
/* send host check data to broker */
int broker_host_check(int type, int flags, int attr, host *hst, int check_type, int state, int state_type, struct timeval start_time, struct timeval end_time, char *cmd, double latency, double exectime, int timeout, int early_timeout, int retcode, char *cmdline, char *output, char *long_output, char *perfdata, struct timeval *timestamp, check_result *cr) {
	char *command_buf = NULL;
	char *command_name = NULL;
	char *command_args = NULL;
	nebstruct_host_check_data ds;
	int return_code = OK;

	if(!(event_broker_options & BROKER_HOST_CHECKS))
		return OK;

	if(hst == 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.host_name = hst->name;
	ds.object_ptr = (void *)hst;
	ds.check_type = check_type;
	ds.current_attempt = hst->current_attempt;
	ds.max_attempts = hst->max_attempts;
	ds.state = state;
	ds.state_type = state_type;
	ds.timeout = timeout;
	ds.command_name = command_name;
	ds.command_args = command_args;
	ds.command_line = cmdline;
	ds.start_time = start_time;
	ds.end_time = end_time;
	ds.early_timeout = early_timeout;
	ds.execution_time = exectime;
	ds.latency = latency;
	ds.return_code = retcode;
	ds.output = output;
	ds.long_output = long_output;
	ds.perf_data = perfdata;
	ds.check_result_ptr = cr;

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

	/* free data */
	my_free(command_buf);

	return return_code;
	}
Ejemplo n.º 10
0
int main(void) {
    /* typical in 10000 service scenario: 150..1000 concurrently scheduled async jobs. */
    const int num_checks_at_once = MAX_CONCURRENT_CHECKS;
    void* neb_handle;
    int i;
    char ok = 1;
    char * test_nebargs[] = { "config=extras/shared.conf", };

    struct nebstruct_process_struct data_process_events;
    data_process_events.type = NEBTYPE_PROCESS_EVENTLOOPSTART;

    init_externals();

    init_host();
    init_svc();
    init_svc_check();

    neb_handle = load_neb("./mod_gearman2.o", test_nebargs[0]);
    neb_make_callbacks(NEBCALLBACK_PROCESS_DATA, &data_process_events);

    while (ok) {
        printf("Sending %i service checks.\n", num_checks_at_once);
        for (i = 0; i < num_checks_at_once; i++) {
            nebstruct_service_check_data* data_service_check;
            char host_name[16];
            char service_name[16];
            sprintf(host_name, "%i", i / 10);
            sprintf(service_name, "%i", i);
            data_service_check = setup_service(host_name, service_name);
            neb_make_callbacks(NEBCALLBACK_SERVICE_CHECK_DATA,
                    data_service_check);
        }

        ok = (reap_cr_from_neb(num_checks_at_once) >= num_checks_at_once);
    }

    unload_neb(neb_handle);

    return 0;
}
Ejemplo n.º 11
0
/* 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;
        }
Ejemplo n.º 12
0
/* 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;
        }
Ejemplo n.º 13
0
/* 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;
        }
Ejemplo n.º 14
0
/* 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)
{
	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;
	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;
	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;
}
Ejemplo n.º 15
0
/* 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;
        }
Ejemplo n.º 16
0
/* 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;
}
Ejemplo n.º 17
0
/* 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;
        }
Ejemplo n.º 18
0
/* 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;
        }
Ejemplo n.º 19
0
/* 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;
	}
Ejemplo n.º 20
0
/* 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;
        }
Ejemplo n.º 21
0
static int reap_cr_from_neb(int num_of_pending_results) {
    nebstruct_timed_event_data data_timed_event;
    int tmp_nr_of_results = -1;

    printf("Waiting for all results to arrive...\n");
    while (tmp_nr_of_results != nr_of_rcv_results
            || nr_of_rcv_results < num_of_pending_results) {
        if (tmp_nr_of_results >= 0)
            printf(" received %i from %i\n", nr_of_rcv_results,
                    num_of_pending_results);

        tmp_nr_of_results = nr_of_rcv_results;

        /* reap results, neb module will call process_check_result therefore */
        data_timed_event.event_type = EVENT_CHECK_REAPER;
        neb_make_callbacks(NEBCALLBACK_TIMED_EVENT_DATA, &data_timed_event);
        sleep(1);
    }
    nr_of_rcv_results = 0;

    return verify_check_results(num_of_pending_results);
}
Ejemplo n.º 22
0
/* 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;
        }
Ejemplo n.º 23
0
/* 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;
}
Ejemplo n.º 24
0
/* 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)
{
	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;
	get_broker_timestamp(&ds.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;
}