/*********************************************************************** * * CONFIG.C - Nagios Configuration CGI (View Only) * * Copyright (c) 1999-2006 Ethan Galstad (nagios@nagios.org) * Last Modified: 03-21-2006 * * This CGI program will display various configuration information. * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ***********************************************************************/ #include "../include/config.h" #include "../include/common.h" #include "../include/objects.h" #include "../include/cgiutils.h" #include "../include/cgiauth.h" #include "../include/getcgi.h" extern char main_config_file[MAX_FILENAME_LENGTH]; extern char url_html_path[MAX_FILENAME_LENGTH]; extern char url_docs_path[MAX_FILENAME_LENGTH]; extern char url_images_path[MAX_FILENAME_LENGTH]; extern char url_logo_images_path[MAX_FILENAME_LENGTH]; extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; extern host *host_list; extern service *service_list; extern hostgroup *hostgroup_list; extern servicegroup *servicegroup_list; extern contactgroup *contactgroup_list; extern command *command_list; extern timeperiod *timeperiod_list; extern contact *contact_list; extern servicedependency *servicedependency_list; extern serviceescalation *serviceescalation_list; extern hostdependency *hostdependency_list; extern hostescalation *hostescalation_list; extern hostextinfo *hostextinfo_list; extern serviceextinfo *serviceextinfo_list; #define DISPLAY_NONE 0 #define DISPLAY_HOSTS 1 #define DISPLAY_HOSTGROUPS 2 #define DISPLAY_CONTACTS 3 #define DISPLAY_CONTACTGROUPS 4 #define DISPLAY_SERVICES 5 #define DISPLAY_TIMEPERIODS 6 #define DISPLAY_COMMANDS 7 #define DISPLAY_HOSTGROUPESCALATIONS 8 /* no longer implemented */ #define DISPLAY_SERVICEDEPENDENCIES 9 #define DISPLAY_SERVICEESCALATIONS 10 #define DISPLAY_HOSTDEPENDENCIES 11 #define DISPLAY_HOSTESCALATIONS 12 #define DISPLAY_HOSTEXTINFO 13 #define DISPLAY_SERVICEEXTINFO 14 #define DISPLAY_SERVICEGROUPS 15 void document_header(int); void document_footer(void); int process_cgivars(void); void display_options(void); void display_hosts(void); void display_hostgroups(void); void display_servicegroups(void); void display_contacts(void); void display_contactgroups(void); void display_services(void); void display_timeperiods(void); void display_commands(void); void display_servicedependencies(void); void display_serviceescalations(void); void display_hostdependencies(void); void display_hostescalations(void); void display_hostextinfo(void); void display_serviceextinfo(void); void unauthorized_message(void); authdata current_authdata; int display_type=DISPLAY_NONE; int embedded=FALSE; 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; } document_header(TRUE); /* get authentication information */ get_authentication_information(¤t_authdata); /* begin top table */ printf("
| \n"); display_info_table("Configuration",FALSE,¤t_authdata); printf(" | \n"); /* right hand column of top row */ printf("\n"); if(display_type!=DISPLAY_NONE){ printf("\n"); } /* display context-sensitive help */ switch(display_type){ case DISPLAY_HOSTS: display_context_help(CONTEXTHELP_CONFIG_HOSTS); break; case DISPLAY_HOSTGROUPS: display_context_help(CONTEXTHELP_CONFIG_HOSTGROUPS); break; case DISPLAY_SERVICEGROUPS: display_context_help(CONTEXTHELP_CONFIG_SERVICEGROUPS); break; case DISPLAY_CONTACTS: display_context_help(CONTEXTHELP_CONFIG_CONTACTS); break; case DISPLAY_CONTACTGROUPS: display_context_help(CONTEXTHELP_CONFIG_CONTACTGROUPS); break; case DISPLAY_SERVICES: display_context_help(CONTEXTHELP_CONFIG_SERVICES); break; case DISPLAY_TIMEPERIODS: display_context_help(CONTEXTHELP_CONFIG_TIMEPERIODS); break; case DISPLAY_COMMANDS: display_context_help(CONTEXTHELP_CONFIG_COMMANDS); break; case DISPLAY_SERVICEDEPENDENCIES: display_context_help(CONTEXTHELP_CONFIG_SERVICEDEPENDENCIES); break; case DISPLAY_SERVICEESCALATIONS: display_context_help(CONTEXTHELP_CONFIG_HOSTESCALATIONS); break; case DISPLAY_HOSTDEPENDENCIES: display_context_help(CONTEXTHELP_CONFIG_HOSTDEPENDENCIES); break; case DISPLAY_HOSTESCALATIONS: display_context_help(CONTEXTHELP_CONFIG_HOSTESCALATIONS); break; case DISPLAY_HOSTEXTINFO: display_context_help(CONTEXTHELP_CONFIG_HOSTEXTINFO); break; case DISPLAY_SERVICEEXTINFO: display_context_help(CONTEXTHELP_CONFIG_SERVICEEXTINFO); break; default: display_context_help(CONTEXTHELP_CONFIG_MENU); break; } printf(" | \n"); /* end of top table */ printf("
| Host Name | "); printf("Alias/Description | "); printf("Address | "); printf("Parent Hosts | "); printf("Max. Check Attempts | "); printf("Check Interval | \n"); printf("Host Check Command | "); printf("Obsess Over | \n"); printf("Enable Active Checks | \n"); printf("Enable Passive Checks | \n"); printf("Check Freshness | \n"); printf("Freshness Threshold | \n"); printf("Default Contact Groups | \n"); printf("Notification Interval | "); printf("Notification Options | "); printf("Notification Period | "); printf("Event Handler | "); printf("Enable Event Handler | "); printf("Stalking Options | \n"); printf("Enable Flap Detection | "); printf("Low Flap Threshold | "); printf("High Flap Threshold | "); printf("Process Performance Data | "); printf("Enable Failure Prediction | "); printf("Failure Prediction Options | "); printf("Retention Options | "); printf("
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| %s | \n",bg_class,url_encode(temp_host->name),temp_host->name); printf("%s | \n",bg_class,temp_host->alias); printf("%s | \n",bg_class,temp_host->address); printf("",bg_class); for(temp_hostsmember=temp_host->parent_hosts;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){ if(temp_hostsmember!=temp_host->parent_hosts) printf(", "); printf("%s\n",CONFIG_CGI,url_encode(temp_hostsmember->host_name),temp_hostsmember->host_name); } if(temp_host->parent_hosts==NULL) printf(" "); printf(" | \n"); printf("%d | \n",bg_class,temp_host->max_attempts); get_interval_time_string(temp_host->check_interval,time_string,sizeof(time_string)); printf("%s | \n",bg_class,time_string); printf("",bg_class); if(temp_host->host_check_command==NULL) printf(" "); else printf("%s | \n",CONFIG_CGI,url_encode(temp_host->host_check_command),temp_host->host_check_command); printf("\n"); printf("%s | \n",bg_class,(temp_host->obsess_over_host==TRUE)?"Yes":"No"); printf("%s | \n",bg_class,(temp_host->checks_enabled==TRUE)?"Yes":"No"); printf("%s | \n",bg_class,(temp_host->accept_passive_host_checks==TRUE)?"Yes":"No"); printf("%s | \n",bg_class,(temp_host->check_freshness==TRUE)?"Yes":"No"); printf("",bg_class); if(temp_host->freshness_threshold==0) printf("Auto-determined value\n"); else printf("%d seconds\n",temp_host->freshness_threshold); printf(" | \n"); printf("",bg_class); /* find all the contact groups for this host... */ for(temp_contactgroupsmember=temp_host->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ if(temp_contactgroupsmember!=temp_host->contact_groups) printf(", "); printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); } printf(" | \n"); get_interval_time_string(temp_host->notification_interval,time_string,sizeof(time_string)); printf("%s | \n",bg_class,(temp_host->notification_interval==0)?"No Re-notification":time_string); printf("",bg_class); options=0; if(temp_host->notify_on_down==TRUE){ options=1; printf("Down"); } if(temp_host->notify_on_unreachable==TRUE){ printf("%sUnreachable",(options)?", ":""); options=1; } if(temp_host->notify_on_recovery==TRUE){ printf("%sRecovery",(options)?", ":""); options=1; } if(temp_host->notify_on_flapping==TRUE){ printf("%sFlapping",(options)?", ":""); options=1; } if(options==0) printf("None"); printf(" | \n"); printf("",bg_class); if(temp_host->notification_period==NULL) printf(" "); else printf("%s",CONFIG_CGI,url_encode(temp_host->notification_period),temp_host->notification_period); printf(" | \n"); printf("",bg_class); if(temp_host->event_handler==NULL) printf(" "); else printf("%s | \n",CONFIG_CGI,url_encode(temp_host->event_handler),temp_host->event_handler); printf("\n"); printf("",bg_class); printf("%s\n",(temp_host->event_handler_enabled==TRUE)?"Yes":"No"); printf(" | \n"); printf("",bg_class); options=0; if(temp_host->stalk_on_up==TRUE){ options=1; printf("Up"); } if(temp_host->stalk_on_down==TRUE){ printf("%sDown",(options)?", ":""); options=1; } if(temp_host->stalk_on_unreachable==TRUE){ printf("%sUnreachable",(options)?", ":""); options=1; } if(options==0) printf("None"); printf(" | \n"); printf("",bg_class); printf("%s\n",(temp_host->flap_detection_enabled==TRUE)?"Yes":"No"); printf(" | \n"); printf("",bg_class); if(temp_host->low_flap_threshold==0.0) printf("Program-wide value\n"); else printf("%3.1f%%\n",temp_host->low_flap_threshold); printf(" | \n"); printf("",bg_class); if(temp_host->high_flap_threshold==0.0) printf("Program-wide value\n"); else printf("%3.1f%%\n",temp_host->high_flap_threshold); printf(" | \n"); printf("",bg_class); printf("%s\n",(temp_host->process_performance_data==TRUE)?"Yes":"No"); printf(" | \n"); printf("",bg_class); printf("%s\n",(temp_host->failure_prediction_enabled==TRUE)?"Yes":"No"); printf(" | \n"); printf("%s | \n",bg_class,(temp_host->failure_prediction_options==NULL)?" ":temp_host->failure_prediction_options); printf("",bg_class); options=0; if(temp_host->retain_status_information==TRUE){ options=1; printf("Status Information"); } if(temp_host->retain_nonstatus_information==TRUE){ printf("%sNon-Status Information",(options==1)?", ":""); options=1; } if(options==0) printf("None"); printf(" | \n"); printf("
\n"); printf("
| Group Name | "); printf("Description | "); printf("Host Members | "); printf("
|---|---|---|
| %s | ",bg_class,temp_hostgroup->group_name); printf("%s | \n",bg_class,temp_hostgroup->alias); printf("",bg_class); /* find all the hosts that are members of this hostgroup... */ for(temp_hostgroupmember=temp_hostgroup->members;temp_hostgroupmember!=NULL;temp_hostgroupmember=temp_hostgroupmember->next){ if(temp_hostgroupmember!=temp_hostgroup->members) printf(", "); printf("%s\n",CONFIG_CGI,url_encode(temp_hostgroupmember->host_name),temp_hostgroupmember->host_name); } printf(" | \n"); printf("
\n"); printf("
| Group Name | "); printf("Description | "); printf("Service Members | "); printf("
|---|---|---|
| %s | ",bg_class,temp_servicegroup->group_name); printf("%s | \n",bg_class,temp_servicegroup->alias); printf("",bg_class); /* find all the services that are members of this servicegroup... */ for(temp_servicegroupmember=temp_servicegroup->members;temp_servicegroupmember!=NULL;temp_servicegroupmember=temp_servicegroupmember->next){ printf("%s%s / ",(temp_servicegroupmember==temp_servicegroup->members)?"":", ",CONFIG_CGI,url_encode(temp_servicegroupmember->host_name),temp_servicegroupmember->host_name); printf("%s\n",url_encode(temp_servicegroupmember->service_description),temp_servicegroupmember->service_description); } printf(" | \n"); printf("
\n"); printf("
| Contact Name | "); printf("Alias | "); printf("Email Address | "); printf("Pager Address/Number | "); printf("Service Notification Options | "); printf("Host Notification Options | "); printf("Service Notification Period | "); printf("Host Notification Period | "); printf("Service Notification Commands | "); printf("Host Notification Commands | "); printf("
|---|---|---|---|---|---|---|---|---|---|
| %s | \n",bg_class,url_encode(temp_contact->name),temp_contact->name); printf("%s | \n",bg_class,temp_contact->alias); printf("%s | \n",bg_class,(temp_contact->email==NULL)?" ":temp_contact->email,(temp_contact->email==NULL)?" ":temp_contact->email); printf("%s | \n",bg_class,(temp_contact->pager==NULL)?" ":temp_contact->pager); printf("",bg_class); options=0; if(temp_contact->notify_on_service_unknown==TRUE){ options=1; printf("Unknown"); } if(temp_contact->notify_on_service_warning==TRUE){ printf("%sWarning",(options)?", ":""); options=1; } if(temp_contact->notify_on_service_critical==TRUE){ printf("%sCritical",(options)?", ":""); options=1; } if(temp_contact->notify_on_service_recovery==TRUE){ printf("%sRecovery",(options)?", ":""); options=1; } if(temp_contact->notify_on_service_flapping==TRUE){ printf("%sFlapping",(options)?", ":""); options=1; } if(!options) printf("None"); printf(" | \n"); printf("",bg_class); options=0; if(temp_contact->notify_on_host_down==TRUE){ options=1; printf("Down"); } if(temp_contact->notify_on_host_unreachable==TRUE){ printf("%sUnreachable",(options)?", ":""); options=1; } if(temp_contact->notify_on_host_recovery==TRUE){ printf("%sRecovery",(options)?", ":""); options=1; } if(temp_contact->notify_on_host_flapping==TRUE){ printf("%sFlapping",(options)?", ":""); options=1; } if(!options) printf("None"); printf(" | \n"); printf("\n",bg_class); if(temp_contact->service_notification_period==NULL) printf(" "); else printf("%s",CONFIG_CGI,url_encode(temp_contact->service_notification_period),temp_contact->service_notification_period); printf(" | \n"); printf("\n",bg_class); if(temp_contact->host_notification_period==NULL) printf(" "); else printf("%s",CONFIG_CGI,url_encode(temp_contact->host_notification_period),temp_contact->host_notification_period); printf(" | \n"); printf("",bg_class); found=FALSE; for(temp_commandsmember=temp_contact->service_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){ if(temp_commandsmember!=temp_contact->service_notification_commands) printf(", "); printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),temp_commandsmember->command); found=TRUE; } if(found==FALSE) printf("None"); printf(" | \n"); printf("",bg_class); found=FALSE; for(temp_commandsmember=temp_contact->host_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){ if(temp_commandsmember!=temp_contact->host_notification_commands) printf(", "); printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),temp_commandsmember->command); found=TRUE; } if(found==FALSE) printf("None"); printf(" | \n"); printf("
\n"); printf("
| Group Name | \n"); printf("Description | \n"); printf("Contact Members | \n"); printf("
|---|---|---|
| %s | \n",bg_class,url_encode(temp_contactgroup->group_name),temp_contactgroup->group_name); printf("%s | \n",bg_class,temp_contactgroup->alias); /* find all the contact who are members of this contact group... */ printf("",bg_class); for(temp_contactgroupmember=temp_contactgroup->members;temp_contactgroupmember!=NULL;temp_contactgroupmember=temp_contactgroupmember->next){ if(temp_contactgroupmember!=temp_contactgroup->members) printf(", "); printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupmember->contact_name),temp_contactgroupmember->contact_name); } printf(" | \n"); printf("
\n"); printf("
| Service | "); printf("||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Host | \n"); printf("Description | \n"); printf("Max. Check Attempts | \n"); printf("Normal Check Interval | \n"); printf("Retry Check Interal | \n"); printf("Check Command | \n"); printf("Check Period | \n"); printf("Parallelize | \n"); printf("Volatile | \n"); printf("Obsess Over | \n"); printf("Enable Active Checks | \n"); printf("Enable Passive Checks | \n"); printf("Check Freshness | \n"); printf("Freshness Threshold | \n"); printf("Default Contact Groups | \n"); printf("Enable Notifications | \n"); printf("Notification Interval | \n"); printf("Notification Options | \n"); printf("Notification Period | \n"); printf("Event Handler | "); printf("Enable Event Handler | "); printf("Stalking Options | \n"); printf("Enable Flap Detection | "); printf("Low Flap Threshold | "); printf("High Flap Threshold | "); printf("Process Performance Data | "); printf("Enable Failure Prediction | "); printf("Failure Prediction Options | "); printf("Retention Options | "); printf("
| ",url_encode(temp_service->description)); printf("%s | \n",CONFIG_CGI,url_encode(temp_service->host_name),temp_service->host_name); printf("%s | \n",bg_class,temp_service->description); printf("%d | \n",bg_class,temp_service->max_attempts); get_interval_time_string(temp_service->check_interval,time_string,sizeof(time_string)); printf("%s | \n",bg_class,time_string); get_interval_time_string(temp_service->retry_interval,time_string,sizeof(time_string)); printf("%s | \n",bg_class,time_string); strncpy(command_line,temp_service->service_check_command,sizeof(command_line)); command_line[sizeof(command_line)-1]='\x0'; command_name=strtok(command_line,"!"); printf("%s | \n",bg_class,CONFIG_CGI,url_encode(command_name),temp_service->service_check_command); printf("",bg_class); if(temp_service->check_period==NULL) printf(" "); else printf("%s",CONFIG_CGI,url_encode(temp_service->check_period),temp_service->check_period); printf(" | \n"); printf("%s | \n",bg_class,(temp_service->parallelize==TRUE)?"Yes":"No"); printf("%s | \n",bg_class,(temp_service->is_volatile==TRUE)?"Yes":"No"); printf("%s | \n",bg_class,(temp_service->obsess_over_service==TRUE)?"Yes":"No"); printf("%s | \n",bg_class,(temp_service->checks_enabled==TRUE)?"Yes":"No"); printf("%s | \n",bg_class,(temp_service->accept_passive_service_checks==TRUE)?"Yes":"No"); printf("%s | \n",bg_class,(temp_service->check_freshness==TRUE)?"Yes":"No"); printf("",bg_class); if(temp_service->freshness_threshold==0) printf("Auto-determined value\n"); else printf("%d seconds\n",temp_service->freshness_threshold); printf(" | \n"); printf("",bg_class); for(temp_contactgroupsmember=temp_service->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ if(temp_contactgroupsmember!=temp_service->contact_groups) printf(", "); printf("%s",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); } if(temp_service->contact_groups==NULL) printf(" "); printf(" | \n"); printf("",bg_class); printf("%s\n",(temp_service->notifications_enabled==TRUE)?"Yes":"No"); printf(" | \n"); get_interval_time_string(temp_service->notification_interval,time_string,sizeof(time_string)); printf("%s | \n",bg_class,(temp_service->notification_interval==0)?"No Re-notification":time_string); printf("",bg_class); options=0; if(temp_service->notify_on_unknown==TRUE){ options=1; printf("Unknown"); } if(temp_service->notify_on_warning==TRUE){ printf("%sWarning",(options)?", ":""); options=1; } if(temp_service->notify_on_critical==TRUE){ printf("%sCritical",(options)?", ":""); options=1; } if(temp_service->notify_on_recovery==TRUE){ printf("%sRecovery",(options)?", ":""); options=1; } if(temp_service->notify_on_flapping==TRUE){ printf("%sFlapping",(options)?", ":""); options=1; } if(!options) printf("None"); printf(" | \n"); printf("",bg_class); if(temp_service->notification_period==NULL) printf(" "); else printf("%s",CONFIG_CGI,url_encode(temp_service->notification_period),temp_service->notification_period); printf(" | \n"); printf("",bg_class); if(temp_service->event_handler==NULL) printf(" "); else printf("%s",CONFIG_CGI,url_encode(temp_service->event_handler),temp_service->event_handler); printf(" | \n"); printf("",bg_class); printf("%s\n",(temp_service->event_handler_enabled==TRUE)?"Yes":"No"); printf(" | \n"); printf("",bg_class); options=0; if(temp_service->stalk_on_ok==TRUE){ options=1; printf("Ok"); } if(temp_service->stalk_on_warning==TRUE){ printf("%sWarning",(options)?", ":""); options=1; } if(temp_service->stalk_on_unknown==TRUE){ printf("%sUnknown",(options)?", ":""); options=1; } if(temp_service->stalk_on_critical==TRUE){ printf("%sCritical",(options)?", ":""); options=1; } if(options==0) printf("None"); printf(" | \n"); printf("",bg_class); printf("%s\n",(temp_service->flap_detection_enabled==TRUE)?"Yes":"No"); printf(" | \n"); printf("",bg_class); if(temp_service->low_flap_threshold==0.0) printf("Program-wide value\n"); else printf("%3.1f%%\n",temp_service->low_flap_threshold); printf(" | \n"); printf("",bg_class); if(temp_service->high_flap_threshold==0.0) printf("Program-wide value\n"); else printf("%3.1f%%\n",temp_service->high_flap_threshold); printf(" | \n"); printf("",bg_class); printf("%s\n",(temp_service->process_performance_data==TRUE)?"Yes":"No"); printf(" | \n"); printf("",bg_class); printf("%s\n",(temp_service->failure_prediction_enabled==TRUE)?"Yes":"No"); printf(" | \n"); printf("%s | \n",bg_class,(temp_service->failure_prediction_options==NULL)?" ":temp_service->failure_prediction_options); printf("",bg_class); options=0; if(temp_service->retain_status_information==TRUE){ options=1; printf("Status Information"); } if(temp_service->retain_nonstatus_information==TRUE){ printf("%sNon-Status Information",(options==1)?", ":""); options=1; } if(options==0) printf("None"); printf(" | \n"); printf("
\n"); printf("
| Name | \n"); printf("Alias/Description | \n"); printf("Sunday Time Ranges | \n"); printf("Monday Time Ranges | \n"); printf("Tuesday Time Ranges | \n"); printf("Wednesday Time Ranges | \n"); printf("Thursday Time Ranges | \n"); printf("Friday Time Ranges | \n"); printf("Saturday Time Ranges | \n"); printf("
|---|---|---|---|---|---|---|---|---|
| %s | \n",bg_class,url_encode(temp_timeperiod->name),temp_timeperiod->name); printf("%s | \n",bg_class,temp_timeperiod->alias); for(day=0;day<7;day++){ printf("",bg_class); for(temp_timerange=temp_timeperiod->days[day];temp_timerange!=NULL;temp_timerange=temp_timerange->next){ if(temp_timerange!=temp_timeperiod->days[day]) printf(", "); hours=temp_timerange->range_start/3600; minutes=(temp_timerange->range_start-(hours*3600))/60; seconds=temp_timerange->range_start-(hours*3600)-(minutes*60); snprintf(timestring,sizeof(timestring)-1,"%02d:%02d:%02d",hours,minutes,seconds); timestring[sizeof(timestring)-1]='\x0'; printf("%s - ",timestring); hours=temp_timerange->range_end/3600; minutes=(temp_timerange->range_end-(hours*3600))/60; seconds=temp_timerange->range_end-(hours*3600)-(minutes*60); snprintf(timestring,sizeof(timestring)-1,"%02d:%02d:%02d",hours,minutes,seconds); timestring[sizeof(timestring)-1]='\x0'; printf("%s",timestring); } if(temp_timeperiod->days[day]==NULL) printf(" "); printf(" | \n"); } printf("
\n"); printf("
| Dependent Service | "); printf("Master Service | "); printf("||||
|---|---|---|---|---|---|
| Host | "); printf("Service | "); printf("Host | "); printf("Service | "); printf("Dependency Type | "); printf("Dependency Failure Options | "); printf("
| %s | ",bg_class,CONFIG_CGI,url_encode(temp_sd->dependent_host_name),temp_sd->dependent_host_name); printf("%s | \n",url_encode(temp_sd->dependent_service_description),temp_sd->dependent_service_description); printf("%s | ",bg_class,CONFIG_CGI,url_encode(temp_sd->host_name),temp_sd->host_name); printf("%s | \n",url_encode(temp_sd->service_description),temp_sd->service_description); printf("%s | ",bg_class,(temp_sd->dependency_type==NOTIFICATION_DEPENDENCY)?"Notification":"Check Execution"); printf("",bg_class); options=FALSE; if(temp_sd->fail_on_ok==TRUE){ printf("Ok"); options=TRUE; } if(temp_sd->fail_on_warning==TRUE){ printf("%sWarning",(options==TRUE)?", ":""); options=TRUE; } if(temp_sd->fail_on_unknown==TRUE){ printf("%sUnknown",(options==TRUE)?", ":""); options=TRUE; } if(temp_sd->fail_on_critical==TRUE){ printf("%sCritical",(options==TRUE)?", ":""); options=TRUE; } if(temp_sd->fail_on_pending==TRUE){ printf("%sPending",(options==TRUE)?", ":""); options=TRUE; } printf(" | \n"); printf("
\n"); printf("
| Service | "); printf("|||||||
|---|---|---|---|---|---|---|---|
| Host | "); printf("Description | "); printf("Contact Groups | "); printf("First Notification | "); printf("Last Notification | "); printf("Notification Interval | "); printf("Escalation Period | "); printf("Escalation Options | "); printf("
| %s | ",bg_class,CONFIG_CGI,url_encode(temp_se->host_name),temp_se->host_name); printf("%s | \n",url_encode(temp_se->description),temp_se->description); printf("",bg_class); for(temp_contactgroupsmember=temp_se->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ if(temp_contactgroupsmember!=temp_se->contact_groups) printf(", "); printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); } printf(" | \n"); printf("%d | ",bg_class,temp_se->first_notification); printf("",bg_class); if(temp_se->last_notification==0) printf("Infinity"); else printf("%d",temp_se->last_notification); printf(" | \n"); printf("",bg_class); if(temp_se->notification_interval==0) printf("Notify Only Once (No Re-notification)"); else printf("%d",temp_se->notification_interval); printf(" | \n"); printf("",bg_class); if(temp_se->escalation_period==NULL) printf(" "); else printf("%s",CONFIG_CGI,url_encode(temp_se->escalation_period),temp_se->escalation_period); printf(" | \n"); printf("",bg_class); options=FALSE; if(temp_se->escalate_on_warning==TRUE){ printf("%sWarning",(options==TRUE)?", ":""); options=TRUE; } if(temp_se->escalate_on_unknown==TRUE){ printf("%sUnknown",(options==TRUE)?", ":""); options=TRUE; } if(temp_se->escalate_on_critical==TRUE){ printf("%sCritical",(options==TRUE)?", ":""); options=TRUE; } if(temp_se->escalate_on_recovery==TRUE){ printf("%sRecovery",(options==TRUE)?", ":""); options=TRUE; } if(options==FALSE) printf("None"); printf(" | \n"); printf("
\n"); printf("
| Dependent Host | "); printf("Master Host | "); printf("Dependency Type | "); printf("Dependency Failure Options | "); printf("
|---|---|---|---|
| %s | ",bg_class,CONFIG_CGI,url_encode(temp_hd->dependent_host_name),temp_hd->dependent_host_name); printf("%s | ",bg_class,CONFIG_CGI,url_encode(temp_hd->host_name),temp_hd->host_name); printf("%s | ",bg_class,(temp_hd->dependency_type==NOTIFICATION_DEPENDENCY)?"Notification":"Check Execution"); printf("",bg_class); options=FALSE; if(temp_hd->fail_on_up==TRUE){ printf("Up"); options=TRUE; } if(temp_hd->fail_on_down==TRUE){ printf("%sDown",(options==TRUE)?", ":""); options=TRUE; } if(temp_hd->fail_on_unreachable==TRUE){ printf("%sUnreachable",(options==TRUE)?", ":""); options=TRUE; } if(temp_hd->fail_on_pending==TRUE){ printf("%sPending",(options==TRUE)?", ":""); options=TRUE; } printf(" | \n"); printf("
\n"); printf("
| Host | "); printf("Contact Groups | "); printf("First Notification | "); printf("Last Notification | "); printf("Notification Interval | "); printf("Escalation Period | "); printf("Escalation Options | "); printf("
|---|---|---|---|---|---|---|
| %s | ",bg_class,CONFIG_CGI,url_encode(temp_he->host_name),temp_he->host_name); printf("",bg_class); for(temp_contactgroupsmember=temp_he->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ if(temp_contactgroupsmember!=temp_he->contact_groups) printf(", "); printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); } printf(" | \n"); printf("%d | ",bg_class,temp_he->first_notification); printf("",bg_class); if(temp_he->last_notification==0) printf("Infinity"); else printf("%d",temp_he->last_notification); printf(" | \n"); printf("",bg_class); if(temp_he->notification_interval==0) printf("Notify Only Once (No Re-notification)"); else printf("%d",temp_he->notification_interval); printf(" | \n"); printf("",bg_class); if(temp_he->escalation_period==NULL) printf(" "); else printf("%s",CONFIG_CGI,url_encode(temp_he->escalation_period),temp_he->escalation_period); printf(" | \n"); printf("",bg_class); options=FALSE; if(temp_he->escalate_on_down==TRUE){ printf("%sDown",(options==TRUE)?", ":""); options=TRUE; } if(temp_he->escalate_on_unreachable==TRUE){ printf("%sUnreachable",(options==TRUE)?", ":""); options=TRUE; } if(temp_he->escalate_on_recovery==TRUE){ printf("%sRecovery",(options==TRUE)?", ":""); options=TRUE; } if(options==FALSE) printf("None"); printf(" | \n"); printf("
\n"); printf("
| Host | "); printf("Notes URL | "); printf("2-D Coords | "); printf("3-D Coords | "); printf("Statusmap Image | "); printf("VRML Image | "); printf("Logo Image | "); printf("Image Alt | "); printf("|||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| %s | ",bg_class,CONFIG_CGI,url_encode(temp_hostextinfo->host_name),temp_hostextinfo->host_name); printf("%s | ",bg_class,(temp_hostextinfo->notes_url==NULL)?" ":temp_hostextinfo->notes_url); if(temp_hostextinfo->have_2d_coords==FALSE) printf("",bg_class); else printf(" | %d,%d | ",bg_class,temp_hostextinfo->x_2d,temp_hostextinfo->y_2d); if(temp_hostextinfo->have_3d_coords==FALSE) printf("",bg_class); else printf(" | %.2f,%.2f,%.2f | ",bg_class,temp_hostextinfo->x_3d,temp_hostextinfo->y_3d,temp_hostextinfo->z_3d); if(temp_hostextinfo->statusmap_image==NULL) printf("",bg_class); else printf(" | ",bg_class); else printf(" | ",bg_class); else printf(" | %s | ",bg_class,(temp_hostextinfo->icon_image_alt==NULL)?" ":temp_hostextinfo->icon_image_alt); printf("
\n"); printf("
| Service | "); printf("|||||
|---|---|---|---|---|---|
| Host | "); printf("Description | "); printf("Notes URL | "); printf("Logo Image | "); printf("Image Alt | "); printf("|
| %s | ",bg_class,CONFIG_CGI,url_encode(temp_serviceextinfo->host_name),temp_serviceextinfo->host_name); printf("%s | \n",url_encode(temp_serviceextinfo->description),temp_serviceextinfo->description); printf("%s | ",bg_class,(temp_serviceextinfo->notes_url==NULL)?" ":temp_serviceextinfo->notes_url); if(temp_serviceextinfo->icon_image==NULL) printf("",bg_class); else printf(" | %s | ",bg_class,(temp_serviceextinfo->icon_image_alt==NULL)?" ":temp_serviceextinfo->icon_image_alt); printf("|