Пример #1
0
int main(int argc, char **argv) {
	int result;

	/* reset internal variables */
	reset_cgi_vars();

	/* read the CGI configuration file */
	result = read_cgi_config_file(get_cgi_config_location());
	if(result == ERROR) {
		document_header();
		return ERROR;
		}

	/* defaults from CGI config file */
	layout_method = default_statuswrl_layout_method;

	/* get the arguments passed in the URL */
	process_cgivars();

	document_header();

	/* read the main configuration file */
	result = read_main_config_file(main_config_file);
	if(result == ERROR)
		return ERROR;

	/* read all object configuration data */
	result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
	if(result == ERROR)
		return ERROR;

	/* read all status data */
	result = read_all_status_data(get_cgi_config_location(), READ_ALL_STATUS_DATA);
	if(result == ERROR) {
		free_memory();
		return ERROR;
		}

	/* get authentication information */
	get_authentication_information(&current_authdata);

	/* display the 3-D VRML world... */
	display_world();

	/* free all allocated memory */
	free_memory();

	return OK;
	}
Пример #2
0
int main(void) {
	int result = OK;

	/* get the arguments passed in the URL */
	process_cgivars();

	/* reset internal variables */
	reset_cgi_vars();

	/* read the CGI configuration file */
	result = read_cgi_config_file(get_cgi_config_location());
	if (result == ERROR) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(get_cgi_config_location(), ERROR_CGI_CFG_FILE, FALSE);
		document_footer(CGI_ID);
		free_html_request(html_request_list);
		return ERROR;
	}

	/* read the main configuration file */
	result = read_main_config_file(main_config_file);
	if (result == ERROR) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(main_config_file, ERROR_CGI_MAIN_CFG, FALSE);
		document_footer(CGI_ID);
		free_html_request(html_request_list);
		return ERROR;
	}

	/* read all object configuration data */
	result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
	if (result == ERROR) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(NULL, ERROR_CGI_OBJECT_DATA, FALSE);
		document_footer(CGI_ID);
		free_html_request(html_request_list);
		return ERROR;
	}

	/* read all status data */
	result = read_all_status_data(main_config_file, READ_ALL_STATUS_DATA);
	if (result == ERROR && daemon_check == TRUE) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(NULL, ERROR_CGI_STATUS_DATA, FALSE);
		document_footer(CGI_ID);
		free_html_request(html_request_list);
		free_memory();
		return ERROR;
	}

	document_header(CGI_ID, TRUE, "Network Outages");

	/* get authentication information */
	get_authentication_information(&current_authdata);

	if (display_header == TRUE) {

		/* begin top table */
		printf("<table border='0' width='100%%'>\n");
		printf("<tr>\n");

		/* left column of the first row */
		printf("<td align='left' valign='top' width='33%%'>\n");
		display_info_table("Network Outages", &current_authdata, daemon_check);
		printf("</td>\n");

		/* middle column of top row */
		printf("<td align='center' valign='top' width='33%%'>\n");
		printf("</td>\n");

		/* right column of top row */
		printf("<td align='right' valign='bottom' width='33%%'>\n");
		printf("</td>\n");

		/* end of top table */
		printf("</tr>\n");
		printf("</table>\n");

	}


	/* display network outage info */
	display_network_outages();

	document_footer(CGI_ID);

	/* free memory allocated to comment data */
	free_comment_data();

	/* free all allocated memory */
	free_html_request(html_request_list);
	free_memory();

	return OK;
}
Пример #3
0
/** @brief Yes we need a main function **/
int main(void) {
	char buffer[MAX_DATETIME_LENGTH];
	int result = OK;

	/* get the arguments passed in the URL */
	process_cgivars();

	/* reset internal variables */
	reset_cgi_vars();

	/* read the CGI configuration file */
	result = read_cgi_config_file(get_cgi_config_location());
	if (result == ERROR) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(get_cgi_config_location(), ERROR_CGI_CFG_FILE, FALSE);
		document_footer(CGI_ID);
		return ERROR;
	}

	/* read the main configuration file */
	result = read_main_config_file(main_config_file);
	if (result == ERROR) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(main_config_file, ERROR_CGI_MAIN_CFG, FALSE);
		document_footer(CGI_ID);
		return ERROR;
	}

	/* read all object configuration data */
	result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
	if (result == ERROR) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(NULL, ERROR_CGI_OBJECT_DATA, FALSE);
		document_footer(CGI_ID);
		return ERROR;
	}

	/* This requires the date_format parameter in the main config file */
	if (timeperiod_type == TIMEPERIOD_CUSTOM) {
		if (strcmp(start_time_string, ""))
			string_to_time(start_time_string, &ts_start);

		if (strcmp(end_time_string, ""))
			string_to_time(end_time_string, &ts_end);
	}

	/* overwrite config value with amount we got via GET */
	result_limit = (get_result_limit != -1) ? get_result_limit : result_limit;

	/* for json and csv output return all by default */
	if (get_result_limit == -1 && (content_type == JSON_CONTENT || content_type == CSV_CONTENT))
		result_limit = 0;

	document_header(CGI_ID, TRUE, "Alert Notifications");

	/* get authentication information */
	get_authentication_information(&current_authdata);

	/* calculate timestamps for reading logs */
	convert_timeperiod_to_times(timeperiod_type, &ts_start, &ts_end);

	if (display_header == TRUE) {

		/* begin top table */
		printf("<table border='0' width='100%%'>\n");
		printf("<tr>\n");

		/* left column of top row */
		printf("<td align='left' valign='top' width='33%%'>\n");

		if (query_type == DISPLAY_SERVICES)
			display_info_table("Service Notifications", &current_authdata, daemon_check);
		else if (query_type == DISPLAY_HOSTGROUPS)
			display_info_table("Hostgroup Notifications", &current_authdata, daemon_check);
		else if (query_type == DISPLAY_SERVICEGROUPS)
			display_info_table("Servicegroup Notifications", &current_authdata, daemon_check);
		else if (query_type == DISPLAY_HOSTS) {
			if (find_all == TRUE)
				display_info_table("Notifications", &current_authdata, daemon_check);
			else
				display_info_table("Host Notifications", &current_authdata, daemon_check);
		} else
			display_info_table("Contact Notifications", &current_authdata, daemon_check);

		if (query_type == DISPLAY_HOSTS || query_type == DISPLAY_SERVICES || query_type == DISPLAY_HOSTGROUPS || query_type == DISPLAY_SERVICEGROUPS) {
			printf("<table border='1' cellpadding='0' cellspacing='0' class='linkBox'>\n");
			printf("<tr><td class='linkBox'>\n");
			if (query_type == DISPLAY_HOSTS) {
				printf("<a href='%s?host=%s'>View <b>Status Detail</b> For <b>%s</b></a><br>\n", STATUS_CGI, (find_all == TRUE) ? "all" : url_encode(query_host_name), (find_all == TRUE) ? "All Hosts" : "This Host");
				printf("<a href='%s?host=%s'>View <b>Alert History</b> For <b>%s</b></a><br>\n", HISTORY_CGI, (find_all == TRUE) ? "all" : url_encode(query_host_name), (find_all == TRUE) ? "All Hosts" : "This Host");
#ifdef USE_TRENDS
				if (find_all == FALSE)
					printf("<a href='%s?host=%s'>View <b>Trends</b> For <b>This Host</b></a><br>\n", TRENDS_CGI, url_encode(query_host_name));
#endif
				printf("<a href='%s?type=%d&amp;host=%s'>View <b>Information</b> For <b>This Host</b></a><br>\n", EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(query_host_name));
				printf("<a href='%s?host=%s&amp;show_log_entries'>View <b>Availability Report</b> For <b>This Host</b></a><br>\n", AVAIL_CGI, url_encode(query_host_name));
			} else if (query_type == DISPLAY_SERVICES) {
				printf("<a href='%s?host=%s&amp;", HISTORY_CGI, (find_all == TRUE) ? "all" : url_encode(query_host_name));
				printf("service=%s'>View <b>Alert History</b> For <b>This Service</b></a><br>\n", url_encode(query_svc_description));
#ifdef USE_TRENDS
				printf("<a href='%s?host=%s&amp;", TRENDS_CGI, (find_all == TRUE) ? "all" : url_encode(query_host_name));
				printf("service=%s'>View <b>Trends</b> For <b>This Service</b></a><br>\n", url_encode(query_svc_description));
#endif
				printf("<a href='%s?type=%d&amp;host=%s&amp;service=%s'>View <b>Information</b> For <b>This Service</b></a><br>\n", EXTINFO_CGI, DISPLAY_SERVICE_INFO, url_encode(query_host_name), url_encode(query_svc_description));
				printf("<a href='%s?host=%s&amp;service=%s&amp;show_log_entries'>View <b>Availability Report</b> For <b>This Service</b></a><br>\n", AVAIL_CGI, url_encode(query_host_name), url_encode(query_svc_description));
				printf("<a href='%s?host=%s'>View <b>Notifications</b> For <b>This Host</b></a><br>\n", NOTIFICATIONS_CGI, url_encode(query_host_name));
			} else if (query_type == DISPLAY_HOSTGROUPS) {
				printf("<a href='%s?hostgroup=%s&amp;style=hostdetail'>View <b>Host Status Detail</b> For <b>This Hostgroup</b></a><br>\n", STATUS_CGI, url_encode(query_hostgroup_name));
				printf("<a href='%s?hostgroup=%s&amp;style=detail'>View <b>Service Status Detail</b> For <b>This Hostgroup</b></a><br>\n", STATUS_CGI, url_encode(query_hostgroup_name));
				printf("<a href='%s?hostgroup=%s'>View <b>Alert History</b> For <b>This Hostgroup</b></a><br>\n", HISTORY_CGI, url_encode(query_hostgroup_name));
			} else if (query_type == DISPLAY_SERVICEGROUPS) {
				printf("<a href='%s?servicegroup=%s&amp;style=hostdetail'>View <b>Host Status Detail</b> For <b>This Servicegroup</b></a><br>\n", STATUS_CGI, url_encode(query_servicegroup_name));
				printf("<a href='%s?servicegroup=%s&amp;style=detail'>View <b>Service Status Detail</b> For <b>This Servicegroup</b></a><br>\n", STATUS_CGI, url_encode(query_servicegroup_name));
				printf("<a href='%s?servicegroup=%s'>View <b>Alert History</b> For <b>This Servicegroup</b></a><br>\n", HISTORY_CGI, url_encode(query_servicegroup_name));
			}
			printf("</td></tr>\n");
			printf("</table>\n");
		}

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

		/* middle column of top row */
		printf("<td align='center' valign='top' width='33%%'>\n");

		printf("<div align='center' class='dataTitle'>\n");
		if (query_type == DISPLAY_SERVICES)
			printf("Service '%s' on Host '%s'", query_svc_description, query_host_name);
		else if (query_type == DISPLAY_HOSTS) {
			if (find_all == TRUE)
				printf("All Hosts and Services");
			else
				printf("Host '%s'", html_encode(query_host_name, TRUE));
		} else if (query_type == DISPLAY_HOSTGROUPS) {
			printf("Host Group '%s'", html_encode(query_hostgroup_name, TRUE));
		} else if (query_type == DISPLAY_SERVICEGROUPS) {
			printf("Service Group '%s'", html_encode(query_servicegroup_name, TRUE));
		} else {
			if (find_all == TRUE)
				printf("All Contacts");
			else
				printf("Contact '%s'", html_encode(query_contact_name, TRUE));
		}
		printf("</div>\n");
		printf("<br>\n");

		display_nav_table(ts_start, ts_end);

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

		/* right hand column of top row */
		printf("<td align='right' valign='top' width='33%%'>\n");

		printf("<form method='GET' action='%s'>\n", NOTIFICATIONS_CGI);
		if (query_type == DISPLAY_SERVICES) {
			printf("<input type='hidden' name='host' value='%s'>\n", escape_string(query_host_name));
			printf("<input type='hidden' name='service' value='%s'>\n", escape_string(query_svc_description));
		} else if (query_type == DISPLAY_HOSTGROUPS) {
			printf("<input type='hidden' name='hostgroup' value='%s'>\n", escape_string(query_hostgroup_name));
		} else if (query_type == DISPLAY_SERVICEGROUPS) {
			printf("<input type='hidden' name='servicegroup' value='%s'>\n", escape_string(query_servicegroup_name));
		} else
			printf("<input type='hidden' name='%s' value='%s'>\n", (query_type == DISPLAY_HOSTS) ? "host" : "contact", (query_type == DISPLAY_HOSTS) ? escape_string(query_host_name) : escape_string(query_contact_name));
		printf("<input type='hidden' name='ts_start' value='%lu'>\n", ts_start);
		printf("<input type='hidden' name='ts_end' value='%lu'>\n", ts_end);
		printf("<input type='hidden' name='limit' value='%d'>\n", result_limit);

		printf("<table border='0' class='optBox'>\n");
		printf("<tr>\n");
		if (query_type == DISPLAY_SERVICES)
			printf("<td align='left' colspan='2' class='optBoxItem'>Notification detail level for this service:</td>");
		if (query_type == DISPLAY_HOSTGROUPS || query_type == DISPLAY_SERVICEGROUPS)
			printf("<td align='left' colspan='2' class='optBoxItem'>Notification detail level for this %sgroup:</td>", (query_type == DISPLAY_HOSTGROUPS) ? "host" : "service");
		else
			printf("<td align='left' colspan='2' class='optBoxItem'>Notification detail level for %s %s%s:</td>", (find_all == TRUE) ? "all" : "this", (query_type == DISPLAY_HOSTS) ? "host" : "contact", (find_all == TRUE) ? "s" : "");
		printf("</tr>\n");
		printf("<tr><td></td>\n");
		printf("<td align='left' class='optBoxItem'><select name='type'>\n");
		printf("<option value='%d' %s>All notifications\n", NOTIFICATION_ALL, (notification_options == NOTIFICATION_ALL) ? "selected" : "");
		if (query_type != DISPLAY_SERVICES) {
			printf("<option value='%d' %s>All service notifications\n", NOTIFICATION_SERVICE_ALL, (notification_options == NOTIFICATION_SERVICE_ALL) ? "selected" : "");
			printf("<option value='%d' %s>All host notifications\n", NOTIFICATION_HOST_ALL, (notification_options == NOTIFICATION_HOST_ALL) ? "selected" : "");
		}
		printf("<option value='%d' %s>Service custom\n", NOTIFICATION_SERVICE_CUSTOM, (notification_options == NOTIFICATION_SERVICE_CUSTOM) ? "selected" : "");
		printf("<option value='%d' %s>Service acknowledgements\n", NOTIFICATION_SERVICE_ACK, (notification_options == NOTIFICATION_SERVICE_ACK) ? "selected" : "");
		printf("<option value='%d' %s>Service warning\n", NOTIFICATION_SERVICE_WARNING, (notification_options == NOTIFICATION_SERVICE_WARNING) ? "selected" : "");
		printf("<option value='%d' %s>Service unknown\n", NOTIFICATION_SERVICE_UNKNOWN, (notification_options == NOTIFICATION_SERVICE_UNKNOWN) ? "selected" : "");
		printf("<option value='%d' %s>Service critical\n", NOTIFICATION_SERVICE_CRITICAL, (notification_options == NOTIFICATION_SERVICE_CRITICAL) ? "selected" : "");
		printf("<option value='%d' %s>Service recovery\n", NOTIFICATION_SERVICE_RECOVERY, (notification_options == NOTIFICATION_SERVICE_RECOVERY) ? "selected" : "");
		printf("<option value='%d' %s>Service flapping\n", NOTIFICATION_SERVICE_FLAP, (notification_options == NOTIFICATION_SERVICE_FLAP) ? "selected" : "");
		if (query_type != DISPLAY_SERVICES) {
			printf("<option value='%d' %s>Host custom\n", NOTIFICATION_HOST_CUSTOM, (notification_options == NOTIFICATION_HOST_CUSTOM) ? "selected" : "");
			printf("<option value='%d' %s>Host acknowledgements\n", NOTIFICATION_HOST_ACK, (notification_options == NOTIFICATION_HOST_ACK) ? "selected" : "");
			printf("<option value='%d' %s>Host down\n", NOTIFICATION_HOST_DOWN, (notification_options == NOTIFICATION_HOST_DOWN) ? "selected" : "");
			printf("<option value='%d' %s>Host unreachable\n", NOTIFICATION_HOST_UNREACHABLE, (notification_options == NOTIFICATION_HOST_UNREACHABLE) ? "selected" : "");
			printf("<option value='%d' %s>Host recovery\n", NOTIFICATION_HOST_RECOVERY, (notification_options == NOTIFICATION_HOST_RECOVERY) ? "selected" : "");
			printf("<option value='%d' %s>Host flapping\n", NOTIFICATION_HOST_FLAP, (notification_options == NOTIFICATION_HOST_FLAP) ? "selected" : "");
		}
		printf("</select></td>\n");
		printf("</tr>\n");

		/* Order */
		printf("<tr><td align='right'>Order:</td>");
		printf("<td nowrap><input type='radio' name='order' value='new2old' %s> Newer Entries First&nbsp;&nbsp;| <input type='radio' name='order' value='old2new' %s> Older Entries First</td></tr>\n", (reverse == TRUE) ? "" : "checked", (reverse == TRUE) ? "checked" : "");

		/* Timeperiod */
		printf("<tr><td align='left'>Timeperiod:</td>");
		printf("<td align='left'>\n");

		printf("<select id='selecttp' name='timeperiod' onChange=\"var i=document.getElementById('selecttp').selectedIndex; if (document.getElementById('selecttp').options[i].value == 'custom') { $( '#custtime' ).toggle( 'blind', {}, 200 ); } else { $( '#custtime' ).toggle( 'blind', {}, 200 ); }\">\n");
		printf("<option value='singleday' %s>Single Day\n", (timeperiod_type == TIMEPERIOD_SINGLE_DAY) ? "selected" : "");
		printf("<option value='today' %s>Today\n", (timeperiod_type == TIMEPERIOD_TODAY) ? "selected" : "");
		printf("<option value='last24hours' %s>Last 24 Hours\n", (timeperiod_type == TIMEPERIOD_LAST24HOURS) ? "selected" : "");
		printf("<option value='thisweek' %s>This Week\n", (timeperiod_type == TIMEPERIOD_THISWEEK) ? "selected" : "");
		printf("<option value='last7days' %s>Last 7 Days\n", (timeperiod_type == TIMEPERIOD_LAST7DAYS) ? "selected" : "");
		printf("<option value='lastweek' %s>Last Week\n", (timeperiod_type == TIMEPERIOD_LASTWEEK) ? "selected" : "");
		printf("<option value='thismonth' %s>This Month\n", (timeperiod_type == TIMEPERIOD_THISMONTH) ? "selected" : "");
		printf("<option value='last31days' %s>Last 31 Days\n", (timeperiod_type == TIMEPERIOD_LAST31DAYS) ? "selected" : "");
		printf("<option value='lastmonth' %s>Last Month\n", (timeperiod_type == TIMEPERIOD_LASTMONTH) ? "selected" : "");
		printf("<option value='thisyear' %s>This Year\n", (timeperiod_type == TIMEPERIOD_THISYEAR) ? "selected" : "");
		printf("<option value='lastyear' %s>Last Year\n", (timeperiod_type == TIMEPERIOD_LASTYEAR) ? "selected" : "");
		printf("<option value='custom' %s>* CUSTOM PERIOD *\n", (timeperiod_type == TIMEPERIOD_CUSTOM) ? "selected" : "");
		printf("</select>\n");
		printf("<div id='custtime' style='display:%s;'>", (timeperiod_type == TIMEPERIOD_CUSTOM) ? "" : "none");

		printf("<br><table border='0' cellspacing='0' cellpadding='0'>\n");
		get_time_string(&ts_start, buffer, sizeof(buffer) - 1, SHORT_DATE_TIME);
		printf("<tr><td>Start:&nbsp;&nbsp;</td><td><input type='text' class='timepicker' name='start_time' value='%s' size='25'></td></tr>", buffer);

		get_time_string(&ts_end, buffer, sizeof(buffer) - 1, SHORT_DATE_TIME);
		printf("<tr><td>End:&nbsp;&nbsp;</td><td><input type='text' class='timepicker' name='end_time' value='%s' size='25'></td></tr></table></div>", buffer);

		printf("</td></tr>\n");

		/* submit Button */
		printf("<tr><td><input type='submit' value='Update'></td><td align='right'><input type='reset' value='Reset' onClick=\"window.location.href='%s?order=new2old&amp;timeperiod=singleday&amp;limit=%d'\">&nbsp;</td></tr>\n", NOTIFICATIONS_CGI, result_limit);

		printf("</table>\n");
		printf("</form>\n");

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

		/* end of top table */
		printf("</tr>\n");
		printf("</table>\n");
	}

	/* display notifications */
	display_notifications();

	/* display footer */
	document_footer(CGI_ID);

	/* free allocated memory */
	free_memory();

	return OK;
}
Пример #4
0
int main(void) {
	int result = OK;
	char temp_buffer[MAX_INPUT_BUFFER];


	/* get the CGI variables passed in the URL */
	process_cgivars();

	/* reset internal variables */
	reset_cgi_vars();

	/* read the CGI configuration file */
	result = read_cgi_config_file(get_cgi_config_location());
	if(result == ERROR) {
		document_header(FALSE);
		cgi_config_file_error(get_cgi_config_location());
		document_footer();
		return ERROR;
		}

	/* read the main configuration file */
	result = read_main_config_file(main_config_file);
	if(result == ERROR) {
		document_header(FALSE);
		main_config_file_error(main_config_file);
		document_footer();
		return ERROR;
		}

	/* read all object configuration data */
	result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
	if(result == ERROR) {
		document_header(FALSE);
		object_data_error();
		document_footer();
		return ERROR;
		}


	document_header(TRUE);

	/* get authentication information */
	get_authentication_information(&current_authdata);

	/* determine what log file we should be using */
	get_log_archive_to_use(log_archive, log_file_to_use, (int)sizeof(log_file_to_use));

	if(display_header == TRUE) {

		/* begin top table */
		printf("<table border=0 width=100%% cellpadding=0 cellspacing=0>\n");
		printf("<tr>\n");

		/* left column of top table - info box */
		printf("<td align=left valign=top width=33%%>\n");
		display_info_table((log_rotation_method == LOG_ROTATION_NONE || log_archive == 0) ? "Current Event Log" : "Archived Event Log", FALSE, &current_authdata);
		printf("</td>\n");

		/* middle column of top table - log file navigation options */
		printf("<td align=center valign=top width=33%%>\n");
		snprintf(temp_buffer, sizeof(temp_buffer) - 1, "%s?%s", SHOWLOG_CGI, (use_lifo == FALSE) ? "oldestfirst&" : "");
		temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
		display_nav_table(temp_buffer, log_archive);
		printf("</td>\n");

		/* right hand column of top row */
		printf("<td align=right valign=top width=33%%>\n");

		printf("<form method='GET' action='%s'>\n", SHOWLOG_CGI);
		printf("<input type='hidden' name='archive' value='%d'>\n", log_archive);
		printf("<table border=0 cellspacing=0 cellpadding=0 CLASS='optBox'>\n");
		printf("<tr>");
		printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='oldestfirst' %s> Older Entries First:</td>", (use_lifo == FALSE) ? "checked" : "");
		printf("</tr>\n");
		printf("<tr>");
		printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='submit' value='Update'></td>\n");
		printf("</tr>\n");

		/* display context-sensitive help */
		printf("<tr>\n");
		printf("<td align=right>\n");
		display_context_help(CONTEXTHELP_LOG);
		printf("</td>\n");
		printf("</tr>\n");

		printf("</table>\n");
		printf("</form>\n");

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

		/* end of top table */
		printf("</tr>\n");
		printf("</table>\n");
		printf("</p>\n");

		}


	/* display the contents of the log file */
	display_log();

	document_footer();

	/* free allocated memory */
	free_memory();

	return OK;
	}
Пример #5
0
/* get current authentication information */
int get_authentication_information(authdata *authinfo) {
	mmapfile *thefile;
	char *input = NULL;
	char *temp_ptr = NULL;
	contact *temp_contact = NULL;
	contactgroup *temp_contactgroup = NULL;

	if(authinfo == NULL)
		return ERROR;

	/* initial values... */
	authinfo->authorized_for_all_hosts = FALSE;
	authinfo->authorized_for_all_host_commands = FALSE;
	authinfo->authorized_for_all_services = FALSE;
	authinfo->authorized_for_all_service_commands = FALSE;
	authinfo->authorized_for_system_information = FALSE;
	authinfo->authorized_for_system_commands = FALSE;
	authinfo->authorized_for_configuration_information = FALSE;
	authinfo->authorized_for_read_only = FALSE;
	authinfo->locale_lang_path="";
	authinfo->locale_lang_user_lang="";

	/* grab username from the environment... */
	if(use_ssl_authentication) {
		/* patch by Pawl Zuzelski - 7/22/08 */
		temp_ptr = getenv("SSL_CLIENT_S_DN_CN");
		}
	else {
		temp_ptr = getenv("REMOTE_USER");
		}
	if(temp_ptr == NULL) {
		authinfo->username = "";
		authinfo->authenticated = FALSE;
		}
	else {
		authinfo->username = (char *)malloc(strlen(temp_ptr) + 1);
		if(authinfo->username == NULL)
			authinfo->username = "";
		else
			strcpy(authinfo->username, temp_ptr);
		if(!strcmp(authinfo->username, ""))
			authinfo->authenticated = FALSE;
		else
			authinfo->authenticated = TRUE;
		}

	/* read in authorization override vars from config file... */
	if((thefile = mmap_fopen(get_cgi_config_location())) != NULL) {

		while(1) {

			/* free memory */
			free(input);

			/* read the next line */
			if((input = mmap_fgets_multiline(thefile)) == NULL)
				break;

			strip(input);

			/* we don't have a username yet, so fake the authentication if we find a default username defined */
			if(!strcmp(authinfo->username, "") && strstr(input, "default_user_name=") == input) {
				temp_ptr = strtok(input, "=");
				temp_ptr = strtok(NULL, ",");
				authinfo->username = (char *)malloc(strlen(temp_ptr) + 1);
				if(authinfo->username == NULL)
					authinfo->username = "";
				else
					strcpy(authinfo->username, temp_ptr);
				if(!strcmp(authinfo->username, ""))
					authinfo->authenticated = FALSE;
				else
					authinfo->authenticated = TRUE;
				}

			else if(strstr(input, "authorized_for_all_hosts=") == input) {
				temp_ptr = strtok(input, "=");
				while((temp_ptr = strtok(NULL, ","))) {
					if(!strcmp(temp_ptr, authinfo->username) || !strcmp(temp_ptr, "*"))
						authinfo->authorized_for_all_hosts = TRUE;
					}
				}
			else if(strstr(input, "authorized_for_all_services=") == input) {
				temp_ptr = strtok(input, "=");
				while((temp_ptr = strtok(NULL, ","))) {
					if(!strcmp(temp_ptr, authinfo->username) || !strcmp(temp_ptr, "*"))
						authinfo->authorized_for_all_services = TRUE;
					}
				}
			else if(strstr(input, "authorized_for_system_information=") == input) {
				temp_ptr = strtok(input, "=");
				while((temp_ptr = strtok(NULL, ","))) {
					if(!strcmp(temp_ptr, authinfo->username) || !strcmp(temp_ptr, "*"))
						authinfo->authorized_for_system_information = TRUE;
					}
				}
			else if(strstr(input, "authorized_for_configuration_information=") == input) {
				temp_ptr = strtok(input, "=");
				while((temp_ptr = strtok(NULL, ","))) {
					if(!strcmp(temp_ptr, authinfo->username) || !strcmp(temp_ptr, "*"))
						authinfo->authorized_for_configuration_information = TRUE;
					}
				}
			else if(strstr(input, "authorized_for_all_host_commands=") == input) {
				temp_ptr = strtok(input, "=");
				while((temp_ptr = strtok(NULL, ","))) {
					if(!strcmp(temp_ptr, authinfo->username) || !strcmp(temp_ptr, "*"))
						authinfo->authorized_for_all_host_commands = TRUE;
					}
				}
			else if(strstr(input, "authorized_for_all_service_commands=") == input) {
				temp_ptr = strtok(input, "=");
				while((temp_ptr = strtok(NULL, ","))) {
					if(!strcmp(temp_ptr, authinfo->username) || !strcmp(temp_ptr, "*"))
						authinfo->authorized_for_all_service_commands = TRUE;
					}
				}
			else if(strstr(input, "authorized_for_system_commands=") == input) {
				temp_ptr = strtok(input, "=");
				while((temp_ptr = strtok(NULL, ","))) {
					if(!strcmp(temp_ptr, authinfo->username) || !strcmp(temp_ptr, "*"))
						authinfo->authorized_for_system_commands = TRUE;
					}
				}
			else if(strstr(input, "authorized_for_read_only=") == input) {
				temp_ptr = strtok(input, "=");
				while((temp_ptr = strtok(NULL, ","))) {
					if(!strcmp(temp_ptr, authinfo->username) || !strcmp(temp_ptr, "*"))
						authinfo->authorized_for_read_only = TRUE;
					}
				}
			else if((temp_contact = find_contact(authinfo->username)) != NULL) {
				if(strstr(input, "authorized_contactgroup_for_all_hosts=") == input) {
					temp_ptr = strtok(input, "=");
					while((temp_ptr = strtok(NULL, ","))) {
						temp_contactgroup = find_contactgroup(temp_ptr);
						if(is_contact_member_of_contactgroup(temp_contactgroup, temp_contact))
							authinfo->authorized_for_all_hosts = TRUE;
						}
					}
				else if(strstr(input, "authorized_contactgroup_for_all_services=") == input) {
					temp_ptr = strtok(input, "=");
					while((temp_ptr = strtok(NULL, ","))) {
						temp_contactgroup = find_contactgroup(temp_ptr);
						if(is_contact_member_of_contactgroup(temp_contactgroup, temp_contact))
							authinfo->authorized_for_all_services = TRUE;
						}
					}
				else if(strstr(input, "authorized_contactgroup_for_system_information=") == input) {
					temp_ptr = strtok(input, "=");
					while((temp_ptr = strtok(NULL, ","))) {
						temp_contactgroup = find_contactgroup(temp_ptr);
						if(is_contact_member_of_contactgroup(temp_contactgroup, temp_contact))
							authinfo->authorized_for_system_information = TRUE;
						}
					}
				else if(strstr(input, "authorized_contactgroup_for_configuration_information=") == input) {
					temp_ptr = strtok(input, "=");
					while((temp_ptr = strtok(NULL, ","))) {
						temp_contactgroup = find_contactgroup(temp_ptr);
						if(is_contact_member_of_contactgroup(temp_contactgroup, temp_contact))
							authinfo->authorized_for_configuration_information = TRUE;
						}
					}
				else if(strstr(input, "authorized_contactgroup_for_all_host_commands=") == input) {
					temp_ptr = strtok(input, "=");
					while((temp_ptr = strtok(NULL, ","))) {
						temp_contactgroup = find_contactgroup(temp_ptr);
						if(is_contact_member_of_contactgroup(temp_contactgroup, temp_contact))
							authinfo->authorized_for_all_host_commands = TRUE;
						}
					}
				else if(strstr(input, "authorized_contactgroup_for_all_service_commands=") == input) {
					temp_ptr = strtok(input, "=");
					while((temp_ptr = strtok(NULL, ","))) {
						temp_contactgroup = find_contactgroup(temp_ptr);
						if(is_contact_member_of_contactgroup(temp_contactgroup, temp_contact))
							authinfo->authorized_for_all_service_commands = TRUE;
						}
					}
				else if(strstr(input, "authorized_contactgroup_for_system_commands=") == input) {
					temp_ptr = strtok(input, "=");
					while((temp_ptr = strtok(NULL, ","))) {
						temp_contactgroup = find_contactgroup(temp_ptr);
						if(is_contact_member_of_contactgroup(temp_contactgroup, temp_contact))
							authinfo->authorized_for_system_commands = TRUE;
						}
					}
				else if(strstr(input, "authorized_contactgroup_for_read_only=") == input) {
					temp_ptr = strtok(input, "=");
					while((temp_ptr = strtok(NULL, ","))) {
						temp_contactgroup = find_contactgroup(temp_ptr);
						if(is_contact_member_of_contactgroup(temp_contactgroup, temp_contact))
							authinfo->authorized_for_read_only = TRUE;
						}
					}
				}else if(strstr(input, "locale_lang_path=") == input) {
					temp_ptr = strtok(input, "=");
					temp_ptr = strtok(NULL, "=");
					if(temp_ptr)
					{
						authinfo->locale_lang_path = (char*) malloc(strlen(temp_ptr)+1);
						strcpy(authinfo->locale_lang_path, temp_ptr);
					}else{
						authinfo->locale_lang_path="";
					}
				}else if(strstr(input, "locale_lang_user="******",");
					lang += strlen(authinfo->username) + 1;
					
					authinfo->locale_lang_user_lang = (char*) malloc(strlen(lang) + 1);
					strcpy(authinfo->locale_lang_user_lang, lang);
				}
			}

		/* free memory and close the file */
		free(input);
		mmap_fclose(thefile);
		}
	setlocale(LC_ALL,authinfo->locale_lang_user_lang);
	bindtextdomain("nagios-plugins",authinfo->locale_lang_path);
	
	//setlocale(LC_ALL,"zh_CN");
	//bindtextdomain("nagios-plugins","/usr/local/nagios/share/locale");
	textdomain("nagios-plugins");
	
	if(authinfo->authenticated == TRUE)
		return OK;
	else
		return ERROR;
		
	}
Пример #6
0
int main(void) {
	int result = OK;

	/* get the arguments passed in the URL */
	process_cgivars();

	/* reset internal variables */
	reset_cgi_vars();

	document_header();

	/* validate arguments in URL */
	result = validate_arguments();
	if(result == ERROR) {
		document_footer();
		return ERROR;
		}

	/* read the CGI configuration file */
	result = read_cgi_config_file(get_cgi_config_location());
	if(result == ERROR) {
		printf("<P>Error: Could not open CGI configuration file '%s' for reading!</P>\n", get_cgi_config_location());
		document_footer();
		return ERROR;
		}

	/* read the main configuration file */
	result = read_main_config_file(main_config_file);
	if(result == ERROR) {
		printf("<P>Error: Could not open main configuration file '%s' for reading!</P>\n", main_config_file);
		document_footer();
		return ERROR;
		}

	/* read all object configuration data */
	result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
	if(result == ERROR) {
		printf("<P>Error: Could not read some or all object configuration data!</P>\n");
		document_footer();
		return ERROR;
		}

	/* read all status data */
	result = read_all_status_data(get_cgi_config_location(), READ_ALL_STATUS_DATA);
	if(result == ERROR) {
		printf("<P>Error: Could not read host and service status information!</P>\n");
		document_footer();
		free_memory();
		return ERROR;
		}

	/* get authentication information */
	get_authentication_information(&current_authdata);

	/* decide what to display to the user */
	if(display_type == DISPLAY_HOST && host_style == DISPLAY_HOST_SERVICES)
		display_host_services();
	else if(display_type == DISPLAY_HOST)
		display_host();
	else if(display_type == DISPLAY_SERVICE)
		display_service();
	else if(display_type == DISPLAY_HOSTGROUP && hostgroup_style == DISPLAY_HOSTGROUP_OVERVIEW)
		display_hostgroup_overview();
	else if(display_type == DISPLAY_HOSTGROUP && hostgroup_style == DISPLAY_HOSTGROUP_SUMMARY)
		display_hostgroup_summary();
	else if(display_type == DISPLAY_PING)
		display_ping();
	else if(display_type == DISPLAY_TRACEROUTE)
		display_traceroute();
	else if(display_type == DISPLAY_QUICKSTATS)
		display_quick_stats();
	else if(display_type == DISPLAY_PROCESS)
		display_process();
	else if(display_type == DISPLAY_ALL_PROBLEMS || display_type == DISPLAY_UNHANDLED_PROBLEMS)
		display_problems();
	else
		display_index();

	document_footer();

	/* free all allocated memory */
	free_memory();

	return OK;
	}
Пример #7
0
int main(void) {
	int result = OK;
	char temp_buffer[MAX_INPUT_BUFFER];
	char temp_buffer2[MAX_INPUT_BUFFER];

	/* get the variables passed to us */
	process_cgivars();

	/* reset internal CGI variables */
	reset_cgi_vars();

	/* read the CGI configuration file */
	result = read_cgi_config_file(get_cgi_config_location());
	if(result == ERROR) {
		document_header(FALSE);
		cgi_config_file_error(get_cgi_config_location());
		document_footer();
		return ERROR;
		}

	/* read the main configuration file */
	result = read_main_config_file(main_config_file);
	if(result == ERROR) {
		document_header(FALSE);
		main_config_file_error(main_config_file);
		document_footer();
		return ERROR;
		}

	/* read all object configuration data */
	result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
	if(result == ERROR) {
		document_header(FALSE);
		object_data_error();
		document_footer();
		return ERROR;
		}

	document_header(TRUE);

	/* get authentication information */
	get_authentication_information(&current_authdata);

	/* determine what log file we should be using */
	get_log_archive_to_use(log_archive, log_file_to_use, (int)sizeof(log_file_to_use));

	if(display_header == TRUE) {

		/* begin top table */
		printf("<table border=0 width=100%%>\n");
		printf("<tr>\n");

		/* left column of the first row */
		printf("<td align=left valign=top width=33%%>\n");

		if(display_type == DISPLAY_SERVICES)
			snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Service Alert History");
		else if(show_all_hosts == TRUE)
			snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Alert History");
		else
			snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Host Alert History");
		temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
		display_info_table(temp_buffer, FALSE, &current_authdata);

		printf("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 CLASS='linkBox'>\n");
		printf("<TR><TD CLASS='linkBox'>\n");
		if(display_type == DISPLAY_HOSTS) {
			printf("<A HREF='%s?host=%s'>View Status Detail For %s</A><BR />\n", STATUS_CGI, (show_all_hosts == TRUE) ? "all" : url_encode(host_name), (show_all_hosts == TRUE) ? "All Hosts" : "This Host");
			printf("<A HREF='%s?host=%s'>View Notifications For %s</A><BR />\n", NOTIFICATIONS_CGI, (show_all_hosts == TRUE) ? "all" : url_encode(host_name), (show_all_hosts == TRUE) ? "All Hosts" : "This Host");
#ifdef USE_TRENDS
			if(show_all_hosts == FALSE)
				printf("<A HREF='%s?host=%s'>View Trends For This Host</A>\n", TRENDS_CGI, url_encode(host_name));
#endif
			}
		else {
			printf("<A HREF='%s?host=%s&", NOTIFICATIONS_CGI, url_encode(host_name));
			printf("service=%s'>View Notifications For This Service</A><BR />\n", url_encode(svc_description));
#ifdef USE_TRENDS
			printf("<A HREF='%s?host=%s&", TRENDS_CGI, url_encode(host_name));
			printf("service=%s'>View Trends For This Service</A><BR />\n", url_encode(svc_description));
#endif
			printf("<A HREF='%s?host=%s'>View History For This Host</A>\n", HISTORY_CGI, url_encode(host_name));
			}
		printf("</TD></TR>\n");
		printf("</TABLE>\n");

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


		/* middle column of top row */
		printf("<td align=center valign=top width=33%%>\n");

		printf("<DIV ALIGN=CENTER CLASS='dataTitle'>\n");
		if(display_type == DISPLAY_SERVICES)
			printf("Service '%s' On Host '%s'", svc_description, host_name);
		else if(show_all_hosts == TRUE)
			printf("All Hosts and Services");
		else
			printf("Host '%s'", host_name);
		printf("</DIV>\n");
		printf("<BR />\n");

		snprintf(temp_buffer, sizeof(temp_buffer) - 1, "%s?%shost=%s&type=%d&statetype=%d&", HISTORY_CGI, (use_lifo == FALSE) ? "oldestfirst&" : "", url_encode(host_name), history_options, state_options);
		temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
		if(display_type == DISPLAY_SERVICES) {
			snprintf(temp_buffer2, sizeof(temp_buffer2) - 1, "service=%s&", url_encode(svc_description));
			temp_buffer2[sizeof(temp_buffer2) - 1] = '\x0';
			strncat(temp_buffer, temp_buffer2, sizeof(temp_buffer) - strlen(temp_buffer) - 1);
			temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
			}
		display_nav_table(temp_buffer, log_archive);

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


		/* right hand column of top row */
		printf("<td align=right valign=top width=33%%>\n");

		printf("<form method=\"GET\" action=\"%s\">\n", HISTORY_CGI);
		printf("<table border=0 CLASS='optBox'>\n");
		printf("<input type='hidden' name='host' value='%s'>\n", (show_all_hosts == TRUE) ? "all" : escape_string(host_name));
		if(display_type == DISPLAY_SERVICES)
			printf("<input type='hidden' name='service' value='%s'>\n", escape_string(svc_description));
		printf("<input type='hidden' name='archive' value='%d'>\n", log_archive);

		printf("<tr>\n");
		printf("<td align=left CLASS='optBoxItem'>State type options:</td>\n");
		printf("</tr>\n");

		printf("<tr>\n");
		printf("<td align=left CLASS='optBoxItem'><select name='statetype'>\n");
		printf("<option value=%d %s>All state types</option>\n", STATE_ALL, (state_options == STATE_ALL) ? "selected" : "");
		printf("<option value=%d %s>Soft states</option>\n", STATE_SOFT, (state_options == STATE_SOFT) ? "selected" : "");
		printf("<option value=%d %s>Hard states</option>\n", STATE_HARD, (state_options == STATE_HARD) ? "selected" : "");
		printf("</select></td>\n");
		printf("</tr>\n");

		printf("<tr>\n");
		printf("<td align=left CLASS='optBoxItem'>History detail level for ");
		if(display_type == DISPLAY_HOSTS)
			printf("%s host%s", (show_all_hosts == TRUE) ? "all" : "this", (show_all_hosts == TRUE) ? "s" : "");
		else
			printf("service");
		printf(":</td>\n");
		printf("</tr>\n")
		;
		printf("<tr>\n");
		printf("<td align=left CLASS='optBoxItem'><select name='type'>\n");
		if(display_type == DISPLAY_HOSTS)
			printf("<option value=%d %s>All alerts</option>\n", HISTORY_ALL, (history_options == HISTORY_ALL) ? "selected" : "");
		printf("<option value=%d %s>All service alerts</option>\n", HISTORY_SERVICE_ALL, (history_options == HISTORY_SERVICE_ALL) ? "selected" : "");
		if(display_type == DISPLAY_HOSTS)
			printf("<option value=%d %s>All host alerts</option>\n", HISTORY_HOST_ALL, (history_options == HISTORY_HOST_ALL) ? "selected" : "");
		printf("<option value=%d %s>Service warning</option>\n", HISTORY_SERVICE_WARNING, (history_options == HISTORY_SERVICE_WARNING) ? "selected" : "");
		printf("<option value=%d %s>Service unknown</option>\n", HISTORY_SERVICE_UNKNOWN, (history_options == HISTORY_SERVICE_UNKNOWN) ? "selected" : "");
		printf("<option value=%d %s>Service critical</option>\n", HISTORY_SERVICE_CRITICAL, (history_options == HISTORY_SERVICE_CRITICAL) ? "selected" : "");
		printf("<option value=%d %s>Service recovery</option>\n", HISTORY_SERVICE_RECOVERY, (history_options == HISTORY_SERVICE_RECOVERY) ? "selected" : "");
		if(display_type == DISPLAY_HOSTS) {
			printf("<option value=%d %s>Host down</option>\n", HISTORY_HOST_DOWN, (history_options == HISTORY_HOST_DOWN) ? "selected" : "");
			printf("<option value=%d %s>Host unreachable</option>\n", HISTORY_HOST_UNREACHABLE, (history_options == HISTORY_HOST_UNREACHABLE) ? "selected" : "");
			printf("<option value=%d %s>Host recovery</option>\n", HISTORY_HOST_RECOVERY, (history_options == HISTORY_HOST_RECOVERY) ? "selected" : "");
			}
		printf("</select></td>\n");
		printf("</tr>\n");

		printf("<tr>\n");
		printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='noflapping' %s> Hide Flapping Alerts</td>", (display_flapping_alerts == FALSE) ? "checked" : "");
		printf("</tr>\n");
		printf("<tr>\n");
		printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='nodowntime' %s> Hide Downtime Alerts</td>", (display_downtime_alerts == FALSE) ? "checked" : "");
		printf("</tr>\n");

		printf("<tr>\n");
		printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='nosystem' %s> Hide Process Messages</td>", (display_system_messages == FALSE) ? "checked" : "");
		printf("</tr>\n");
		printf("<tr>\n");
		printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='oldestfirst' %s> Older Entries First</td>", (use_lifo == FALSE) ? "checked" : "");
		printf("</tr>\n");

		printf("<tr>\n");
		printf("<td align=left CLASS='optBoxItem'><input type='submit' value='Update'></td>\n");
		printf("</tr>\n");

		/* display context-sensitive help */
		printf("<tr>\n");
		printf("<td align=right>\n");
		display_context_help(CONTEXTHELP_HISTORY);
		printf("</td>\n");
		printf("</tr>\n");

		printf("</table>\n");
		printf("</form>\n");

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

		/* end of top table */
		printf("</tr>\n");
		printf("</table>\n");

		}


	/* display history */
	get_history();

	document_footer();

	/* free allocated memory */
	free_memory();

	return OK;
	}
Пример #8
0
/** @brief Yes we need a main function **/
int main(void) {
    int result = OK;

    /* get the variables passed to us */
    process_cgivars();

    /* reset internal CGI variables */
    reset_cgi_vars();

    /* read the CGI configuration file */
    result = read_cgi_config_file(get_cgi_config_location());
    if (result == ERROR) {
        document_header(CGI_ID, FALSE, "Error");
        print_error(get_cgi_config_location(), ERROR_CGI_CFG_FILE, FALSE);
        document_footer(CGI_ID);
        return ERROR;
    }

    /* read the main configuration file */
    result = read_main_config_file(main_config_file);
    if (result == ERROR) {
        document_header(CGI_ID, FALSE, "Error");
        print_error(main_config_file, ERROR_CGI_MAIN_CFG, FALSE);
        document_footer(CGI_ID);
        return ERROR;
    }

    /* read all object configuration data */
    result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
    if (result == ERROR) {
        document_header(CGI_ID, FALSE, "Error");
        print_error(NULL, ERROR_CGI_OBJECT_DATA, FALSE);
        document_footer(CGI_ID);
        return ERROR;
    }

    /* overwrite config value with amount we got via GET */
    result_limit = (get_result_limit != -1) ? get_result_limit : result_limit;

    document_header(CGI_ID, TRUE, "History");

    /* get authentication information */
    get_authentication_information(&current_authdata);

    /* calculate timestamps for reading logs */
    convert_timeperiod_to_times(TIMEPERIOD_SINGLE_DAY, &ts_start, &ts_end);

    if (display_header == TRUE) {

        /* begin top table */
        printf("<table border=0 width=100%%>\n");
        printf("<tr>\n");

        /* left column of the first row */
        printf("<td align=left valign=top width=33%%>\n");

        if (display_type == DISPLAY_HOSTS)
            display_info_table("Host Alert History", &current_authdata, daemon_check);
        else if (display_type == DISPLAY_SERVICES)
            display_info_table("Service Alert History", &current_authdata, daemon_check);
        else if (display_type == DISPLAY_HOSTGROUPS)
            display_info_table("Host Group Alert History", &current_authdata, daemon_check);
        else if (display_type == DISPLAY_SERVICEGROUPS)
            display_info_table("Service Group Alert History", &current_authdata, daemon_check);
        else
            display_info_table("Alert History", &current_authdata, daemon_check);

        printf("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 CLASS='linkBox'>\n");
        printf("<TR><TD CLASS='linkBox'>\n");
        if (display_type == DISPLAY_HOSTS) {
            printf("<a href='%s?host=%s'>View <b>Service Status Detail</b> For <b>%s</b></a><br>\n", STATUS_CGI, (show_all_hosts == TRUE) ? "all" : url_encode(host_name), (show_all_hosts == TRUE) ? "All Hosts" : "This Host");
            printf("<a href='%s?host=%s'>View <b>Notifications</b> For <b>%s</b></a><br>\n", NOTIFICATIONS_CGI, (show_all_hosts == TRUE) ? "all" : url_encode(host_name), (show_all_hosts == TRUE) ? "All Hosts" : "This Host");
            printf("<a href='%s?type=%d&host=%s'>View <b>Information</b> For <b>This Host</b></a><br>\n", EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(host_name));
#ifdef USE_TRENDS
            if (show_all_hosts == FALSE)
                printf("<a href='%s?host=%s'>View <b>Trends</b> For <b>This Host</b></a>\n", TRENDS_CGI, url_encode(host_name));
#endif
        } else if (display_type == DISPLAY_SERVICES) {
            printf("<a href='%s?host=%s&service=%s'>View <b>Notifications</b> For <b>This Service</b></a><br>\n", NOTIFICATIONS_CGI, url_encode(host_name), url_encode(service_desc));
            printf("<a href='%s?type=%d&host=%s&service=%s'>View <b>Information</b> For <b>This Service</b></a><br>\n", EXTINFO_CGI, DISPLAY_SERVICE_INFO, url_encode(host_name), url_encode(service_desc));
#ifdef USE_TRENDS
            printf("<a href='%s?host=%s&service=%s'>View <b>Trends</b> For <b>This Service</b></a><br>\n", TRENDS_CGI, url_encode(host_name), url_encode(service_desc));
#endif
            printf("<a href='%s?host=%s'>View <b>Alert History</b> For <b>This Host</b></a>\n", HISTORY_CGI, url_encode(host_name));
        } else if (display_type == DISPLAY_HOSTGROUPS) {
            printf("<a href='%s?hostgroup=%s&style=hostdetail'>View <b>Host Status Detail</b> For <b>This Hostgroup</b></a><br>\n", STATUS_CGI, url_encode(hostgroup_name));
            printf("<a href='%s?hostgroup=%s&style=detail'>View <b>Service Status Detail</b> For <b>This Hostgroup</b></a><br>\n", STATUS_CGI, url_encode(hostgroup_name));
            printf("<a href='%s?hostgroup=%s'>View <b>Notifications</b> For <b>This Hostgroup</b></a>\n", NOTIFICATIONS_CGI, url_encode(hostgroup_name));
        } else if (display_type == DISPLAY_SERVICEGROUPS) {
            printf("<a href='%s?servicegroup=%s&style=hostdetail'>View <b>Host Status Detail</b> For <b>This Servicegroup</b></a><br>\n", STATUS_CGI, url_encode(servicegroup_name));
            printf("<a href='%s?servicegroup=%s&style=detail'>View <b>Service Status Detail</b> For <b>This Servicegroup</b></a><br>\n", STATUS_CGI, url_encode(servicegroup_name));
            printf("<a href='%s?servicegroup=%s'>View <b>Notifications</b> For <b>This Servicegroup</b></a>\n", NOTIFICATIONS_CGI, url_encode(servicegroup_name));
        }
        printf("</TD></TR>\n");
        printf("</TABLE>\n");

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

        /* middle column of top row */
        printf("<td align=center valign=top width=33%%>\n");

        printf("<DIV ALIGN=CENTER CLASS='dataTitle'>\n");
        if (display_type == DISPLAY_SERVICES)
            printf("Service '%s' On Host '%s'", html_encode(service_desc, TRUE), html_encode(host_name, TRUE));
        else if (display_type == DISPLAY_HOSTS) {
            if (show_all_hosts == TRUE)
                printf("All Hosts and Services");
            else
                printf("Host '%s'", html_encode(host_name, TRUE));
        } else if (display_type == DISPLAY_HOSTGROUPS)
            printf("Host Group '%s'", html_encode(hostgroup_name, TRUE));
        else if (display_type == DISPLAY_SERVICEGROUPS)
            printf("Service Group '%s'", html_encode(servicegroup_name, TRUE));
        printf("</DIV>\n");
        printf("<BR />\n");

        display_nav_table(ts_start, ts_end);

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

        /* right hand column of top row */
        printf("<td align=right valign=top width=33%%>\n");

        printf("<form method=\"GET\" action=\"%s\">\n", HISTORY_CGI);
        printf("<input type='hidden' name='ts_start' value='%lu'>\n", ts_start);
        printf("<input type='hidden' name='ts_end' value='%lu'>\n", ts_end);
        printf("<input type='hidden' name='limit' value='%d'>\n", result_limit);

        if (display_type == DISPLAY_HOSTGROUPS)
            printf("<input type='hidden' name='hostgroup' value='%s'>\n", escape_string(hostgroup_name));
        else if (display_type == DISPLAY_SERVICEGROUPS)
            printf("<input type='hidden' name='servicegroup' value='%s'>\n", escape_string(servicegroup_name));
        else {
            printf("<input type='hidden' name='host' value='%s'>\n", (show_all_hosts == TRUE) ? "all" : escape_string(host_name));
            if (display_type == DISPLAY_SERVICES)
                printf("<input type='hidden' name='service' value='%s'>\n", escape_string(service_desc));
        }
        printf("<table border=0 CLASS='optBox'>\n");

        printf("<tr>\n");
        printf("<td align=left CLASS='optBoxItem'>State type options:</td>\n");
        printf("</tr>\n");

        printf("<tr>\n");
        printf("<td align=left CLASS='optBoxItem'><select name='statetype'>\n");
        printf("<option value=%d %s>All state types</option>\n", STATE_ALL, (state_options == STATE_ALL) ? "selected" : "");
        printf("<option value=%d %s>Soft states</option>\n", STATE_SOFT, (state_options == STATE_SOFT) ? "selected" : "");
        printf("<option value=%d %s>Hard states</option>\n", STATE_HARD, (state_options == STATE_HARD) ? "selected" : "");
        printf("</select></td>\n");
        printf("</tr>\n");

        printf("<tr>\n");
        printf("<td align=left CLASS='optBoxItem'>History detail level for ");
        if (display_type == DISPLAY_HOSTGROUPS || display_type == DISPLAY_SERVICEGROUPS)
            printf("this %sgroup", (display_type == DISPLAY_HOSTGROUPS) ? "host" : "service");
        else if (display_type == DISPLAY_HOSTS)
            printf("%s host%s", (show_all_hosts == TRUE) ? "all" : "this", (show_all_hosts == TRUE) ? "s" : "");
        else
            printf("service");
        printf(":</td>\n");
        printf("</tr>\n");
        printf("<tr>\n");
        printf("<td align=left CLASS='optBoxItem'><select name='type'>\n");
        if (display_type == DISPLAY_HOSTS || display_type == DISPLAY_HOSTGROUPS)
            printf("<option value=%d %s>All alerts</option>\n", HISTORY_ALL, (history_options == HISTORY_ALL) ? "selected" : "");
        printf("<option value=%d %s>All service alerts</option>\n", HISTORY_SERVICE_ALL, (history_options == HISTORY_SERVICE_ALL) ? "selected" : "");
        if (display_type == DISPLAY_HOSTS || display_type == DISPLAY_HOSTGROUPS)
            printf("<option value=%d %s>All host alerts</option>\n", HISTORY_HOST_ALL, (history_options == HISTORY_HOST_ALL) ? "selected" : "");
        printf("<option value=%d %s>Service warning</option>\n", HISTORY_SERVICE_WARNING, (history_options == HISTORY_SERVICE_WARNING) ? "selected" : "");
        printf("<option value=%d %s>Service unknown</option>\n", HISTORY_SERVICE_UNKNOWN, (history_options == HISTORY_SERVICE_UNKNOWN) ? "selected" : "");
        printf("<option value=%d %s>Service critical</option>\n", HISTORY_SERVICE_CRITICAL, (history_options == HISTORY_SERVICE_CRITICAL) ? "selected" : "");
        printf("<option value=%d %s>Service recovery</option>\n", HISTORY_SERVICE_RECOVERY, (history_options == HISTORY_SERVICE_RECOVERY) ? "selected" : "");
        if (display_type == DISPLAY_HOSTS || display_type == DISPLAY_HOSTGROUPS) {
            printf("<option value=%d %s>Host down</option>\n", HISTORY_HOST_DOWN, (history_options == HISTORY_HOST_DOWN) ? "selected" : "");
            printf("<option value=%d %s>Host unreachable</option>\n", HISTORY_HOST_UNREACHABLE, (history_options == HISTORY_HOST_UNREACHABLE) ? "selected" : "");
            printf("<option value=%d %s>Host recovery</option>\n", HISTORY_HOST_RECOVERY, (history_options == HISTORY_HOST_RECOVERY) ? "selected" : "");
        }
        printf("</select></td>\n");
        printf("</tr>\n");

        printf("<tr>\n");
        printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='noflapping' %s> Hide Flapping Alerts</td>", (display_flapping_alerts == FALSE) ? "checked" : "");
        printf("</tr>\n");
        printf("<tr>\n");
        printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='nodowntime' %s> Hide Downtime Alerts</td>", (display_downtime_alerts == FALSE) ? "checked" : "");
        printf("</tr>\n");

        printf("<tr>\n");
        printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='nosystem' %s> Hide Process Messages</td>", (display_system_messages == FALSE) ? "checked" : "");
        printf("</tr>\n");
        printf("<tr>\n");
        printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='order' value='old2new' %s> Older Entries First</td>", (reverse == TRUE) ? "checked" : "");
        printf("</tr>\n");

        printf("<tr>\n");
        printf("<td align=left CLASS='optBoxItem'><input type='submit' value='Update'></td>\n");
        printf("</tr>\n");

        printf("</table>\n");
        printf("</form>\n");
        printf("</td>\n");

        /* end of top table */
        printf("</tr>\n");
        printf("</table>\n");

    }

    /* display history */
    show_history();

    document_footer(CGI_ID);

    /* free allocated memory */
    free_memory();

    return OK;
}
Пример #9
0
/** @brief Yes we need a main function **/
int main(void) {
	int result = OK;

	/* get the CGI variables passed in the URL */
	process_cgivars();

	/* reset internal variables */
	reset_cgi_vars();

	/* read the CGI configuration file */
	result = read_cgi_config_file(get_cgi_config_location());
	if (result == ERROR) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(get_cgi_config_location(), ERROR_CGI_CFG_FILE, FALSE);
		document_footer(CGI_ID);
		return ERROR;
	}

	/* read the main configuration file */
	result = read_main_config_file(main_config_file);
	if (result == ERROR) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(main_config_file, ERROR_CGI_MAIN_CFG, FALSE);
		document_footer(CGI_ID);
		return ERROR;
	}

	/* read all object configuration data */
	result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
	if (result == ERROR) {
		document_header(CGI_ID, FALSE, "Error");
		print_error(NULL, ERROR_CGI_OBJECT_DATA, FALSE);
		document_footer(CGI_ID);
		return ERROR;
	}

	/* This requires the date_format parameter in the main config file */
	if (timeperiod_type == TIMEPERIOD_CUSTOM) {
		if (strcmp(start_time_string, ""))
			string_to_time(start_time_string, &ts_start);

		if (strcmp(end_time_string, ""))
			string_to_time(end_time_string, &ts_end);
	}

	/* overwrite config value with amount we got via GET */
	result_limit = (get_result_limit != -1) ? get_result_limit : result_limit;

	/* for json and csv output return all by default */
	if (get_result_limit == -1 && (content_type == JSON_CONTENT || content_type == CSV_CONTENT))
		result_limit = 0;

	document_header(CGI_ID, TRUE, "Log File");

	/* calculate timestamps for reading logs */
	convert_timeperiod_to_times(timeperiod_type, &ts_start, &ts_end);

	/* get authentication information */
	get_authentication_information(&current_authdata);

	if (display_header == TRUE) {

		/* start input form */
		printf("<form method='GET' style='margin:0;' action='%s'>\n", SHOWLOG_CGI);
		printf("<input type='hidden' name='ts_start' value='%lu'>\n", ts_start);
		printf("<input type='hidden' name='ts_end' value='%lu'>\n", ts_end);
		printf("<input type='hidden' name='limit' value='%d'>\n", result_limit);

		/* begin top table */
		printf("<table border=0 width=100%% cellpadding=0 cellspacing=0>\n");
		printf("<tr>\n");

		/* left column of top table - info box */
		printf("<td align=left valign=top width=33%%>\n");
		display_info_table("Event Log", &current_authdata, daemon_check);
		printf("</td>\n");

		/* middle column of top table - log file navigation options */
		printf("<td align=center valign=top width=33%%>\n");
		display_nav_table(ts_start, ts_end);
		printf("</td>\n");

		/* right hand column of top row */
		printf("<td align=right valign=top width=33%%>\n");

		/* show filter */
		printf("<table border=0 cellspacing=0 cellpadding=0 CLASS='optBox' align=right><tr><td>\n");
		show_filter();
		printf("</td></tr>\n");

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

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

		/* end of top table */
		printf("</tr>\n");
		printf("</table>\n");

		printf("</form>\n");
	}

	/* check to see if the user is authorized to view the log file */
	if (is_authorized_for_system_information(&current_authdata) == FALSE) {
		print_generic_error_message("It appears as though you do not have permission to view the log file...", "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 ERROR;
	}

	/* display the contents of the log file */
	display_logentries();

	document_footer(CGI_ID);

	/* free allocated memory */
	free_memory();

	return OK;
}
Пример #10
0
int main(void) {
    int result=OK;
    char temp_buffer[MAX_INPUT_BUFFER];
    char temp_buffer2[MAX_INPUT_BUFFER];


    /* get the arguments passed in the URL */
    process_cgivars();

    /* reset internal variables */
    reset_cgi_vars();

    /* read the CGI configuration file */
    result=read_cgi_config_file(get_cgi_config_location());
    if(result==ERROR) {
        document_header(FALSE);
        cgi_config_file_error(get_cgi_config_location());
        document_footer();
        return ERROR;
    }

    /* read the main configuration file */
    result=read_main_config_file(main_config_file);
    if(result==ERROR) {
        document_header(FALSE);
        main_config_file_error(main_config_file);
        document_footer();
        return ERROR;
    }

    /* read all object configuration data */
    result=read_all_object_configuration_data(main_config_file,READ_ALL_OBJECT_DATA);
    if(result==ERROR) {
        document_header(FALSE);
        object_data_error();
        document_footer();
        return ERROR;
    }


    document_header(TRUE);

    /* get authentication information */
    get_authentication_information(&current_authdata);

    /* determine what log file we should use */
    get_log_archive_to_use(log_archive,log_file_to_use,(int)sizeof(log_file_to_use));


    if(display_header==TRUE) {

        /* begin top table */
        printf("<table border=0 width=100%%>\n");
        printf("<tr>\n");

        /* left column of top row */
        printf("<td align=left valign=top width=33%%>\n");

        if(query_type==FIND_SERVICE)
            snprintf(temp_buffer,sizeof(temp_buffer)-1,"Service Notifications");
        else if(query_type==FIND_HOST) {
            if(find_all==TRUE)
                snprintf(temp_buffer,sizeof(temp_buffer)-1,"Notifications");
            else
                snprintf(temp_buffer,sizeof(temp_buffer)-1,"Host Notifications");
        }
        else
            snprintf(temp_buffer,sizeof(temp_buffer)-1,"Contact Notifications");
        display_info_table(temp_buffer,FALSE,&current_authdata);

        if(query_type==FIND_HOST || query_type==FIND_SERVICE) {
            printf("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 CLASS='linkBox'>\n");
            printf("<TR><TD CLASS='linkBox'>\n");
            if(query_type==FIND_HOST) {
                printf("<A HREF='%s?host=%s'>View Status Detail For %s</A><BR>\n",STATUS_CGI,(find_all==TRUE)?"all":url_encode(query_host_name),(find_all==TRUE)?"All Hosts":"This Host");
                printf("<A HREF='%s?host=%s'>View History For %s</A><BR>\n",HISTORY_CGI,(find_all==TRUE)?"all":url_encode(query_host_name),(find_all==TRUE)?"All Hosts":"This Host");
#ifdef USE_TRENDS
                if(find_all==FALSE)
                    printf("<A HREF='%s?host=%s'>View Trends For This Host</A><BR>\n",TRENDS_CGI,url_encode(query_host_name));
#endif
            }
            else if(query_type==FIND_SERVICE) {
                printf("<A HREF='%s?host=%s&",HISTORY_CGI,(find_all==TRUE)?"all":url_encode(query_host_name));
                printf("service=%s'>View History For This Service</A><BR>\n",url_encode(query_svc_description));
#ifdef USE_TRENDS
                printf("<A HREF='%s?host=%s&",TRENDS_CGI,(find_all==TRUE)?"all":url_encode(query_host_name));
                printf("service=%s'>View Trends For This Service</A><BR>\n",url_encode(query_svc_description));
#endif
            }
            printf("</TD></TR>\n");
            printf("</TABLE>\n");
        }

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


        /* middle column of top row */
        printf("<td align=center valign=top width=33%%>\n");

        printf("<DIV ALIGN=CENTER CLASS='dataTitle'>\n");
        if(query_type==FIND_SERVICE)
            printf("Service '%s' On Host '%s'",query_svc_description,query_host_name);
        else if(query_type==FIND_HOST) {
            if(find_all==TRUE)
                printf("All Hosts and Services");
            else
                printf("Host '%s'",query_host_name);
        }
        else {
            if(find_all==TRUE)
                printf("All Contacts");
            else
                printf("Contact '%s'",query_contact_name);
        }
        printf("</DIV>\n");
        printf("<BR>\n");

        if(query_type==FIND_SERVICE) {
            snprintf(temp_buffer,sizeof(temp_buffer)-1,"%s?%shost=%s&",NOTIFICATIONS_CGI,(use_lifo==FALSE)?"oldestfirst&":"",url_encode(query_host_name));
            snprintf(temp_buffer2,sizeof(temp_buffer2)-1,"service=%s&type=%d&",url_encode(query_svc_description),notification_options);
            strncat(temp_buffer,temp_buffer2,sizeof(temp_buffer)-strlen(temp_buffer)-1);
        }
        else
            snprintf(temp_buffer,sizeof(temp_buffer)-1,"%s?%s%s=%s&type=%d&",NOTIFICATIONS_CGI,(use_lifo==FALSE)?"oldestfirst&":"",(query_type==FIND_HOST)?"host":"contact",(query_type==FIND_HOST)?url_encode(query_host_name):url_encode(query_contact_name),notification_options);
        temp_buffer[sizeof(temp_buffer)-1]='\x0';
        display_nav_table(temp_buffer,log_archive);

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


        /* right hand column of top row */
        printf("<td align=right valign=top width=33%%>\n");

        printf("<table border=0 CLASS='optBox'>\n");
        printf("<form method='GET' action='%s'>\n",NOTIFICATIONS_CGI);
        if(query_type==FIND_SERVICE) {
            printf("<input type='hidden' name='host' value='%s'>\n",escape_string(query_host_name));
            printf("<input type='hidden' name='service' value='%s'>\n",escape_string(query_svc_description));
        }
        else
            printf("<input type='hidden' name='%s' value='%s'>\n",(query_type==FIND_HOST)?"host":"contact",(query_type==FIND_HOST)?escape_string(query_host_name):escape_string(query_contact_name));
        printf("<input type='hidden' name='archive' value='%d'>\n",log_archive);
        printf("<tr>\n");
        if(query_type==FIND_SERVICE)
            printf("<td align=left colspan=2 CLASS='optBoxItem'>Notification detail level for this service:</td>");
        else
            printf("<td align=left colspan=2 CLASS='optBoxItem'>Notification detail level for %s %s%s:</td>",(find_all==TRUE)?"all":"this",(query_type==FIND_HOST)?"host":"contact",(find_all==TRUE)?"s":"");
        printf("</tr>\n");
        printf("<tr>\n");
        printf("<td align=left colspan=2 CLASS='optBoxItem'><select name='type'>\n");
        printf("<option value=%d %s>All notifications\n",NOTIFICATION_ALL,(notification_options==NOTIFICATION_ALL)?"selected":"");
        if(query_type!=FIND_SERVICE) {
            printf("<option value=%d %s>All service notifications\n",NOTIFICATION_SERVICE_ALL,(notification_options==NOTIFICATION_SERVICE_ALL)?"selected":"");
            printf("<option value=%d %s>All host notifications\n",NOTIFICATION_HOST_ALL,(notification_options==NOTIFICATION_HOST_ALL)?"selected":"");
        }
        printf("<option value=%d %s>Service custom\n",NOTIFICATION_SERVICE_CUSTOM,(notification_options==NOTIFICATION_SERVICE_CUSTOM)?"selected":"");
        printf("<option value=%d %s>Service acknowledgements\n",NOTIFICATION_SERVICE_ACK,(notification_options==NOTIFICATION_SERVICE_ACK)?"selected":"");
        printf("<option value=%d %s>Service warning\n",NOTIFICATION_SERVICE_WARNING,(notification_options==NOTIFICATION_SERVICE_WARNING)?"selected":"");
        printf("<option value=%d %s>Service unknown\n",NOTIFICATION_SERVICE_UNKNOWN,(notification_options==NOTIFICATION_SERVICE_UNKNOWN)?"selected":"");
        printf("<option value=%d %s>Service critical\n",NOTIFICATION_SERVICE_CRITICAL,(notification_options==NOTIFICATION_SERVICE_CRITICAL)?"selected":"");
        printf("<option value=%d %s>Service recovery\n",NOTIFICATION_SERVICE_RECOVERY,(notification_options==NOTIFICATION_SERVICE_RECOVERY)?"selected":"");
        printf("<option value=%d %s>Service flapping\n",NOTIFICATION_SERVICE_FLAP,(notification_options==NOTIFICATION_SERVICE_FLAP)?"selected":"");
        if(query_type!=FIND_SERVICE) {
            printf("<option value=%d %s>Host custom\n",NOTIFICATION_HOST_CUSTOM,(notification_options==NOTIFICATION_HOST_CUSTOM)?"selected":"");
            printf("<option value=%d %s>Host acknowledgements\n",NOTIFICATION_HOST_ACK,(notification_options==NOTIFICATION_HOST_ACK)?"selected":"");
            printf("<option value=%d %s>Host down\n",NOTIFICATION_HOST_DOWN,(notification_options==NOTIFICATION_HOST_DOWN)?"selected":"");
            printf("<option value=%d %s>Host unreachable\n",NOTIFICATION_HOST_UNREACHABLE,(notification_options==NOTIFICATION_HOST_UNREACHABLE)?"selected":"");
            printf("<option value=%d %s>Host recovery\n",NOTIFICATION_HOST_RECOVERY,(notification_options==NOTIFICATION_HOST_RECOVERY)?"selected":"");
            printf("<option value=%d %s>Host flapping\n",NOTIFICATION_HOST_FLAP,(notification_options==NOTIFICATION_HOST_FLAP)?"selected":"");
        }
        printf("</select></td>\n");
        printf("</tr>\n");
        printf("<tr>\n");
        printf("<td align=left CLASS='optBoxItem'>Older Entries First:</td>\n");
        printf("<td></td>\n");
        printf("</tr>\n");
        printf("<tr>\n");
        printf("<td align=left valign=bottom CLASS='optBoxItem'><input type='checkbox' name='oldestfirst' %s></td>",(use_lifo==FALSE)?"checked":"");
        printf("<td align=right CLASS='optBoxItem'><input type='submit' value='Update'></td>\n");
        printf("</tr>\n");

        /* display context-sensitive help */
        printf("<tr><td></td><td align=right valign=bottom>\n");
        display_context_help(CONTEXTHELP_NOTIFICATIONS);
        printf("</td></tr>\n");

        printf("</form>\n");
        printf("</table>\n");

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

        /* end of top table */
        printf("</tr>\n");
        printf("</table>\n");

    }


    /* display notifications */
    display_notifications();

    document_footer();

    /* free allocated memory */
    free_memory();

    return OK;
}
Пример #11
0
int main(void) {
	int result = OK;


	/* get the arguments passed in the URL */
	process_cgivars();

	/* reset internal variables */
	reset_cgi_vars();

	/* read the CGI configuration file */
	result = read_cgi_config_file(get_cgi_config_location());
	if(result == ERROR) {
		document_header(FALSE);
		cgi_config_file_error(get_cgi_config_location());
		document_footer();
		return ERROR;
		}

	/* read the main configuration file */
	result = read_main_config_file(main_config_file);
	if(result == ERROR) {
		document_header(FALSE);
		main_config_file_error(main_config_file);
		document_footer();
		return ERROR;
		}

	/* read all object configuration data */
	result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
	if(result == ERROR) {
		document_header(FALSE);
		object_data_error();
		document_footer();
		return ERROR;
		}

	/* read all status data */
	result = read_all_status_data(get_cgi_config_location(), READ_ALL_STATUS_DATA);
	if(result == ERROR) {
		document_header(FALSE);
		status_data_error();
		document_footer();
		free_memory();
		return ERROR;
		}

	document_header(TRUE);

	/* get authentication information */
	get_authentication_information(&current_authdata);

	if(display_header == TRUE) {

		/* begin top table */
		printf("<table border=0 width=100%%>\n");
		printf("<tr>\n");

		/* left column of the first row */
		printf("<td align=left valign=top width=33%%>\n");
		display_info_table("Network Outages", TRUE, &current_authdata);
		printf("</td>\n");

		/* middle column of top row */
		printf("<td align=center valign=top width=33%%>\n");
		printf("</td>\n");

		/* right column of top row */
		printf("<td align=right valign=bottom width=33%%>\n");

		/* display context-sensitive help */
		display_context_help(CONTEXTHELP_OUTAGES);

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

		/* end of top table */
		printf("</tr>\n");
		printf("</table>\n");

		}


	/* display network outage info */
	display_network_outages();

	document_footer();

	/* free memory allocated to comment data */
	free_comment_data();

	/* free all allocated memory */
	free_memory();

	return OK;
	}