コード例 #1
0
ファイル: showlog.c プロジェクト: fjpqzm/naigos_locale
/* display the contents of the log file */
int display_log(void) {
	char *input = NULL;
	char image[MAX_INPUT_BUFFER];
	char image_alt[MAX_INPUT_BUFFER];
	time_t t;
	char *temp_buffer = NULL;
	char date_time[MAX_DATETIME_LENGTH];
	int error = FALSE;
	mmapfile *thefile = NULL;
	char last_message_date[MAX_INPUT_BUFFER] = "";
	char current_message_date[MAX_INPUT_BUFFER] = "";
	struct tm *time_ptr = NULL;


	/* check to see if the user is authorized to view the log file */
	if(is_authorized_for_system_information(&current_authdata) == FALSE) {
		printf("<HR>\n");
		printf("<DIV CLASS='errorMessage'>%s</DIV><br><br>\n",_("It appears as though you do not have permission to view the log file..."));
		printf("<DIV CLASS='errorDescription'>%s</DIV>\n",_("If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI<br>and check the authorization options in your CGI configuration file."));
		printf("<HR>\n");
		return ERROR;
		}

	error = FALSE;

	if(use_lifo == TRUE) {
		error = read_file_into_lifo(log_file_to_use);
		if(error != LIFO_OK) {
			if(error == LIFO_ERROR_MEMORY) {
				printf("<P><DIV CLASS='warningMessage'>Not enough memory to reverse log file - displaying log in natural order...</DIV></P>");
				error = FALSE;
				}
			else
				error = TRUE;
			use_lifo = FALSE;
			}
		else
			error = FALSE;
		}

	if(use_lifo == FALSE) {

		if((thefile = mmap_fopen(log_file_to_use)) == NULL) {
			printf("<HR>\n");
			printf("<P><DIV CLASS='errorMessage'>%s</DIV></P>", log_file_to_use,_("Error: Could not open log file '%s' for reading!"));
			printf("<HR>\n");
			error = TRUE;
			}
		}

	if(error == FALSE) {

		printf("<P><DIV CLASS='logEntries'>\n");

		while(1) {

			free(input);

			if(use_lifo == TRUE) {
				if((input = pop_lifo()) == NULL)
					break;
				}
			else if((input = mmap_fgets(thefile)) == NULL)
				break;

			strip(input);

			if(strstr(input, " starting...")) {
				strcpy(image, START_ICON);
				strcpy(image_alt, START_ICON_ALT);
				}
			else if(strstr(input, " shutting down...")) {
				strcpy(image, STOP_ICON);
				strcpy(image_alt, STOP_ICON_ALT);
				}
			else if(strstr(input, "Bailing out")) {
				strcpy(image, STOP_ICON);
				strcpy(image_alt, STOP_ICON_ALT);
				}
			else if(strstr(input, " restarting...")) {
				strcpy(image, RESTART_ICON);
				strcpy(image_alt, RESTART_ICON_ALT);
				}
			else if(strstr(input, "HOST ALERT:") && strstr(input, ";DOWN;")) {
				strcpy(image, HOST_DOWN_ICON);
				strcpy(image_alt, HOST_DOWN_ICON_ALT);
				}
			else if(strstr(input, "HOST ALERT:") && strstr(input, ";UNREACHABLE;")) {
				strcpy(image, HOST_UNREACHABLE_ICON);
				strcpy(image_alt, HOST_UNREACHABLE_ICON_ALT);
				}
			else if(strstr(input, "HOST ALERT:") && (strstr(input, ";RECOVERY;") || strstr(input, ";UP;"))) {
				strcpy(image, HOST_UP_ICON);
				strcpy(image_alt, HOST_UP_ICON_ALT);
				}
			else if(strstr(input, "HOST NOTIFICATION:")) {
				strcpy(image, HOST_NOTIFICATION_ICON);
				strcpy(image_alt, HOST_NOTIFICATION_ICON_ALT);
				}
			else if(strstr(input, "SERVICE ALERT:") && strstr(input, ";CRITICAL;")) {
				strcpy(image, CRITICAL_ICON);
				strcpy(image_alt, CRITICAL_ICON_ALT);
				}
			else if(strstr(input, "SERVICE ALERT:") && strstr(input, ";WARNING;")) {
				strcpy(image, WARNING_ICON);
				strcpy(image_alt, WARNING_ICON_ALT);
				}
			else if(strstr(input, "SERVICE ALERT:") && strstr(input, ";UNKNOWN;")) {
				strcpy(image, UNKNOWN_ICON);
				strcpy(image_alt, UNKNOWN_ICON_ALT);
				}
			else if(strstr(input, "SERVICE ALERT:") && (strstr(input, ";RECOVERY;") || strstr(input, ";OK;"))) {
				strcpy(image, OK_ICON);
				strcpy(image_alt, OK_ICON_ALT);
				}
			else if(strstr(input, "SERVICE NOTIFICATION:")) {
				strcpy(image, NOTIFICATION_ICON);
				strcpy(image_alt, NOTIFICATION_ICON_ALT);
				}
			else if(strstr(input, "SERVICE EVENT HANDLER:")) {
				strcpy(image, SERVICE_EVENT_ICON);
				strcpy(image_alt, SERVICE_EVENT_ICON_ALT);
				}
			else if(strstr(input, "HOST EVENT HANDLER:")) {
				strcpy(image, HOST_EVENT_ICON);
				strcpy(image_alt, HOST_EVENT_ICON_ALT);
				}
			else if(strstr(input, "EXTERNAL COMMAND:")) {
				strcpy(image, EXTERNAL_COMMAND_ICON);
				strcpy(image_alt, EXTERNAL_COMMAND_ICON_ALT);
				}
			else if(strstr(input, "PASSIVE SERVICE CHECK:")) {
				strcpy(image, PASSIVE_ICON);
				strcpy(image_alt, "Passive Service Check");
				}
			else if(strstr(input, "PASSIVE HOST CHECK:")) {
				strcpy(image, PASSIVE_ICON);
				strcpy(image_alt, "Passive Host Check");
				}
			else if(strstr(input, "LOG ROTATION:")) {
				strcpy(image, LOG_ROTATION_ICON);
				strcpy(image_alt, LOG_ROTATION_ICON_ALT);
				}
			else if(strstr(input, "active mode...")) {
				strcpy(image, ACTIVE_ICON);
				strcpy(image_alt, ACTIVE_ICON_ALT);
				}
			else if(strstr(input, "standby mode...")) {
				strcpy(image, STANDBY_ICON);
				strcpy(image_alt, STANDBY_ICON_ALT);
				}
			else if(strstr(input, "SERVICE FLAPPING ALERT:") && strstr(input, ";STARTED;")) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Service started flapping");
				}
			else if(strstr(input, "SERVICE FLAPPING ALERT:") && strstr(input, ";STOPPED;")) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Service stopped flapping");
				}
			else if(strstr(input, "SERVICE FLAPPING ALERT:") && strstr(input, ";DISABLED;")) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Service flap detection disabled");
				}
			else if(strstr(input, "HOST FLAPPING ALERT:") && strstr(input, ";STARTED;")) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Host started flapping");
				}
			else if(strstr(input, "HOST FLAPPING ALERT:") && strstr(input, ";STOPPED;")) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Host stopped flapping");
				}
			else if(strstr(input, "HOST FLAPPING ALERT:") && strstr(input, ";DISABLED;")) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Host flap detection disabled");
				}
			else if(strstr(input, "SERVICE DOWNTIME ALERT:") && strstr(input, ";STARTED;")) {
				strcpy(image, SCHEDULED_DOWNTIME_ICON);
				strcpy(image_alt, "Service entered a period of scheduled downtime");
				}
			else if(strstr(input, "SERVICE DOWNTIME ALERT:") && strstr(input, ";STOPPED;")) {
				strcpy(image, SCHEDULED_DOWNTIME_ICON);
				strcpy(image_alt, "Service exited a period of scheduled downtime");
				}
			else if(strstr(input, "SERVICE DOWNTIME ALERT:") && strstr(input, ";CANCELLED;")) {
				strcpy(image, SCHEDULED_DOWNTIME_ICON);
				strcpy(image_alt, "Service scheduled downtime has been cancelled");
				}
			else if(strstr(input, "HOST DOWNTIME ALERT:") && strstr(input, ";STARTED;")) {
				strcpy(image, SCHEDULED_DOWNTIME_ICON);
				strcpy(image_alt, "Host entered a period of scheduled downtime");
				}
			else if(strstr(input, "HOST DOWNTIME ALERT:") && strstr(input, ";STOPPED;")) {
				strcpy(image, SCHEDULED_DOWNTIME_ICON);
				strcpy(image_alt, "Host exited a period of scheduled downtime");
				}
			else if(strstr(input, "HOST DOWNTIME ALERT:") && strstr(input, ";CANCELLED;")) {
				strcpy(image, SCHEDULED_DOWNTIME_ICON);
				strcpy(image_alt, "Host scheduled downtime has been cancelled");
				}
			else {
				strcpy(image, INFO_ICON);
				strcpy(image_alt, INFO_ICON_ALT);
				}

			temp_buffer = strtok(input, "]");
			t = (temp_buffer == NULL) ? 0L : strtoul(temp_buffer + 1, NULL, 10);

			time_ptr = localtime(&t);
			strftime(current_message_date, sizeof(current_message_date), "%B %d, %Y %H:00\n", time_ptr);
			current_message_date[sizeof(current_message_date) - 1] = '\x0';

			if(strcmp(last_message_date, current_message_date) != 0 && display_timebreaks == TRUE) {
				printf("<BR CLEAR='all'>\n");
				printf("<DIV CLASS='dateTimeBreak'>\n");
				printf("<table border=0 width=95%%><tr>");
				printf("<td width=40%%><hr width=100%%></td>");
				printf("<td align=center CLASS='dateTimeBreak'>%s</td>", current_message_date);
				printf("<td width=40%%><hr width=100%%></td>");
				printf("</tr></table>\n");
				printf("</DIV>\n");
				printf("<BR CLEAR='all'><DIV CLASS='logEntries'>\n");
				strncpy(last_message_date, current_message_date, sizeof(last_message_date));
				last_message_date[sizeof(last_message_date) - 1] = '\x0';
				}

			get_time_string(&t, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
			strip(date_time);

			temp_buffer = strtok(NULL, "\n");

			if(display_frills == TRUE)
				printf("<img align='left' src='%s%s' alt='%s' title='%s'>", url_images_path, image, image_alt, image_alt);
			printf("[%s] %s", date_time, (temp_buffer == NULL) ? "" : html_encode(temp_buffer, FALSE));
			if(enable_splunk_integration == TRUE) {
				printf("&nbsp;&nbsp;&nbsp;");
				display_splunk_generic_url(temp_buffer, 2);
				}
			printf("<br clear='all'>\n");
			}

		printf("</DIV></P>\n");
		printf("<HR>\n");

		free(input);

		if(use_lifo == FALSE)
			mmap_fclose(thefile);
		}

	if(use_lifo == TRUE)
		free_lifo_memory();

	return OK;
	}
コード例 #2
0
ファイル: history.c プロジェクト: jbuchbinder/icinga-core
void show_history(void) {
    char image[MAX_INPUT_BUFFER];
    char image_alt[MAX_INPUT_BUFFER];
    char match1[MAX_INPUT_BUFFER];
    char match2[MAX_INPUT_BUFFER];
    char date_time[MAX_DATETIME_LENGTH];
    char last_message_date[MAX_INPUT_BUFFER] = "";
    char current_message_date[MAX_INPUT_BUFFER] = "";
    char *temp_buffer = NULL;
    char *entry_host_name = NULL;
    char *entry_service_desc = NULL;
    char *error_text = NULL;
    int system_message = FALSE;
    int display_line = FALSE;
    int history_type = SERVICE_HISTORY;
    int history_detail_type = HISTORY_SERVICE_CRITICAL;
    int status = READLOG_OK;
    int displayed_entries = 0;
    int total_entries = 0;
    host *temp_host = NULL;
    service *temp_service = NULL;
    hostgroup *temp_hostgroup = NULL;
    servicegroup *temp_servicegroup = NULL;
    logentry *temp_entry = NULL;
    struct tm *time_ptr = NULL;
    logentry *entry_list = NULL;
    logfilter *filter_list = NULL;


    if (display_type == DISPLAY_HOSTGROUPS) {

        temp_hostgroup = find_hostgroup(hostgroup_name);

        if (temp_hostgroup == NULL) {
            print_generic_error_message("There are no host groups with this name defined.", NULL, 0);
            return;
        }
        /* make sure the user is authorized to view this hostgroup */
        if (show_partial_hostgroups == FALSE && is_authorized_for_hostgroup(temp_hostgroup, &current_authdata) == FALSE) {
            print_generic_error_message("It appears as though you do not have permission to view information for the host group you requested...", "If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI and check the authorization options in your CGI configuration file.", 0);
            return;
        }
    }

    if (display_type == DISPLAY_SERVICEGROUPS) {

        temp_servicegroup = find_servicegroup(servicegroup_name);

        if (temp_servicegroup == NULL) {
            print_generic_error_message("There are no service groups with this name defined.", NULL, 0);
            return;
        }
        /* make sure the user is authorized to view this servicegroup */
        if (is_authorized_for_servicegroup(temp_servicegroup, &current_authdata) == FALSE) {
            print_generic_error_message("It appears as though you do not have permission to view information for the service group you requested...", "If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI and check the authorization options in your CGI configuration file.", 0);
            return;
        }
    }

    add_log_filter(&filter_list, LOGENTRY_SERVICE_CRITICAL, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_WARNING, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_UNKNOWN, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_RECOVERY, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_OK, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_FLAPPING_STARTED, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_FLAPPING_STOPPED, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_FLAPPING_DISABLED, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_DOWNTIME_STARTED, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_DOWNTIME_STOPPED, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SERVICE_DOWNTIME_CANCELLED, LOGFILTER_INCLUDE);

    if (display_type == DISPLAY_HOSTS || display_type == DISPLAY_HOSTGROUPS) {
        add_log_filter(&filter_list, LOGENTRY_HOST_DOWN, LOGFILTER_INCLUDE);
        add_log_filter(&filter_list, LOGENTRY_HOST_UNREACHABLE, LOGFILTER_INCLUDE);
        add_log_filter(&filter_list, LOGENTRY_HOST_RECOVERY, LOGFILTER_INCLUDE);
        add_log_filter(&filter_list, LOGENTRY_HOST_UP, LOGFILTER_INCLUDE);
        add_log_filter(&filter_list, LOGENTRY_HOST_FLAPPING_STARTED, LOGFILTER_INCLUDE);
        add_log_filter(&filter_list, LOGENTRY_HOST_FLAPPING_STOPPED, LOGFILTER_INCLUDE);
        add_log_filter(&filter_list, LOGENTRY_HOST_FLAPPING_DISABLED, LOGFILTER_INCLUDE);
        add_log_filter(&filter_list, LOGENTRY_HOST_FLAPPING_DISABLED, LOGFILTER_INCLUDE);
        add_log_filter(&filter_list, LOGENTRY_HOST_FLAPPING_STOPPED, LOGFILTER_INCLUDE);
        add_log_filter(&filter_list, LOGENTRY_HOST_FLAPPING_DISABLED, LOGFILTER_INCLUDE);
    }

    /* system log entries */
    add_log_filter(&filter_list, LOGENTRY_STARTUP, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_SHUTDOWN, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_BAILOUT, LOGFILTER_INCLUDE);
    add_log_filter(&filter_list, LOGENTRY_RESTART, LOGFILTER_INCLUDE);


    /* scan the log file for archived state data */
    status = get_log_entries(&entry_list, &filter_list, &error_text, NULL, reverse, ts_start, ts_end);


    /* dealing with errors */
    if (status == READLOG_ERROR_WARNING) {
        if (error_text != NULL) {
            print_generic_error_message(error_text, NULL, 0);
            my_free(error_text);
        } else
            print_generic_error_message("Unkown error!", NULL, 0);
    }

    if (status == READLOG_ERROR_MEMORY)
        print_generic_error_message("Out of memory...", "showing all I could get!", 0);


    if (status == READLOG_ERROR_FATAL) {
        if (error_text != NULL) {
            print_generic_error_message(error_text, NULL, 0);
            my_free(error_text);
        }

        return;

        /* now we start displaying the log entries */
    } else {

        printf("<table width='100%%' cellspacing=0 cellpadding=0><tr><td width='33%%'></td><td width='33%%' nowrap>");
        printf("<div class='page_selector' id='hist_page_selector'>\n");
        printf("<div id='page_navigation_copy'></div>");
        page_limit_selector(result_start);
        printf("</div>\n");
        printf("</td><td width='33%%' align='right' style='padding-right:2px'>\n");
        print_export_link(HTML_CONTENT, HISTORY_CGI, NULL);
        printf("</td></tr></table>");

        printf("<DIV CLASS='logEntries'>\n");

        for (temp_entry = entry_list; temp_entry != NULL; temp_entry = temp_entry->next) {

            strcpy(image, "");
            strcpy(image_alt, "");
            system_message = FALSE;

            switch (temp_entry->type) {

            /* service state alerts */
            case LOGENTRY_SERVICE_CRITICAL:
            case LOGENTRY_SERVICE_WARNING:
            case LOGENTRY_SERVICE_UNKNOWN:
            case LOGENTRY_SERVICE_RECOVERY:
            case LOGENTRY_SERVICE_OK:

                history_type = SERVICE_HISTORY;

                /* get host and service names */
                temp_buffer = my_strtok(temp_entry->entry_text, ":");
                temp_buffer = my_strtok(NULL, ";");
                if (temp_buffer)
                    entry_host_name = strdup(temp_buffer + 1);
                else
                    entry_host_name = NULL;

                temp_buffer = my_strtok(NULL, ";");
                if (temp_buffer)
                    entry_service_desc = strdup(temp_buffer);
                else
                    entry_service_desc = NULL;

                if (temp_entry->type == LOGENTRY_SERVICE_CRITICAL) {
                    strcpy(image, CRITICAL_ICON);
                    strcpy(image_alt, CRITICAL_ICON_ALT);
                    history_detail_type = HISTORY_SERVICE_CRITICAL;
                } else if (temp_entry->type == LOGENTRY_SERVICE_WARNING) {
                    strcpy(image, WARNING_ICON);
                    strcpy(image_alt, WARNING_ICON_ALT);
                    history_detail_type = HISTORY_SERVICE_WARNING;
                } else if (temp_entry->type == LOGENTRY_SERVICE_UNKNOWN) {
                    strcpy(image, UNKNOWN_ICON);
                    strcpy(image_alt, UNKNOWN_ICON_ALT);
                    history_detail_type = HISTORY_SERVICE_UNKNOWN;
                } else if (temp_entry->type == LOGENTRY_SERVICE_RECOVERY || temp_entry->type == LOGENTRY_SERVICE_OK) {
                    strcpy(image, OK_ICON);
                    strcpy(image_alt, OK_ICON_ALT);
                    history_detail_type = HISTORY_SERVICE_RECOVERY;
                }
                break;

            /* service flapping alerts */
            case LOGENTRY_SERVICE_FLAPPING_STARTED:
            case LOGENTRY_SERVICE_FLAPPING_STOPPED:
            case LOGENTRY_SERVICE_FLAPPING_DISABLED:

                if (display_flapping_alerts == FALSE)
                    continue;

                history_type = SERVICE_FLAPPING_HISTORY;

                /* get host and service names */
                temp_buffer = my_strtok(temp_entry->entry_text, ":");
                temp_buffer = my_strtok(NULL, ";");
                if (temp_buffer)
                    entry_host_name = strdup(temp_buffer + 1);
                else
                    entry_host_name = NULL;
                temp_buffer = my_strtok(NULL, ";");
                if (temp_buffer)
                    entry_service_desc = strdup(temp_buffer);
                else
                    entry_service_desc = NULL;

                strcpy(image, FLAPPING_ICON);

                if (temp_entry->type == LOGENTRY_SERVICE_FLAPPING_STARTED)
                    strcpy(image_alt, "Service started flapping");
                else if (temp_entry->type == LOGENTRY_SERVICE_FLAPPING_STOPPED)
                    strcpy(image_alt, "Service stopped flapping");
                else if (temp_entry->type == LOGENTRY_SERVICE_FLAPPING_DISABLED)
                    strcpy(image_alt, "Service flap detection disabled");

                break;

            /* service downtime alerts */
            case LOGENTRY_SERVICE_DOWNTIME_STARTED:
            case LOGENTRY_SERVICE_DOWNTIME_STOPPED:
            case LOGENTRY_SERVICE_DOWNTIME_CANCELLED:

                if (display_downtime_alerts == FALSE)
                    continue;

                history_type = SERVICE_DOWNTIME_HISTORY;

                /* get host and service names */
                temp_buffer = my_strtok(temp_entry->entry_text, ":");
                temp_buffer = my_strtok(NULL, ";");
                if (temp_buffer)
                    entry_host_name = strdup(temp_buffer + 1);
                else
                    entry_host_name = NULL;
                temp_buffer = my_strtok(NULL, ";");
                if (temp_buffer)
                    entry_service_desc = strdup(temp_buffer);
                else
                    entry_service_desc = NULL;

                strcpy(image, DOWNTIME_ICON);

                if (temp_entry->type == LOGENTRY_SERVICE_DOWNTIME_STARTED)
                    strcpy(image_alt, "Service entered a period of scheduled downtime");
                else if (temp_entry->type == LOGENTRY_SERVICE_DOWNTIME_STOPPED)
                    strcpy(image_alt, "Service exited from a period of scheduled downtime");
                else if (temp_entry->type == LOGENTRY_SERVICE_DOWNTIME_CANCELLED)
                    strcpy(image_alt, "Service scheduled downtime has been cancelled");

                break;

            /* host state alerts */
            case LOGENTRY_HOST_DOWN:
            case LOGENTRY_HOST_UNREACHABLE:
            case LOGENTRY_HOST_RECOVERY:
            case LOGENTRY_HOST_UP:

                history_type = HOST_HISTORY;

                /* get host name */
                temp_buffer = my_strtok(temp_entry->entry_text, ":");
                temp_buffer = my_strtok(NULL, ";");
                if (temp_buffer)
                    entry_host_name = strdup(temp_buffer + 1);
                else
                    entry_host_name = NULL;

                if (temp_entry->type == LOGENTRY_HOST_DOWN) {
                    strcpy(image, HOST_DOWN_ICON);
                    strcpy(image_alt, HOST_DOWN_ICON_ALT);
                    history_detail_type = HISTORY_HOST_DOWN;
                } else if (temp_entry->type == LOGENTRY_HOST_UNREACHABLE) {
                    strcpy(image, HOST_UNREACHABLE_ICON);
                    strcpy(image_alt, HOST_UNREACHABLE_ICON_ALT);
                    history_detail_type = HISTORY_HOST_UNREACHABLE;
                } else if (temp_entry->type == LOGENTRY_HOST_RECOVERY || temp_entry->type == LOGENTRY_HOST_UP) {
                    strcpy(image, HOST_UP_ICON);
                    strcpy(image_alt, HOST_UP_ICON_ALT);
                    history_detail_type = HISTORY_HOST_RECOVERY;
                }

                break;

            /* host flapping alerts */
            case LOGENTRY_HOST_FLAPPING_STARTED:
            case LOGENTRY_HOST_FLAPPING_STOPPED:
            case LOGENTRY_HOST_FLAPPING_DISABLED:

                if (display_flapping_alerts == FALSE)
                    continue;

                history_type = HOST_FLAPPING_HISTORY;

                /* get host name */
                temp_buffer = my_strtok(temp_entry->entry_text, ":");
                temp_buffer = my_strtok(NULL, ";");
                if (temp_buffer)
                    entry_host_name = strdup(temp_buffer + 1);
                else
                    entry_host_name = NULL;

                strcpy(image, FLAPPING_ICON);

                if (temp_entry->type == LOGENTRY_HOST_FLAPPING_STARTED)
                    strcpy(image_alt, "Host started flapping");
                else if (temp_entry->type == LOGENTRY_HOST_FLAPPING_STOPPED)
                    strcpy(image_alt, "Host stopped flapping");
                else if (temp_entry->type == LOGENTRY_HOST_FLAPPING_DISABLED)
                    strcpy(image_alt, "Host flap detection disabled");

                break;

            /* host downtime alerts */
            case LOGENTRY_HOST_DOWNTIME_STARTED:
            case LOGENTRY_HOST_DOWNTIME_STOPPED:
            case LOGENTRY_HOST_DOWNTIME_CANCELLED:

                if (display_downtime_alerts == FALSE)
                    continue;

                history_type = HOST_DOWNTIME_HISTORY;

                /* get host name */
                temp_buffer = my_strtok(temp_entry->entry_text, ":");
                temp_buffer = my_strtok(NULL, ";");
                if (temp_buffer)
                    entry_host_name = strdup(temp_buffer + 1);
                else
                    entry_host_name = NULL;

                strcpy(image, DOWNTIME_ICON);

                if (temp_entry->type == LOGENTRY_HOST_DOWNTIME_STARTED)
                    strcpy(image_alt, "Host entered a period of scheduled downtime");
                else if (temp_entry->type == LOGENTRY_HOST_DOWNTIME_STOPPED)
                    strcpy(image_alt, "Host exited from a period of scheduled downtime");
                else if (temp_entry->type == LOGENTRY_HOST_DOWNTIME_CANCELLED)
                    strcpy(image_alt, "Host scheduled downtime has been cancelled");

                break;


            /* program start */
            case LOGENTRY_STARTUP:
                if (display_system_messages == FALSE)
                    continue;
                strcpy(image, START_ICON);
                strcpy(image_alt, START_ICON_ALT);
                system_message = TRUE;
                break;

            /* program termination */
            case LOGENTRY_SHUTDOWN:
            case LOGENTRY_BAILOUT:
                if (display_system_messages == FALSE)
                    continue;
                strcpy(image, STOP_ICON);
                strcpy(image_alt, STOP_ICON_ALT);
                system_message = TRUE;
                break;

            /* program restart */
            case LOGENTRY_RESTART:
                if (display_system_messages == FALSE)
                    continue;
                strcpy(image, RESTART_ICON);
                strcpy(image_alt, RESTART_ICON_ALT);
                system_message = TRUE;
                break;
            }

            image[sizeof(image) - 1] = '\x0';
            image_alt[sizeof(image_alt) - 1] = '\x0';

            /* get the timestamp */
            time_ptr = localtime(&temp_entry->timestamp);
            strftime(current_message_date, sizeof(current_message_date), "%B %d, %Y %H:00\n", time_ptr);
            current_message_date[sizeof(current_message_date) - 1] = '\x0';

            get_time_string(&temp_entry->timestamp, date_time, sizeof(date_time), SHORT_DATE_TIME);
            strip(date_time);

            if (strcmp(image, "")) {

                display_line = FALSE;

                if (system_message == TRUE)
                    display_line = TRUE;

                else if (display_type == DISPLAY_HOSTS || display_type == DISPLAY_HOSTGROUPS) {

                    if (history_type == HOST_HISTORY || history_type == SERVICE_HISTORY) {
                        snprintf(match1, sizeof(match1), " HOST ALERT: %s;", host_name);
                        snprintf(match2, sizeof(match2), " SERVICE ALERT: %s;", host_name);
                    } else if (history_type == HOST_FLAPPING_HISTORY || history_type == SERVICE_FLAPPING_HISTORY) {
                        snprintf(match1, sizeof(match1), " HOST FLAPPING ALERT: %s;", host_name);
                        snprintf(match2, sizeof(match2), " SERVICE FLAPPING ALERT: %s;", host_name);
                    } else if (history_type == HOST_DOWNTIME_HISTORY || history_type == SERVICE_DOWNTIME_HISTORY) {
                        snprintf(match1, sizeof(match1), " HOST DOWNTIME ALERT: %s;", host_name);
                        snprintf(match2, sizeof(match2), " SERVICE DOWNTIME ALERT: %s;", host_name);
                    }

                    if (show_all_hosts == TRUE)
                        display_line = TRUE;
                    else if (strstr(temp_entry->entry_text, match1))
                        display_line = TRUE;
                    else if (strstr(temp_entry->entry_text, match2))
                        display_line = TRUE;

                    if (display_line == TRUE) {
                        if (history_options == HISTORY_ALL)
                            display_line = TRUE;
                        else if (history_options == HISTORY_HOST_ALL && (history_type == HOST_HISTORY || history_type == HOST_FLAPPING_HISTORY || history_type == HOST_DOWNTIME_HISTORY))
                            display_line = TRUE;
                        else if (history_options == HISTORY_SERVICE_ALL && (history_type == SERVICE_HISTORY || history_type == SERVICE_FLAPPING_HISTORY || history_type == SERVICE_DOWNTIME_HISTORY))
                            display_line = TRUE;
                        else if ((history_type == HOST_HISTORY || history_type == SERVICE_HISTORY) && (history_detail_type & history_options))
                            display_line = TRUE;
                        else
                            display_line = FALSE;
                    }

                    /* check alert state types */
                    if (display_line == TRUE && (history_type == HOST_HISTORY || history_type == SERVICE_HISTORY)) {
                        if (state_options == STATE_ALL)
                            display_line = TRUE;
                        else if ((state_options & STATE_SOFT) && strstr(temp_entry->entry_text, ";SOFT;"))
                            display_line = TRUE;
                        else if ((state_options & STATE_HARD) && strstr(temp_entry->entry_text, ";HARD;"))
                            display_line = TRUE;
                        else
                            display_line = FALSE;
                    }
                }

                else if (display_type == DISPLAY_SERVICES || display_type == DISPLAY_SERVICEGROUPS) {

                    if (history_type == SERVICE_HISTORY)
                        snprintf(match1, sizeof(match1), " SERVICE ALERT: %s;%s;", host_name, service_desc);
                    else if (history_type == SERVICE_FLAPPING_HISTORY)
                        snprintf(match1, sizeof(match1), " SERVICE FLAPPING ALERT: %s;%s;", host_name, service_desc);
                    else if (history_type == SERVICE_DOWNTIME_HISTORY)
                        snprintf(match1, sizeof(match1), " SERVICE DOWNTIME ALERT: %s;%s;", host_name, service_desc);

                    if (display_type == DISPLAY_SERVICEGROUPS)
                        display_line = TRUE;
                    else if (strstr(temp_entry->entry_text, match1))
                        display_line = TRUE;

                    if (history_type != SERVICE_HISTORY && history_type != SERVICE_FLAPPING_HISTORY && history_type != SERVICE_DOWNTIME_HISTORY)
                        display_line = FALSE;

                    if (display_line == TRUE) {
                        if (history_options == HISTORY_ALL || history_options == HISTORY_SERVICE_ALL)
                            display_line = TRUE;
                        else if (history_options & history_detail_type)
                            display_line = TRUE;
                        else
                            display_line = FALSE;
                    }

                    /* check alert state type */
                    if (display_line == TRUE && history_type == SERVICE_HISTORY) {

                        if (state_options == STATE_ALL)
                            display_line = TRUE;
                        else if ((state_options & STATE_SOFT) && strstr(temp_entry->entry_text, ";SOFT;"))
                            display_line = TRUE;
                        else if ((state_options & STATE_HARD) && strstr(temp_entry->entry_text, ";HARD;"))
                            display_line = TRUE;
                        else
                            display_line = FALSE;
                    }
                }

                /* make sure user is authorized to view this log entry */
                if (display_line == TRUE) {

                    if (system_message == TRUE) {
                        if (is_authorized_for_system_information(&current_authdata) == FALSE)
                            display_line = FALSE;
                    } else {
                        temp_host = find_host(entry_host_name);

                        if (history_type == HOST_HISTORY || history_type == HOST_FLAPPING_HISTORY || history_type == HOST_DOWNTIME_HISTORY) {
                            if (is_authorized_for_host(temp_host, &current_authdata) == FALSE)
                                display_line = FALSE;
                            else if (display_type == DISPLAY_HOSTGROUPS && is_host_member_of_hostgroup(temp_hostgroup, temp_host) == FALSE)
                                display_line = FALSE;
                        } else {
                            temp_service = find_service(entry_host_name, entry_service_desc);
                            if (is_authorized_for_service(temp_service, &current_authdata) == FALSE)
                                display_line = FALSE;
                            else if (display_type == DISPLAY_HOSTGROUPS && is_host_member_of_hostgroup(temp_hostgroup, temp_host) == FALSE)
                                display_line = FALSE;
                            else if (display_type == DISPLAY_SERVICEGROUPS && is_service_member_of_servicegroup(temp_servicegroup, temp_service) == FALSE)
                                display_line = FALSE;
                        }
                    }
                }

                /* display the entry if we should... */
                if (display_line == TRUE) {

                    if (result_limit != 0  && (((total_entries + 1) < result_start) || (total_entries >= ((result_start + result_limit) - 1)))) {
                        total_entries++;
                        continue;
                    }

                    displayed_entries++;
                    total_entries++;

                    if (strcmp(last_message_date, current_message_date) != 0 && display_timebreaks == TRUE) {
                        printf("</DIV><BR CLEAR='all' />\n");
                        printf("<DIV CLASS='dateTimeBreak'>\n");
                        printf("<table border=0 width=95%%><tr>");
                        printf("<td width=40%%><hr width=100%%></td>");
                        printf("<td align=center CLASS='dateTimeBreak'>%s</td>", current_message_date);
                        printf("<td width=40%%><hr width=100%%></td>");
                        printf("</tr></table>\n");
                        printf("</DIV>\n");
                        printf("<BR CLEAR='all' /><DIV CLASS='logEntries'>\n");
                        strncpy(last_message_date, current_message_date, sizeof(last_message_date));
                        last_message_date[sizeof(last_message_date) - 1] = '\x0';
                    }

                    if (display_frills == TRUE)
                        printf("<img align='left' src='%s%s' alt='%s' title='%s' />", url_images_path, image, image_alt, image_alt);
                    printf("[%s] %s", date_time, html_encode(temp_entry->entry_text, FALSE));
                    if (enable_splunk_integration == TRUE) {
                        printf("&nbsp;&nbsp;&nbsp;");
                        display_splunk_generic_url(temp_entry->entry_text, 2);
                    }
                    printf("<br clear='all' />\n");
                }
            }

            /* free memory */
            free(entry_host_name);
            entry_host_name = NULL;
            free(entry_service_desc);
            entry_service_desc = NULL;
        }
    }

    free_log_entries(&entry_list);

    printf("</DIV>\n");

    if (total_entries == 0) {
        printf("<HR>\n");
        printf("<DIV CLASS='errorMessage' style='text-align:center'>No history information was found ");
        if (display_type == DISPLAY_HOSTS)
            printf("%s", (show_all_hosts == TRUE) ? "" : "for this host ");
        else
            printf("for this service ");
        printf("in log files for selected date.</DIV>");
        printf("<script type='text/javascript'>document.getElementById('hist_page_selector').style.display='none';</script>");
    } else {
        printf("<HR>\n");
        page_num_selector(result_start, total_entries, displayed_entries);
    }

    return;
}
コード例 #3
0
ファイル: history.c プロジェクト: alexanderhsiang/nagios
void get_history(void) {
	mmapfile *thefile = NULL;
	char image[MAX_INPUT_BUFFER];
	char image_alt[MAX_INPUT_BUFFER];
	char *input = NULL;
	char *input2 = NULL;
	char match1[MAX_INPUT_BUFFER];
	char match2[MAX_INPUT_BUFFER];
	int found_line = FALSE;
	int system_message = FALSE;
	int display_line = FALSE;
	time_t t;
	char date_time[MAX_DATETIME_LENGTH];
	char *temp_buffer = NULL;
	int history_type = SERVICE_HISTORY;
	int history_detail_type = HISTORY_SERVICE_CRITICAL;
	char *entry_host_name = NULL;
	char *entry_service_desc = NULL;
	host *temp_host = NULL;
	service *temp_service = NULL;
	int result = 0;

	char last_message_date[MAX_INPUT_BUFFER] = "";
	char current_message_date[MAX_INPUT_BUFFER] = "";
	struct tm *time_ptr = NULL;


	if(use_lifo == TRUE) {
		result = read_file_into_lifo(log_file_to_use);
		if(result != LIFO_OK) {
			if(result == LIFO_ERROR_MEMORY) {
				printf("<P><DIV CLASS='warningMessage'>Not enough memory to reverse log file - displaying history in natural order...</DIV></P>\n");
				}
			else if(result == LIFO_ERROR_FILE) {
				printf("<HR><P><DIV CLASS='errorMessage'>Error: Cannot open log file '%s' for reading!</DIV></P><HR>", log_file_to_use);
				return;
				}
			use_lifo = FALSE;
			}
		}

	if(use_lifo == FALSE) {

		if((thefile = mmap_fopen(log_file_to_use)) == NULL) {
			printf("<HR><P><DIV CLASS='errorMessage'>Error: Cannot open log file '%s' for reading!</DIV></P><HR>", log_file_to_use);
			return;
			}
		}

	printf("<P><DIV CLASS='logEntries'>\n");

	while(1) {

		my_free(input);
		my_free(input2);

		if(use_lifo == TRUE) {
			if((input = pop_lifo()) == NULL)
				break;
			}
		else {
			if((input = mmap_fgets(thefile)) == NULL)
				break;
			}

		strip(input);

		strcpy(image, "");
		strcpy(image_alt, "");
		system_message = FALSE;

		if((input2 = (char *)strdup(input)) == NULL)
			continue;

		/* service state alerts */
		if(strstr(input, "SERVICE ALERT:")) {

			history_type = SERVICE_HISTORY;

			/* get host and service names */
			temp_buffer = my_strtok(input2, "]");
			temp_buffer = my_strtok(NULL, ":");
			temp_buffer = my_strtok(NULL, ";");
			if(temp_buffer)
				entry_host_name = strdup(temp_buffer + 1);
			else
				entry_host_name = NULL;
			temp_buffer = my_strtok(NULL, ";");
			if(temp_buffer)
				entry_service_desc = strdup(temp_buffer);
			else
				entry_service_desc = NULL;

			if(strstr(input, ";CRITICAL;")) {
				strncpy(image, CRITICAL_ICON, sizeof(image));
				strncpy(image_alt, CRITICAL_ICON_ALT, sizeof(image_alt));
				history_detail_type = HISTORY_SERVICE_CRITICAL;
				}
			else if(strstr(input, ";WARNING;")) {
				strncpy(image, WARNING_ICON, sizeof(image));
				strncpy(image_alt, WARNING_ICON_ALT, sizeof(image_alt));
				history_detail_type = HISTORY_SERVICE_WARNING;
				}
			else if(strstr(input, ";UNKNOWN;")) {
				strncpy(image, UNKNOWN_ICON, sizeof(image));
				strncpy(image_alt, UNKNOWN_ICON_ALT, sizeof(image_alt));
				history_detail_type = HISTORY_SERVICE_UNKNOWN;
				}
			else if(strstr(input, ";RECOVERY;") || strstr(input, ";OK;")) {
				strncpy(image, OK_ICON, sizeof(image));
				strncpy(image_alt, OK_ICON_ALT, sizeof(image_alt));
				history_detail_type = HISTORY_SERVICE_RECOVERY;
				}
			}

		/* service flapping alerts */
		else if(strstr(input, "SERVICE FLAPPING ALERT:")) {

			if(display_flapping_alerts == FALSE)
				continue;

			history_type = SERVICE_FLAPPING_HISTORY;

			/* get host and service names */
			temp_buffer = my_strtok(input2, "]");
			temp_buffer = my_strtok(NULL, ":");
			temp_buffer = my_strtok(NULL, ";");
			if(temp_buffer)
				entry_host_name = strdup(temp_buffer + 1);
			else
				entry_host_name = NULL;
			temp_buffer = my_strtok(NULL, ";");
			if(temp_buffer)
				entry_service_desc = strdup(temp_buffer);
			else
				entry_service_desc = NULL;

			strncpy(image, FLAPPING_ICON, sizeof(image));

			if(strstr(input, ";STARTED;"))
				strncpy(image_alt, "Service started flapping", sizeof(image_alt));
			else if(strstr(input, ";STOPPED;"))
				strncpy(image_alt, "Service stopped flapping", sizeof(image_alt));
			else if(strstr(input, ";DISABLED;"))
				strncpy(image_alt, "Service flap detection disabled", sizeof(image_alt));
			}

		/* service downtime alerts */
		else if(strstr(input, "SERVICE DOWNTIME ALERT:")) {

			if(display_downtime_alerts == FALSE)
				continue;

			history_type = SERVICE_DOWNTIME_HISTORY;

			/* get host and service names */
			temp_buffer = my_strtok(input2, "]");
			temp_buffer = my_strtok(NULL, ":");
			temp_buffer = my_strtok(NULL, ";");
			if(temp_buffer)
				entry_host_name = strdup(temp_buffer + 1);
			else
				entry_host_name = NULL;
			temp_buffer = my_strtok(NULL, ";");
			if(temp_buffer)
				entry_service_desc = strdup(temp_buffer);
			else
				entry_service_desc = NULL;

			strncpy(image, SCHEDULED_DOWNTIME_ICON, sizeof(image));

			if(strstr(input, ";STARTED;"))
				strncpy(image_alt, "Service entered a period of scheduled downtime", sizeof(image_alt));
			else if(strstr(input, ";STOPPED;"))
				strncpy(image_alt, "Service exited from a period of scheduled downtime", sizeof(image_alt));
			else if(strstr(input, ";CANCELLED;"))
				strncpy(image_alt, "Service scheduled downtime has been cancelled", sizeof(image_alt));
			}

		/* host state alerts */
		else if(strstr(input, "HOST ALERT:")) {

			history_type = HOST_HISTORY;

			/* get host name */
			temp_buffer = my_strtok(input2, "]");
			temp_buffer = my_strtok(NULL, ":");
			temp_buffer = my_strtok(NULL, ";");
			if(temp_buffer)
				entry_host_name = strdup(temp_buffer + 1);
			else
				entry_host_name = NULL;

			if(strstr(input, ";DOWN;")) {
				strncpy(image, HOST_DOWN_ICON, sizeof(image));
				strncpy(image_alt, HOST_DOWN_ICON_ALT, sizeof(image_alt));
				history_detail_type = HISTORY_HOST_DOWN;
				}
			else if(strstr(input, ";UNREACHABLE;")) {
				strncpy(image, HOST_UNREACHABLE_ICON, sizeof(image));
				strncpy(image_alt, HOST_UNREACHABLE_ICON_ALT, sizeof(image_alt));
				history_detail_type = HISTORY_HOST_UNREACHABLE;
				}
			else if(strstr(input, ";RECOVERY") || strstr(input, ";UP;")) {
				strncpy(image, HOST_UP_ICON, sizeof(image));
				strncpy(image_alt, HOST_UP_ICON_ALT, sizeof(image_alt));
				history_detail_type = HISTORY_HOST_RECOVERY;
				}
			}

		/* host flapping alerts */
		else if(strstr(input, "HOST FLAPPING ALERT:")) {

			if(display_flapping_alerts == FALSE)
				continue;

			history_type = HOST_FLAPPING_HISTORY;

			/* get host name */
			temp_buffer = my_strtok(input2, "]");
			temp_buffer = my_strtok(NULL, ":");
			temp_buffer = my_strtok(NULL, ";");
			if(temp_buffer)
				entry_host_name = strdup(temp_buffer + 1);
			else
				entry_host_name = NULL;

			strncpy(image, FLAPPING_ICON, sizeof(image));

			if(strstr(input, ";STARTED;"))
				strncpy(image_alt, "Host started flapping", sizeof(image_alt));
			else if(strstr(input, ";STOPPED;"))
				strncpy(image_alt, "Host stopped flapping", sizeof(image_alt));
			else if(strstr(input, ";DISABLED;"))
				strncpy(image_alt, "Host flap detection disabled", sizeof(image_alt));
			}

		/* host downtime alerts */
		else if(strstr(input, "HOST DOWNTIME ALERT:")) {

			if(display_downtime_alerts == FALSE)
				continue;

			history_type = HOST_DOWNTIME_HISTORY;

			/* get host name */
			temp_buffer = my_strtok(input2, "]");
			temp_buffer = my_strtok(NULL, ":");
			temp_buffer = my_strtok(NULL, ";");
			if(temp_buffer)
				entry_host_name = strdup(temp_buffer + 1);
			else
				entry_host_name = NULL;

			strncpy(image, SCHEDULED_DOWNTIME_ICON, sizeof(image));

			if(strstr(input, ";STARTED;"))
				strncpy(image_alt, "Host entered a period of scheduled downtime", sizeof(image_alt));
			else if(strstr(input, ";STOPPED;"))
				strncpy(image_alt, "Host exited from a period of scheduled downtime", sizeof(image_alt));
			else if(strstr(input, ";CANCELLED;"))
				strncpy(image_alt, "Host scheduled downtime has been cancelled", sizeof(image_alt));
			}

		else if(display_system_messages == FALSE)
			continue;

		/* program start */
		else if(strstr(input, " starting...")) {
			strncpy(image, START_ICON, sizeof(image));
			strncpy(image_alt, START_ICON_ALT, sizeof(image_alt));
			system_message = TRUE;
			}

		/* normal program termination */
		else if(strstr(input, " shutting down...")) {
			strncpy(image, STOP_ICON, sizeof(image));
			strncpy(image_alt, STOP_ICON_ALT, sizeof(image_alt));
			system_message = TRUE;
			}

		/* abnormal program termination */
		else if(strstr(input, "Bailing out")) {
			strncpy(image, STOP_ICON, sizeof(image));
			strncpy(image_alt, STOP_ICON_ALT, sizeof(image_alt));
			system_message = TRUE;
			}

		/* program restart */
		else if(strstr(input, " restarting...")) {
			strncpy(image, RESTART_ICON, sizeof(image));
			strncpy(image_alt, RESTART_ICON_ALT, sizeof(image_alt));
			system_message = TRUE;
			}

		image[sizeof(image) - 1] = '\x0';
		image_alt[sizeof(image_alt) - 1] = '\x0';

		/* get the timestamp */
		temp_buffer = strtok(input, "]");
		t = (temp_buffer == NULL) ? 0L : strtoul(temp_buffer + 1, NULL, 10);

		time_ptr = localtime(&t);
		strftime(current_message_date, sizeof(current_message_date), "%B %d, %Y %H:00\n", time_ptr);
		current_message_date[sizeof(current_message_date) - 1] = '\x0';

		get_time_string(&t, date_time, sizeof(date_time), SHORT_DATE_TIME);
		strip(date_time);

		temp_buffer = strtok(NULL, "\n");

		if(strcmp(image, "")) {

			display_line = FALSE;

			if(system_message == TRUE)
				display_line = TRUE;

			else if(display_type == DISPLAY_HOSTS) {

				if(history_type == HOST_HISTORY || history_type == SERVICE_HISTORY) {
					snprintf(match1, sizeof( match1), 
							" HOST ALERT: %s;", host_name);
					snprintf(match2, sizeof( match2), 
							" SERVICE ALERT: %s;", host_name);
					}
				else if(history_type == HOST_FLAPPING_HISTORY || history_type == SERVICE_FLAPPING_HISTORY) {
					snprintf(match1, sizeof( match1), 
							" HOST FLAPPING ALERT: %s;", host_name);
					snprintf(match2, sizeof( match2), 
							" SERVICE FLAPPING ALERT: %s;", host_name);
					}
				else if(history_type == HOST_DOWNTIME_HISTORY || history_type == SERVICE_DOWNTIME_HISTORY) {
					snprintf(match1, sizeof( match1), 
							" HOST DOWNTIME ALERT: %s;", host_name);
					snprintf(match2, sizeof( match2), 
							" SERVICE DOWNTIME ALERT: %s;", host_name);
					}

				if(show_all_hosts == TRUE)
					display_line = TRUE;
				else if(strstr(temp_buffer, match1))
					display_line = TRUE;
				else if(strstr(temp_buffer, match2))
					display_line = TRUE;

				if(display_line == TRUE) {
					if(history_options == HISTORY_ALL)
						display_line = TRUE;
					else if(history_options == HISTORY_HOST_ALL && (history_type == HOST_HISTORY || history_type == HOST_FLAPPING_HISTORY || history_type == HOST_DOWNTIME_HISTORY))
						display_line = TRUE;
					else if(history_options == HISTORY_SERVICE_ALL && (history_type == SERVICE_HISTORY || history_type == SERVICE_FLAPPING_HISTORY || history_type == SERVICE_DOWNTIME_HISTORY))
						display_line = TRUE;
					else if((history_type == HOST_HISTORY || history_type == SERVICE_HISTORY) && (history_detail_type & history_options))
						display_line = TRUE;
					else
						display_line = FALSE;
					}

				/* check alert state types */
				if(display_line == TRUE && (history_type == HOST_HISTORY || history_type == SERVICE_HISTORY)) {
					if(state_options == STATE_ALL)
						display_line = TRUE;
					else if((state_options & STATE_SOFT) && strstr(temp_buffer, ";SOFT;"))
						display_line = TRUE;
					else if((state_options & STATE_HARD) && strstr(temp_buffer, ";HARD;"))
						display_line = TRUE;
					else
						display_line = FALSE;
					}
				}

			else if(display_type == DISPLAY_SERVICES) {

				if(history_type == SERVICE_HISTORY)
					snprintf(match1, sizeof( match1), " SERVICE ALERT: %s;%s;", host_name, svc_description);
				else if(history_type == SERVICE_FLAPPING_HISTORY)
					snprintf(match1, sizeof( match1), " SERVICE FLAPPING ALERT: %s;%s;", host_name, svc_description);
				else if(history_type == SERVICE_DOWNTIME_HISTORY)
					snprintf(match1, sizeof( match1), " SERVICE DOWNTIME ALERT: %s;%s;", host_name, svc_description);

				if(strstr(temp_buffer, match1) && (history_type == SERVICE_HISTORY || history_type == SERVICE_FLAPPING_HISTORY || history_type == SERVICE_DOWNTIME_HISTORY))
					display_line = TRUE;

				if(display_line == TRUE) {
					if(history_options == HISTORY_ALL || history_options == HISTORY_SERVICE_ALL)
						display_line = TRUE;
					else if(history_options & history_detail_type)
						display_line = TRUE;
					else
						display_line = FALSE;
					}

				/* check alert state type */
				if(display_line == TRUE && history_type == SERVICE_HISTORY) {

					if(state_options == STATE_ALL)
						display_line = TRUE;
					else if((state_options & STATE_SOFT) && strstr(temp_buffer, ";SOFT;"))
						display_line = TRUE;
					else if((state_options & STATE_HARD) && strstr(temp_buffer, ";HARD;"))
						display_line = TRUE;
					else
						display_line = FALSE;
					}
				}


			/* make sure user is authorized to view this host or service information */
			if(system_message == FALSE) {

				if(history_type == HOST_HISTORY || history_type == HOST_FLAPPING_HISTORY || history_type == HOST_DOWNTIME_HISTORY) {
					temp_host = find_host(entry_host_name);
					if(is_authorized_for_host(temp_host, &current_authdata) == FALSE)
						display_line = FALSE;

					}
				else {
					temp_service = find_service(entry_host_name, entry_service_desc);
					if(is_authorized_for_service(temp_service, &current_authdata) == FALSE)
						display_line = FALSE;
					}
				}

			/* display the entry if we should... */
			if(display_line == TRUE) {

				if(strcmp(last_message_date, current_message_date) != 0 && display_timebreaks == TRUE) {
					printf("</DIV><BR CLEAR='all' />\n");
					printf("<DIV CLASS='dateTimeBreak'>\n");
					printf("<table border=0 width=95%%><tr>");
					printf("<td width=40%%><hr width=100%%></td>");
					printf("<td align=center CLASS='dateTimeBreak'>%s</td>", current_message_date);
					printf("<td width=40%%><hr width=100%%></td>");
					printf("</tr></table>\n");
					printf("</DIV>\n");
					printf("<BR CLEAR='all' /><DIV CLASS='logEntries'>\n");
					strncpy(last_message_date, current_message_date, sizeof(last_message_date));
					last_message_date[sizeof(last_message_date) - 1] = '\x0';
					}

				if(display_frills == TRUE)
					printf("<img align='left' src='%s%s' alt='%s' title='%s' />", url_images_path, image, image_alt, image_alt);
				printf("[%s] %s", date_time, html_encode(temp_buffer, FALSE));
				if(enable_splunk_integration == TRUE) {
					printf("&nbsp;&nbsp;&nbsp;");
					display_splunk_generic_url(temp_buffer, 2);
					}
				printf("<br clear='all' />\n");

				found_line = TRUE;
				}
			}

		/* free memory */
		free(entry_host_name);
		entry_host_name = NULL;
		free(entry_service_desc);
		entry_service_desc = NULL;
		}

	printf("</DIV></P>\n");

	if(found_line == FALSE) {
		printf("<HR>\n");
		printf("<P><DIV CLASS='warningMessage'>No history information was found ");
		if(display_type == DISPLAY_HOSTS)
			printf("%s", (show_all_hosts == TRUE) ? "" : "for this host ");
		else
			printf("for this service ");
		printf("in %s log file</DIV></P>", (log_archive == 0) ? "the current" : "this archived");
		}

	printf("<HR>\n");

	my_free(input);
	my_free(input2);

	if(use_lifo == TRUE)
		free_lifo_memory();
	else
		mmap_fclose(thefile);

	return;
	}
コード例 #4
0
ファイル: showlog.c プロジェクト: hornet2001/icinga
void display_logentries() {
	char image[MAX_INPUT_BUFFER];
	char image_alt[MAX_INPUT_BUFFER];
	char last_message_date[MAX_INPUT_BUFFER] = "";
	char current_message_date[MAX_INPUT_BUFFER] = "";
	char date_time[MAX_DATETIME_LENGTH];
	char *error_text = NULL;
	int status = READLOG_OK;
	int i = 0;
	int user_has_seen_something = FALSE;
	int json_start = TRUE;
	int total_entries = 0;
	int displayed_entries = 0;
	struct tm *time_ptr = NULL;
	logentry *entry_list = NULL;
	logentry *temp_entry = NULL;
	logfilter *filter_list = NULL;


	/* Add default filters */
	if (showlog_initial_states == FALSE) {
		add_log_filter(&filter_list, LOGENTRY_SERVICE_INITIAL_STATE, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_INITIAL_STATE, LOGFILTER_EXCLUDE);
	}
	if (showlog_current_states == FALSE) {
		add_log_filter(&filter_list, LOGENTRY_SERVICE_CURRENT_STATE, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_CURRENT_STATE, LOGFILTER_EXCLUDE);
	}

	/* Add requested filters */
	if (show_notifications == FALSE) {
		add_log_filter(&filter_list, LOGENTRY_HOST_NOTIFICATION, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SERVICE_NOTIFICATION, LOGFILTER_EXCLUDE);
	}
	if (show_host_status == FALSE) {
		add_log_filter(&filter_list, LOGENTRY_HOST_UP, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_DOWN, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_UNREACHABLE, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_RECOVERY, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_PASSIVE_HOST_CHECK, LOGFILTER_EXCLUDE);
	}
	if (show_service_status == FALSE) {
		add_log_filter(&filter_list, LOGENTRY_SERVICE_OK, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SERVICE_WARNING, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SERVICE_CRITICAL, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SERVICE_UNKNOWN, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SERVICE_RECOVERY, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_PASSIVE_SERVICE_CHECK, LOGFILTER_EXCLUDE);
	}
	if (show_external_commands == FALSE)
		add_log_filter(&filter_list, LOGENTRY_EXTERNAL_COMMAND, LOGFILTER_EXCLUDE);

	if (show_system_messages == FALSE) {
		add_log_filter(&filter_list, LOGENTRY_SYSTEM_WARNING, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_STARTUP, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SHUTDOWN, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_BAILOUT, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_RESTART, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_LOG_ROTATION, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_AUTOSAVE, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_IDOMOD, LOGFILTER_EXCLUDE);
	}
	if (show_event_handler == FALSE) {
		add_log_filter(&filter_list, LOGENTRY_SERVICE_EVENT_HANDLER, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_EVENT_HANDLER, LOGFILTER_EXCLUDE);
	}
	if (show_flapping == FALSE) {
		add_log_filter(&filter_list, LOGENTRY_SERVICE_FLAPPING_STARTED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SERVICE_FLAPPING_STOPPED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SERVICE_FLAPPING_DISABLED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_FLAPPING_STARTED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_FLAPPING_STOPPED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_FLAPPING_DISABLED, LOGFILTER_EXCLUDE);
	}
	if (show_downtime == FALSE) {
		add_log_filter(&filter_list, LOGENTRY_SERVICE_DOWNTIME_STARTED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SERVICE_DOWNTIME_STOPPED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_SERVICE_DOWNTIME_CANCELLED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_DOWNTIME_STARTED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_DOWNTIME_STOPPED, LOGFILTER_EXCLUDE);
		add_log_filter(&filter_list, LOGENTRY_HOST_DOWNTIME_CANCELLED, LOGFILTER_EXCLUDE);
	}

	/* scan the log file for archived state data */
	status = get_log_entries(&entry_list, &filter_list, &error_text, query_string, reverse, ts_start, ts_end);

	free_log_filters(&filter_list);


	/* dealing with errors */
	if (status == READLOG_ERROR_WARNING) {
		if (error_text != NULL) {
			print_generic_error_message(error_text, NULL, 0);
			my_free(error_text);
		} else
			print_generic_error_message("Unkown error!", NULL, 0);
	}

	if (status == READLOG_ERROR_MEMORY)
			print_generic_error_message("Out of memory...", "showing all I could get!", 0);


	if (status == READLOG_ERROR_FATAL) {
		if (error_text != NULL) {
			print_generic_error_message(error_text, NULL, 0);
			my_free(error_text);
		}
		user_has_seen_something = TRUE;

	/* now we start displaying the log entries */
	} else {

		if (content_type == JSON_CONTENT) {
			display_timebreaks = FALSE;
			if (status != READLOG_OK)
				printf(",\n");
			printf("\"log_entries\": [\n");
		} else if (content_type == CSV_CONTENT) {
			display_timebreaks = FALSE;

			printf("%sTimestamp%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
			printf("%sDate Time%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
			printf("%sLog Entry%s\n", csv_data_enclosure, csv_data_enclosure);

		} else {
			/* add export to csv, json, link */
			printf("<table width='100%%' cellspacing=0 cellpadding=0 border=0><tr><td width='33%%'></td><td width='33%%' align=center nowrap>");
			printf("<div class='page_selector' id='log_page_selector'>\n");
			printf("<div id='page_navigation_copy'></div>");
			page_limit_selector(result_start);
			printf("</div>\n");
			printf("</td><td width='33%%' align='right'>\n");
			printf("<div class='csv_export_link' style='margin-right:1em;'>");
			print_export_link(CSV_CONTENT, SHOWLOG_CGI, NULL);
			print_export_link(JSON_CONTENT, SHOWLOG_CGI, NULL);
			print_export_link(HTML_CONTENT, SHOWLOG_CGI, NULL);
			printf("</div></td></tr></table>");
			printf("</div>\n");

			printf("<DIV CLASS='logEntries'>\n");
		}

		for (temp_entry = entry_list; temp_entry != NULL; temp_entry = temp_entry->next) {

			if (result_limit != 0  && (((total_entries + 1) < result_start) || (total_entries >= ((result_start + result_limit) - 1)))) {
				total_entries++;
				continue;
			}

			total_entries++;
			displayed_entries++;

			/* set the correct icon and icon alt text for current log entry */
			if (temp_entry->type == LOGENTRY_STARTUP) {
				strcpy(image, START_ICON);
				strcpy(image_alt, START_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_SHUTDOWN || temp_entry->type == LOGENTRY_BAILOUT) {
				strcpy(image, STOP_ICON);
				strcpy(image_alt, STOP_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_RESTART) {
				strcpy(image, RESTART_ICON);
				strcpy(image_alt, RESTART_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_HOST_DOWN) {
				strcpy(image, HOST_DOWN_ICON);
				strcpy(image_alt, HOST_DOWN_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_HOST_UNREACHABLE) {
				strcpy(image, HOST_UNREACHABLE_ICON);
				strcpy(image_alt, HOST_UNREACHABLE_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_HOST_RECOVERY || temp_entry->type == LOGENTRY_HOST_UP) {
				strcpy(image, HOST_UP_ICON);
				strcpy(image_alt, HOST_UP_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_HOST_NOTIFICATION) {
				strcpy(image, HOST_NOTIFICATION_ICON);
				strcpy(image_alt, HOST_NOTIFICATION_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_SERVICE_CRITICAL) {
				strcpy(image, CRITICAL_ICON);
				strcpy(image_alt, CRITICAL_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_SERVICE_WARNING) {
				strcpy(image, WARNING_ICON);
				strcpy(image_alt, WARNING_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_SERVICE_UNKNOWN) {
				strcpy(image, UNKNOWN_ICON);
				strcpy(image_alt, UNKNOWN_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_SERVICE_RECOVERY || temp_entry->type == LOGENTRY_SERVICE_OK) {
				strcpy(image, OK_ICON);
				strcpy(image_alt, OK_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_SERVICE_NOTIFICATION) {
				strcpy(image, NOTIFICATION_ICON);
				strcpy(image_alt, NOTIFICATION_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_SERVICE_EVENT_HANDLER) {
				strcpy(image, SERVICE_EVENT_ICON);
				strcpy(image_alt, SERVICE_EVENT_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_HOST_EVENT_HANDLER) {
				strcpy(image, HOST_EVENT_ICON);
				strcpy(image_alt, HOST_EVENT_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_EXTERNAL_COMMAND) {
				strcpy(image, EXTERNAL_COMMAND_ICON);
				strcpy(image_alt, EXTERNAL_COMMAND_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_PASSIVE_SERVICE_CHECK) {
				strcpy(image, PASSIVE_ICON);
				strcpy(image_alt, "Passive Service Check");
			} else if (temp_entry->type == LOGENTRY_PASSIVE_HOST_CHECK) {
				strcpy(image, PASSIVE_ICON);
				strcpy(image_alt, "Passive Host Check");
			} else if (temp_entry->type == LOGENTRY_LOG_ROTATION) {
				strcpy(image, LOG_ROTATION_ICON);
				strcpy(image_alt, LOG_ROTATION_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_ACTIVE_MODE) {
				strcpy(image, ACTIVE_ICON);
				strcpy(image_alt, ACTIVE_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_STANDBY_MODE) {
				strcpy(image, STANDBY_ICON);
				strcpy(image_alt, STANDBY_ICON_ALT);
			} else if (temp_entry->type == LOGENTRY_SERVICE_FLAPPING_STARTED) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Service started flapping");
			} else if (temp_entry->type == LOGENTRY_SERVICE_FLAPPING_STOPPED) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Service stopped flapping");
			} else if (temp_entry->type == LOGENTRY_SERVICE_FLAPPING_DISABLED) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Service flap detection disabled");
			} else if (temp_entry->type == LOGENTRY_HOST_FLAPPING_STARTED) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Host started flapping");
			} else if (temp_entry->type == LOGENTRY_HOST_FLAPPING_STOPPED) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Host stopped flapping");
			} else if (temp_entry->type == LOGENTRY_HOST_FLAPPING_DISABLED) {
				strcpy(image, FLAPPING_ICON);
				strcpy(image_alt, "Host flap detection disabled");
			} else if (temp_entry->type == LOGENTRY_SERVICE_DOWNTIME_STARTED) {
				strcpy(image, DOWNTIME_ICON);
				strcpy(image_alt, "Service entered a period of scheduled downtime");
			} else if (temp_entry->type == LOGENTRY_SERVICE_DOWNTIME_STOPPED) {
				strcpy(image, DOWNTIME_ICON);
				strcpy(image_alt, "Service exited a period of scheduled downtime");
			} else if (temp_entry->type == LOGENTRY_SERVICE_DOWNTIME_CANCELLED) {
				strcpy(image, DOWNTIME_ICON);
				strcpy(image_alt, "Service scheduled downtime has been cancelled");
			} else if (temp_entry->type == LOGENTRY_HOST_DOWNTIME_STARTED) {
				strcpy(image, DOWNTIME_ICON);
				strcpy(image_alt, "Host entered a period of scheduled downtime");
			} else if (temp_entry->type == LOGENTRY_HOST_DOWNTIME_STOPPED) {
				strcpy(image, DOWNTIME_ICON);
				strcpy(image_alt, "Host exited a period of scheduled downtime");
			} else if (temp_entry->type == LOGENTRY_HOST_DOWNTIME_CANCELLED) {
				strcpy(image, DOWNTIME_ICON);
				strcpy(image_alt, "Host scheduled downtime has been cancelled");
			} else if (temp_entry->type == LOGENTRY_IDOMOD) {
				strcpy(image, DATABASE_ICON);
				strcpy(image_alt, "IDOMOD Information");
			} else if (temp_entry->type == LOGENTRY_NPCDMOD) {
				strcpy(image, STATS_ICON);
				strcpy(image_alt, "NPCDMOD Information");
			} else if (temp_entry->type == LOGENTRY_AUTOSAVE) {
				strcpy(image, AUTOSAVE_ICON);
				strcpy(image_alt, "Auto-save retention data");
			} else if (temp_entry->type == LOGENTRY_SYSTEM_WARNING) {
				strcpy(image, DAEMON_WARNING_ICON);
				strcpy(image_alt, "Icinga warning message");
			} else {
				strcpy(image, INFO_ICON);
				strcpy(image_alt, INFO_ICON_ALT);
			}

			time_ptr = localtime(&temp_entry->timestamp);
			strftime(current_message_date, sizeof(current_message_date), "%B %d, %Y %H:00", time_ptr);
			current_message_date[sizeof(current_message_date) - 1] = '\x0';

			if (strcmp(last_message_date, current_message_date) != 0 && display_timebreaks == TRUE) {
				printf("</DIV>\n");
				printf("<BR>\n");
				printf("<DIV>\n");
				printf("<table border=0 width=99%% CLASS='dateTimeBreak' align=center><tr>");
				printf("<td width=40%%><hr width=100%%></td>");
				printf("<td align=center CLASS='dateTimeBreak'>%s</td>", current_message_date);
				printf("<td width=40%%><hr width=100%%></td>");
				printf("</tr></table>\n");
				printf("</DIV>\n");
				printf("<BR><DIV CLASS='logEntries'>\n");
				strncpy(last_message_date, current_message_date, sizeof(last_message_date));
				last_message_date[sizeof(last_message_date) - 1] = '\x0';
			}

			get_time_string(&temp_entry->timestamp, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
			strip(date_time);

			/* preparing logentries for json and csv output */
			if (content_type == CSV_CONTENT || content_type == JSON_CONTENT) {
				for (i = 0; i < strlen(temp_entry->entry_text) - 1; i++)
					*(temp_entry->entry_text + i) = *(temp_entry->entry_text + i + 1);
				temp_entry->entry_text[strlen(temp_entry->entry_text) - 1] = '\x0';
			}

			/* displays log entry depending on requested content type */
			if (content_type == JSON_CONTENT) {
				// always add a comma, except for the first line
				if (json_start == FALSE)
					printf(",\n");
				json_start = FALSE;
				printf("{ \"timestamp\": %lu, ", temp_entry->timestamp);
				printf(" \"date_time\": \"%s\", ", date_time);
				printf(" \"log_entry\": \"%s\"}", json_encode(temp_entry->entry_text));
			} else if (content_type == CSV_CONTENT) {
				printf("%s%lu%s%s", csv_data_enclosure, temp_entry->timestamp, csv_data_enclosure, csv_delimiter);
				printf("%s%s%s%s", csv_data_enclosure, date_time, csv_data_enclosure, csv_delimiter);
				printf("%s%s%s\n", csv_data_enclosure, temp_entry->entry_text, csv_data_enclosure);
			} else {
				if (display_frills == TRUE)
					printf("<img align=left src='%s%s' alt='%s' title='%s'>", url_images_path, image, image_alt, image_alt);
				printf("[%s] %s", date_time, (temp_entry->entry_text == NULL) ? "" : html_encode(temp_entry->entry_text, FALSE));
				if (enable_splunk_integration == TRUE) {
					printf("&nbsp;&nbsp;&nbsp;");
					display_splunk_generic_url(temp_entry->entry_text, 2);
				}
				printf("<br clear=all>\n");
			}

			user_has_seen_something = TRUE;
		}

		if (content_type != CSV_CONTENT && content_type != JSON_CONTENT) {
			if (user_has_seen_something == TRUE) {
				printf("</DIV><hr>\n");
				page_num_selector(result_start, total_entries, displayed_entries);
			} else {
				printf("<script type='text/javascript'>document.getElementById('log_page_selector').style.display='none';</script>");
			}
		} else if (content_type == JSON_CONTENT)
			printf("\n]\n");
	}

	free_log_entries(&entry_list);

	if (user_has_seen_something == FALSE && content_type != CSV_CONTENT && content_type != JSON_CONTENT)
		printf("<DIV CLASS='warningMessage'>No log entries found!</DIV>");

	return;
}