コード例 #1
0
/* write a host problem/recovery to the log file */
int log_host_event(host *hst) {
    char *temp_buffer = NULL;
    unsigned long log_options = 0L;

    /* get the log options */
    if(hst->current_state == HOST_DOWN)
        log_options = NSLOG_HOST_DOWN;
    else if(hst->current_state == HOST_UNREACHABLE)
        log_options = NSLOG_HOST_UNREACHABLE;
    else
        log_options = NSLOG_HOST_UP;

    asprintf(&temp_buffer, "HOST ALERT: %s;%s;%s;%d;%s\n",
             hst->name,
             host_state_name(hst->current_state),
             state_type_name(hst->state_type),
             hst->current_attempt,
             (hst->plugin_output == NULL) ? "" : hst->plugin_output);

    write_to_all_logs(temp_buffer, log_options);

    my_free(temp_buffer);

    return OK;
}
コード例 #2
0
ファイル: logging.c プロジェクト: mattbostock/icinga-core
/* logs host states */
int log_host_states(int type, time_t *timestamp) {
	char *temp_buffer = NULL;
	host *temp_host = NULL;

	/* bail if we shouldn't be logging initial states */
	if (type == INITIAL_STATES && log_initial_states == FALSE)
		return OK;

	for (temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {

		asprintf(&temp_buffer, "%s HOST STATE: %s;%s;%s;%d;%s\n",
				(type == INITIAL_STATES) ? "INITIAL" : "CURRENT",
				temp_host->name,
				host_state_name(temp_host->current_state),
				state_type_name(temp_host->state_type),
				temp_host->current_attempt,
				(temp_host->plugin_output == NULL) ? "" : temp_host->plugin_output
				);

		write_to_all_logs_with_timestamp_with_host_service(temp_buffer, NSLOG_INFO_MESSAGE, timestamp, temp_host, NULL);

		my_free(temp_buffer);
	}

	return OK;
}
コード例 #3
0
ファイル: logging.c プロジェクト: mattbostock/icinga-core
/* write a host problem/recovery to the log file */
int log_host_event(host *hst) {
	char *temp_buffer = NULL;
	unsigned long log_options = 0L;

	/* get the log options */
	if (hst->current_state == HOST_DOWN)
		log_options = NSLOG_HOST_DOWN;
	else if (hst->current_state == HOST_UNREACHABLE)
		log_options = NSLOG_HOST_UNREACHABLE;
	else
		log_options = NSLOG_HOST_UP;

	/* either log only the output, or if enabled, add long_output */
	if (log_long_plugin_output == TRUE && hst->long_plugin_output != NULL) {
		asprintf(&temp_buffer, "HOST ALERT: %s;%s;%s;%d;%s\\n%s\n",
				hst->name,
				host_state_name(hst->current_state),
				state_type_name(hst->state_type),
				hst->current_attempt,
				(hst->plugin_output == NULL) ? "" : hst->plugin_output,
				hst->long_plugin_output
				);
	} else {
		asprintf(&temp_buffer, "HOST ALERT: %s;%s;%s;%d;%s\n",
				hst->name,
				host_state_name(hst->current_state),
				state_type_name(hst->state_type),
				hst->current_attempt,
				(hst->plugin_output == NULL) ? "" : hst->plugin_output
				);
	}

	write_to_all_logs_with_host_service(temp_buffer, log_options, hst, NULL);
	my_free(temp_buffer);

	return OK;
}
コード例 #4
0
ファイル: objects_host.c プロジェクト: ipstatic/naemon-core
/* logs host states */
int log_host_states(int type, time_t *timestamp)
{
	host *temp_host = NULL;;

	/* bail if we shouldn't be logging initial states */
	if (type == INITIAL_STATES && log_initial_states == FALSE)
		return OK;

	for (temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
		nm_log(NSLOG_INFO_MESSAGE, "%s HOST STATE: %s;%s;%s;%d;%s\n", (type == INITIAL_STATES) ? "INITIAL" : "CURRENT",
					temp_host->name,
					host_state_name(temp_host->current_state),
					state_type_name(temp_host->state_type),
					temp_host->current_attempt,
					(temp_host->plugin_output == NULL) ? "" : temp_host->plugin_output);
	}

	return OK;
}
コード例 #5
0
ファイル: objects_host.c プロジェクト: ipstatic/naemon-core
/* write a host problem/recovery to the log file */
int log_host_event(host *hst)
{
	unsigned long log_options = 0L;

	/* get the log options */
	if (hst->current_state == STATE_DOWN)
		log_options = NSLOG_HOST_DOWN;
	else if (hst->current_state == STATE_UNREACHABLE)
		log_options = NSLOG_HOST_UNREACHABLE;
	else
		log_options = NSLOG_HOST_UP;

	nm_log(log_options, "HOST ALERT: %s;%s;%s;%d;%s\n",
				hst->name,
				host_state_name(hst->current_state),
				state_type_name(hst->state_type),
				hst->current_attempt,
				(hst->plugin_output == NULL) ? "" : hst->plugin_output);

	return OK;
}