Icinga-core 1.4.0
next gen monitoring
cgi/extinfo.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * EXTINFO.C -  Icinga Extended Information CGI
00004  *
00005  * Copyright (c) 1999-2009 Ethan Galstad (egalstad@nagios.org)
00006  * Copyright (c) 2009-2011 Icinga Development Team (http://www.icinga.org)
00007  *
00008  * License:
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License version 2 as
00012  * published by the Free Software Foundation.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022  *
00023  *****************************************************************************/
00024 
00025 #include "../include/config.h"
00026 #include "../include/common.h"
00027 #include "../include/objects.h"
00028 #include "../include/macros.h"
00029 #include "../include/comments.h"
00030 #include "../include/downtime.h"
00031 #include "../include/statusdata.h"
00032 
00033 static icinga_macros *mac;
00034 
00035 /* make sure gcc3 won't hit here */
00036 #ifndef GCCTOOOLD
00037 #include "../include/statsprofiler.h"
00038 #endif
00039 
00040 #include "../include/cgiutils.h"
00041 #include "../include/getcgi.h"
00042 #include "../include/cgiauth.h"
00043 
00044 extern char             nagios_check_command[MAX_INPUT_BUFFER];
00045 extern char             nagios_process_info[MAX_INPUT_BUFFER];
00046 extern int              nagios_process_state;
00047 
00048 extern time_t           program_start;
00049 extern int              nagios_pid;
00050 extern int              daemon_mode;
00051 extern time_t           last_command_check;
00052 extern time_t           last_log_rotation;
00053 extern int              enable_notifications;
00054 extern int              execute_service_checks;
00055 extern int              accept_passive_service_checks;
00056 extern int              execute_host_checks;
00057 extern int              accept_passive_host_checks;
00058 extern int              enable_event_handlers;
00059 extern int              obsess_over_services;
00060 extern int              obsess_over_hosts;
00061 extern int              enable_flap_detection;
00062 extern int              enable_failure_prediction;
00063 extern int              process_performance_data;
00064 /* make sure gcc3 won't hit here */
00065 #ifndef GCCTOOOLD
00066 extern int              event_profiling_enabled;
00067 #endif
00068 extern int              buffer_stats[1][3];
00069 extern int              program_stats[MAX_CHECK_STATS_TYPES][3];
00070 
00071 extern char main_config_file[MAX_FILENAME_LENGTH];
00072 extern char url_html_path[MAX_FILENAME_LENGTH];
00073 extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
00074 extern char url_js_path[MAX_FILENAME_LENGTH];
00075 extern char url_docs_path[MAX_FILENAME_LENGTH];
00076 extern char url_images_path[MAX_FILENAME_LENGTH];
00077 extern char url_logo_images_path[MAX_FILENAME_LENGTH];
00078 extern char log_file[MAX_FILENAME_LENGTH];
00079 
00080 extern int              enable_splunk_integration;
00081 
00082 extern char             *notes_url_target;
00083 extern char             *action_url_target;
00084 
00085 extern comment           *comment_list;
00086 extern scheduled_downtime  *scheduled_downtime_list;
00087 extern hoststatus *hoststatus_list;
00088 extern servicestatus *servicestatus_list;
00089 extern hostgroup *hostgroup_list;
00090 extern servicegroup *servicegroup_list;
00091 extern servicedependency *servicedependency_list;
00092 extern hostdependency *hostdependency_list;
00093 
00094 
00095 /* make sure gcc3 won't hit here */
00096 #ifndef GCCTOOOLD
00097 extern profile_object* profiled_data;
00098 #endif
00099 
00100 #define MAX_MESSAGE_BUFFER              4096
00101 
00102 #define HEALTH_WARNING_PERCENTAGE       85
00103 #define HEALTH_CRITICAL_PERCENTAGE      75
00104 
00105 /* this is only necessary to distinguish between comments and downtime in single host/service view */
00106 #define CSV_DEFAULT                     0
00107 #define CSV_COMMENT                     1
00108 #define CSV_DOWNTIME                    2
00109 
00110 
00111 /* SORTDATA structure */
00112 typedef struct sortdata_struct{
00113         int is_service;
00114         servicestatus *svcstatus;
00115         hoststatus *hststatus;
00116         struct sortdata_struct *next;
00117         }sortdata;
00118 
00119 int process_cgivars(void);
00120 
00121 void show_process_info(void);
00122 void show_host_info(void);
00123 void show_service_info(void);
00124 void show_performance_data(void);
00125 void show_hostgroup_info(void);
00126 void show_servicegroup_info(void);
00127 void show_downtime(int);
00128 void show_scheduling_queue(void);
00129 void show_comments(int);
00130 
00131 int sort_data(int,int);
00132 int compare_sortdata_entries(int,int,sortdata *,sortdata *);
00133 void free_sortdata_list(void);
00134 
00135 authdata current_authdata;
00136 
00137 sortdata *sortdata_list=NULL;
00138 
00139 char *host_name="";
00140 char *hostgroup_name="";
00141 char *servicegroup_name="";
00142 char *service_desc="";
00143 
00144 int display_type=DISPLAY_PROCESS_INFO;
00145 int show_all_hosts=TRUE;
00146 int show_all_hostgroups=TRUE;
00147 int show_all_servicegroups=TRUE;
00148 
00149 int sort_type=SORT_ASCENDING;
00150 int sort_option=SORT_NEXTCHECKTIME;
00151 
00152 int csv_type=CSV_DEFAULT;
00153 
00154 int dummy;      /* reduce compiler warnings */
00155 
00156 extern int embedded;
00157 extern int refresh;
00158 extern int display_header;
00159 extern int daemon_check;
00160 extern int content_type;
00161 
00162 extern char *csv_delimiter;
00163 extern char *csv_data_enclosure;
00164 
00165 int CGI_ID=EXTINFO_CGI_ID;
00166 
00167 int main(void){
00168         int result=OK;
00169         int found=FALSE;
00170         char temp_buffer[MAX_INPUT_BUFFER]="";
00171         char *processed_string=NULL;
00172         host *temp_host=NULL;
00173         hostsmember *temp_parenthost=NULL;
00174         hostgroup *temp_hostgroup=NULL;
00175         service *temp_service=NULL;
00176         servicegroup *temp_servicegroup=NULL;
00177         servicedependency *temp_sd=NULL;
00178         hostdependency *temp_hd=NULL;
00179 
00180         mac = get_global_macros();
00181 
00182         /* get the arguments passed in the URL */
00183         process_cgivars();
00184 
00185         /* reset internal variables */
00186         reset_cgi_vars();
00187 
00188         /* read the CGI configuration file */
00189         result=read_cgi_config_file(get_cgi_config_location());
00190         if(result==ERROR){
00191                 document_header(CGI_ID,FALSE);
00192                 print_error(get_cgi_config_location(), ERROR_CGI_CFG_FILE);
00193                 document_footer(CGI_ID);
00194                 return ERROR;
00195         }
00196 
00197         /* read the main configuration file */
00198         result=read_main_config_file(main_config_file);
00199         if(result==ERROR){
00200                 document_header(CGI_ID,FALSE);
00201                 print_error(main_config_file, ERROR_CGI_MAIN_CFG);
00202                 document_footer(CGI_ID);
00203                 return ERROR;
00204         }
00205 
00206         /* read all object configuration data */
00207         result=read_all_object_configuration_data(main_config_file,READ_ALL_OBJECT_DATA);
00208         if(result==ERROR){
00209                 document_header(CGI_ID,FALSE);
00210                 print_error(NULL, ERROR_CGI_OBJECT_DATA);
00211                 document_footer(CGI_ID);
00212                 return ERROR;
00213         }
00214 
00215         /* read all status data */
00216         result=read_all_status_data(get_cgi_config_location(),READ_ALL_STATUS_DATA);
00217         if(result==ERROR && daemon_check==TRUE){
00218                 document_header(CGI_ID,FALSE);
00219                 print_error(NULL, ERROR_CGI_STATUS_DATA);
00220                 document_footer(CGI_ID);
00221                 free_memory();
00222                 return ERROR;
00223         }
00224 
00225         /* initialize macros */
00226         init_macros();
00227 
00228         document_header(CGI_ID,TRUE);
00229 
00230         /* get authentication information */
00231         get_authentication_information(&current_authdata);
00232 
00233 
00234         if(display_header==TRUE){
00235 
00236                 /* begin top table */
00237                 printf("<table border=0 width=100%%>\n");
00238                 printf("<tr>\n");
00239 
00240                 /* left column of the first row */
00241                 printf("<td align=left valign=top width=33%%>\n");
00242 
00243                 if(display_type==DISPLAY_HOST_INFO)
00244                         snprintf(temp_buffer,sizeof(temp_buffer)-1,"Host Information");
00245                 else if(display_type==DISPLAY_SERVICE_INFO)
00246                         snprintf(temp_buffer,sizeof(temp_buffer)-1,"Service Information");
00247                 else if(display_type==DISPLAY_COMMENTS)
00248                         snprintf(temp_buffer,sizeof(temp_buffer)-1,"All Host and Service Comments");
00249                 else if(display_type==DISPLAY_PERFORMANCE)
00250                         snprintf(temp_buffer,sizeof(temp_buffer)-1,"Performance Information");
00251                 else if(display_type==DISPLAY_HOSTGROUP_INFO)
00252                         snprintf(temp_buffer,sizeof(temp_buffer)-1,"Hostgroup Information");
00253                 else if(display_type==DISPLAY_SERVICEGROUP_INFO)
00254                         snprintf(temp_buffer,sizeof(temp_buffer)-1,"Servicegroup Information");
00255                 else if(display_type==DISPLAY_DOWNTIME)
00256                         snprintf(temp_buffer,sizeof(temp_buffer)-1,"All Host and Service Scheduled Downtime");
00257                 else if(display_type==DISPLAY_SCHEDULING_QUEUE)
00258                         snprintf(temp_buffer,sizeof(temp_buffer)-1,"Check Scheduling Queue");
00259                 else
00260                         snprintf(temp_buffer,sizeof(temp_buffer)-1,"Icinga Process Information");
00261 
00262                 temp_buffer[sizeof(temp_buffer)-1]='\x0';
00263 
00264                 display_info_table(temp_buffer,refresh,&current_authdata, daemon_check);
00265 
00266                 /* find the host */
00267                 if(display_type==DISPLAY_HOST_INFO || display_type==DISPLAY_SERVICE_INFO){
00268 
00269                         temp_host=find_host(host_name);
00270                         grab_host_macros_r(mac, temp_host);
00271 
00272                         if(display_type==DISPLAY_SERVICE_INFO){
00273                                 temp_service=find_service(host_name,service_desc);
00274                                 grab_service_macros_r(mac, temp_service);
00275                         }
00276 
00277                         /* write some Javascript helper functions */
00278                         if(temp_host!=NULL){
00279                                 printf("<SCRIPT LANGUAGE=\"JavaScript\">\n<!--\n");
00280                                 printf("function nagios_get_host_name()\n{\n");
00281                                 printf("return \"%s\";\n",temp_host->name);
00282                                 printf("}\n");
00283                                 printf("function nagios_get_host_address()\n{\n");
00284                                 printf("return \"%s\";\n",temp_host->address);
00285                                 printf("}\n");
00286                                 printf("function nagios_get_host_address6()\n{\n");
00287                                 printf("return \"%s\";\n",temp_host->address6);
00288                                 printf("}\n");
00289                                 if(temp_service!=NULL){
00290                                         printf("function nagios_get_service_description()\n{\n");
00291                                         printf("return \"%s\";\n",temp_service->description);
00292                                         printf("}\n");
00293                                 }
00294                                 printf("//-->\n</SCRIPT>\n");
00295                         }
00296                 }
00297 
00298                 /* find the hostgroup */
00299                 else if(display_type==DISPLAY_HOSTGROUP_INFO){
00300                         temp_hostgroup=find_hostgroup(hostgroup_name);
00301                         grab_hostgroup_macros_r(mac, temp_hostgroup);
00302                 }
00303 
00304                 /* find the servicegroup */
00305                 else if(display_type==DISPLAY_SERVICEGROUP_INFO){
00306                         temp_servicegroup=find_servicegroup(servicegroup_name);
00307                         grab_servicegroup_macros_r(mac, temp_servicegroup);
00308                 }
00309 
00310                 if((display_type==DISPLAY_HOST_INFO && temp_host!=NULL) || (display_type==DISPLAY_SERVICE_INFO && temp_host!=NULL && temp_service!=NULL) || (display_type==DISPLAY_HOSTGROUP_INFO && temp_hostgroup!=NULL) || (display_type==DISPLAY_SERVICEGROUP_INFO && temp_servicegroup!=NULL)){
00311 
00312                         printf("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 CLASS='linkBox'>\n");
00313                         printf("<TR><TD CLASS='linkBox'>\n");
00314                         if(display_type==DISPLAY_SERVICE_INFO)
00315                                 printf("<A HREF='%s?type=%d&host=%s'>View Information For This Host</A><br>\n",EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(host_name));
00316                         if(display_type==DISPLAY_SERVICE_INFO || display_type==DISPLAY_HOST_INFO)
00317                                 printf("<A HREF='%s?host=%s'>View Status Detail For This Host</A><BR>\n",STATUS_CGI,url_encode(host_name));
00318                         if(display_type==DISPLAY_HOST_INFO){
00319                                 printf("<A HREF='%s?host=%s'>View Alert History For This Host</A><BR>\n",HISTORY_CGI,url_encode(host_name));
00320 #ifdef USE_TRENDS
00321                                 printf("<A HREF='%s?host=%s'>View Trends For This Host</A><BR>\n",TRENDS_CGI,url_encode(host_name));
00322 #endif
00323 #ifdef USE_HISTOGRAM
00324                                 printf("<A HREF='%s?host=%s'>View Alert Histogram For This Host</A><BR>\n",HISTOGRAM_CGI,url_encode(host_name));
00325 #endif
00326                                 printf("<A HREF='%s?host=%s&show_log_entries'>View Availability Report For This Host</A><BR>\n",AVAIL_CGI,url_encode(host_name));
00327                                 printf("<A HREF='%s?host=%s'>View Notifications For This Host</A>\n",NOTIFICATIONS_CGI,url_encode(host_name));
00328                         }
00329                         else if(display_type==DISPLAY_SERVICE_INFO){
00330                                 printf("<A HREF='%s?host=%s&",HISTORY_CGI,url_encode(host_name));
00331                                 printf("service=%s'>View Alert History For This Service</A><BR>\n",url_encode(service_desc));
00332 #ifdef USE_TRENDS
00333                                 printf("<A HREF='%s?host=%s&",TRENDS_CGI,url_encode(host_name));
00334                                 printf("service=%s'>View Trends For This Service</A><BR>\n",url_encode(service_desc));
00335 #endif
00336 #ifdef USE_HISTOGRAM
00337                                 printf("<A HREF='%s?host=%s&",HISTOGRAM_CGI,url_encode(host_name));
00338                                 printf("service=%s'>View Alert Histogram For This Service</A><BR>\n",url_encode(service_desc));
00339 #endif
00340                                 printf("<A HREF='%s?host=%s&",AVAIL_CGI,url_encode(host_name));
00341                                 printf("service=%s&show_log_entries'>View Availability Report For This Service</A><BR>\n",url_encode(service_desc));
00342                                 printf("<A HREF='%s?host=%s&",NOTIFICATIONS_CGI,url_encode(host_name));
00343                                 printf("service=%s'>View Notifications For This Service</A>\n",url_encode(service_desc));
00344                         }
00345                         else if(display_type==DISPLAY_HOSTGROUP_INFO){
00346                                 printf("<A HREF='%s?hostgroup=%s&style=detail'>View Status Detail For This Hostgroup</A><BR>\n",STATUS_CGI,url_encode(hostgroup_name));
00347                                 printf("<A HREF='%s?hostgroup=%s&style=overview'>View Status Overview For This Hostgroup</A><BR>\n",STATUS_CGI,url_encode(hostgroup_name));
00348                                 printf("<A HREF='%s?hostgroup=%s&style=grid'>View Status Grid For This Hostgroup</A><BR>\n",STATUS_CGI,url_encode(hostgroup_name));
00349                                 printf("<A HREF='%s?hostgroup=%s'>View Availability For This Hostgroup</A><BR>\n",AVAIL_CGI,url_encode(hostgroup_name));
00350                         }
00351                         else if(display_type==DISPLAY_SERVICEGROUP_INFO){
00352                                 printf("<A HREF='%s?servicegroup=%s&style=detail'>View Status Detail For This Servicegroup</A><BR>\n",STATUS_CGI,url_encode(servicegroup_name));
00353                                 printf("<A HREF='%s?servicegroup=%s&style=overview'>View Status Overview For This Servicegroup</A><BR>\n",STATUS_CGI,url_encode(servicegroup_name));
00354                                 printf("<A HREF='%s?servicegroup=%s&style=grid'>View Status Grid For This Servicegroup</A><BR>\n",STATUS_CGI,url_encode(servicegroup_name));
00355                                 printf("<A HREF='%s?servicegroup=%s'>View Availability For This Servicegroup</A><BR>\n",AVAIL_CGI,url_encode(servicegroup_name));
00356                         }
00357                         printf("</TD></TR>\n");
00358                         printf("</TABLE>\n");
00359                 }
00360 
00361                 printf("</td>\n");
00362 
00363                 /* middle column of top row */
00364                 printf("<td align=center valign=middle width=33%%>\n");
00365 
00366                 if((display_type==DISPLAY_HOST_INFO && temp_host!=NULL) || (display_type==DISPLAY_SERVICE_INFO && temp_host!=NULL && temp_service!=NULL) || (display_type==DISPLAY_HOSTGROUP_INFO && temp_hostgroup!=NULL) || (display_type==DISPLAY_SERVICEGROUP_INFO && temp_servicegroup!=NULL)){
00367 
00368                         if(display_type==DISPLAY_HOST_INFO){
00369 
00370                                 printf("<DIV CLASS='data'>Host</DIV>\n");
00371                                 printf("<DIV CLASS='dataTitle'>%s</DIV>\n",temp_host->alias);
00372                                 printf("<DIV CLASS='dataTitle'>(%s)</DIV><BR>\n",(temp_host->display_name!=NULL)?temp_host->display_name:temp_host->name);
00373 
00374                                 if (temp_host->parent_hosts != NULL) {
00375                                         /* print all parent hosts */
00376                                         printf("<DIV CLASS='data'>Parents:</DIV>\n");
00377                                         for(temp_parenthost=temp_host->parent_hosts;temp_parenthost!=NULL;temp_parenthost=temp_parenthost->next)
00378                                                 printf("<DIV CLASS='dataTitle'><A HREF='%s?host=%s'>%s</A></DIV>\n",STATUS_CGI, url_encode(temp_parenthost->host_name),temp_parenthost->host_name);
00379                                         printf("<BR>");
00380                                 }
00381 
00382                                 /* Hostgroups */
00383                                 printf("<DIV CLASS='data'>Member of</DIV><DIV CLASS='dataTitle'>");
00384 
00385                                 for(temp_hostgroup=hostgroup_list;temp_hostgroup!=NULL;temp_hostgroup=temp_hostgroup->next){
00386                                         if(is_host_member_of_hostgroup(temp_hostgroup,temp_host)==TRUE){
00387                                                 if(found==TRUE)
00388                                                         printf(", ");
00389 
00390                                                 printf("<A HREF='%s?hostgroup=%s&style=overview'>%s</A>",STATUS_CGI,url_encode(temp_hostgroup->group_name),html_encode((temp_hostgroup->alias!=NULL)?temp_hostgroup->alias:temp_hostgroup->group_name,TRUE));
00391                                                 found=TRUE;
00392                                                 }
00393                                         }
00394 
00395                                 if(found==FALSE)
00396                                         printf("No hostgroups");
00397 
00398                                 printf("</DIV><BR>\n");
00399 
00400                                 /* Host Dependencies */
00401                                 found=FALSE;
00402 
00403                                 printf("<DIV CLASS='data'>Host Dependencies</DIV><DIV CLASS='dataTitle'>");
00404 
00405                                 for(temp_hd=hostdependency_list;temp_hd!=NULL;temp_hd=temp_hd->next){
00406 
00407                                         if(!strcmp(temp_hd->dependent_host_name,temp_host->name)){
00408                                                 if(found==TRUE)
00409                                                         printf("<br>");
00410 
00411                                                 printf("<A HREF='%s?type=%d&host=%s'>%s</A>\n",EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_hd->host_name),html_encode(temp_hd->host_name,FALSE));
00412                                                 found=TRUE;
00413                                         }
00414                                 }
00415 
00416                                 if(found==FALSE)
00417                                         printf("None");
00418 
00419                                 printf("</DIV><BR>\n");
00420 
00421                                 /* Host address(6) */
00422                                 if(!strcmp(temp_host->address6,temp_host->name)){
00423                                         printf("<DIV CLASS='data'>%s</DIV>\n",temp_host->address);
00424                                 } else {
00425                                         printf("<DIV CLASS='data'>%s, %s</DIV>\n",temp_host->address,temp_host->address6);
00426                                 }
00427                         }
00428                         if(display_type==DISPLAY_SERVICE_INFO){
00429 
00430                                 printf("<DIV CLASS='data'>Service</DIV><DIV CLASS='dataTitle'>%s</DIV><DIV CLASS='data'>On Host</DIV>\n",(temp_service->display_name!=NULL)?temp_service->display_name:temp_service->description);
00431                                 printf("<DIV CLASS='dataTitle'>%s</DIV>\n",temp_host->alias);
00432                                 printf("<DIV CLASS='dataTitle'>(<A HREF='%s?type=%d&host=%s'>%s</a>)</DIV><BR>\n",EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_host->name),(temp_host->display_name!=NULL)?temp_host->display_name:temp_host->name);
00433 
00434                                 /* Servicegroups */
00435                                 printf("<DIV CLASS='data'>Member of</DIV><DIV CLASS='dataTitle'>");
00436 
00437                                 for(temp_servicegroup=servicegroup_list;temp_servicegroup!=NULL;temp_servicegroup=temp_servicegroup->next){
00438                                         if(is_service_member_of_servicegroup(temp_servicegroup,temp_service)==TRUE){
00439                                                 if(found==TRUE)
00440                                                         printf(", ");
00441 
00442                                                 printf("<A HREF='%s?servicegroup=%s&style=overview'>%s</A>",STATUS_CGI,url_encode(temp_servicegroup->group_name),html_encode((temp_servicegroup->alias!=NULL)?temp_servicegroup->alias:temp_servicegroup->group_name,TRUE));
00443                                                 found=TRUE;
00444                                                 }
00445                                         }
00446 
00447                                 if(found==FALSE)
00448                                         printf("No servicegroups.");
00449 
00450                                 printf("</DIV><BR>\n");
00451 
00452                                 /* Service Dependencies */
00453                                 found=FALSE;
00454 
00455                                 printf("<DIV CLASS='data'>Service Dependencies</DIV><DIV CLASS='dataTitle'>");
00456 
00457                                 for(temp_sd=servicedependency_list;temp_sd!=NULL;temp_sd=temp_sd->next){
00458 
00459                                         if(!strcmp(temp_sd->dependent_service_description,temp_service->description)&&!strcmp(temp_sd->dependent_host_name,temp_host->name)){
00460                                                 if(found==TRUE)
00461                                                         printf("<br>");
00462 
00463                                                 printf("<A HREF='%s?type=%d&host=%s",EXTINFO_CGI,DISPLAY_SERVICE_INFO,url_encode(temp_sd->host_name));
00464                                                 printf("&service=%s'>%s on %s</A>\n",url_encode(temp_sd->service_description),html_encode(temp_sd->service_description,FALSE),html_encode(temp_sd->host_name,FALSE));
00465                                                 found=TRUE;
00466                                         }
00467                                 }
00468 
00469                                 if(found==FALSE)
00470                                         printf("None");
00471 
00472                                 printf("</DIV><BR>\n");
00473 
00474 
00475                                 if(!strcmp(temp_host->address6,temp_host->name)){
00476                                         printf("<DIV CLASS='data'>%s</DIV>\n",temp_host->address);
00477                                 } else {
00478                                         printf("<DIV CLASS='data'>%s, %s</DIV>\n",temp_host->address,temp_host->address6);
00479                                 }
00480                         }
00481                         if(display_type==DISPLAY_HOSTGROUP_INFO){
00482 
00483                                 printf("<DIV CLASS='data'>Hostgroup</DIV>\n");
00484                                 printf("<DIV CLASS='dataTitle'>%s</DIV>\n",temp_hostgroup->alias);
00485                                 printf("<DIV CLASS='dataTitle'>(%s)</DIV>\n",temp_hostgroup->group_name);
00486 
00487                                 if(temp_hostgroup->notes!=NULL){
00488                                         process_macros_r(mac, temp_hostgroup->notes,&processed_string,0);
00489                                         printf("<p>%s</p>",processed_string);
00490                                         free(processed_string);
00491                                 }
00492                         }
00493                         if(display_type==DISPLAY_SERVICEGROUP_INFO){
00494 
00495                                 printf("<DIV CLASS='data'>Servicegroup</DIV>\n");
00496                                 printf("<DIV CLASS='dataTitle'>%s</DIV>\n",temp_servicegroup->alias);
00497                                 printf("<DIV CLASS='dataTitle'>(%s)</DIV>\n",temp_servicegroup->group_name);
00498 
00499                                 if(temp_servicegroup->notes!=NULL){
00500                                         process_macros_r(mac, temp_servicegroup->notes,&processed_string,0);
00501                                         printf("<p>%s</p>",processed_string);
00502                                         free(processed_string);
00503                                 }
00504                         }
00505 
00506                         if(display_type==DISPLAY_SERVICE_INFO){
00507                                 if(temp_service->icon_image!=NULL){
00508                                         printf("<img src='%s",url_logo_images_path);
00509                                         process_macros_r(mac, temp_service->icon_image,&processed_string,0);
00510                                         printf("%s",processed_string);
00511                                         free(processed_string);
00512                                         printf("' border=0 alt='%s' title='%s'><BR CLEAR=ALL>",(temp_service->icon_image_alt==NULL)?"":temp_service->icon_image_alt,(temp_service->icon_image_alt==NULL)?"":temp_service->icon_image_alt);
00513                                 }
00514                                 if(temp_service->icon_image_alt!=NULL)
00515                                         printf("<font size=-1><i>( %s )</i></font>\n",temp_service->icon_image_alt);
00516                                 if(temp_service->notes!=NULL){
00517                                         process_macros_r(mac, temp_service->notes,&processed_string,0);
00518                                         printf("<p>%s</p>\n",processed_string);
00519                                         free(processed_string);
00520                                 }
00521                         }
00522 
00523                         if(display_type==DISPLAY_HOST_INFO){
00524                                 if(temp_host->icon_image!=NULL){
00525                                         printf("<img src='%s",url_logo_images_path);
00526                                         process_macros_r(mac, temp_host->icon_image,&processed_string,0);
00527                                         printf("%s",processed_string);
00528                                         free(processed_string);
00529                                         printf("' border=0 alt='%s' title='%s'><BR CLEAR=ALL>",(temp_host->icon_image_alt==NULL)?"":temp_host->icon_image_alt,(temp_host->icon_image_alt==NULL)?"":temp_host->icon_image_alt);
00530                                 }
00531                                 if(temp_host->icon_image_alt!=NULL)
00532                                         printf("<font size=-1><i>( %s )</i><font>\n",temp_host->icon_image_alt);
00533                                 if(temp_host->notes!=NULL){
00534                                         process_macros_r(mac, temp_host->notes,&processed_string,0);
00535                                         printf("<p>%s</p>\n",processed_string);
00536                                         free(processed_string);
00537                                 }
00538                         }
00539                 }
00540 
00541                 printf("</td>\n");
00542 
00543                 /* right column of top row */
00544                 printf("<td align=right valign=bottom width=33%%>\n");
00545 
00546                 if(display_type==DISPLAY_HOST_INFO && temp_host!=NULL){
00547 
00548                         printf("<TABLE BORDER='0'>\n");
00549                         if(temp_host->action_url!=NULL && strcmp(temp_host->action_url,"")){
00550                                 process_macros_r(mac, temp_host->action_url,&processed_string,0);
00551                                 BEGIN_MULTIURL_LOOP
00552                                 printf("<TR><TD ALIGN='right'>\n");
00553                                 printf("<A HREF='");
00554                                 printf("%s",processed_string);
00555                                 printf("' TARGET='%s'><img src='%s%s%s' border=0 alt='Perform Additional Actions On This Host' title='Perform Additional Actions On This Host'></A>\n",(action_url_target==NULL)?"_blank":action_url_target,url_images_path,MU_iconstr,ACTION_ICON);
00556                                 printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
00557                                 printf("</TD></TR>\n");
00558                                 END_MULTIURL_LOOP
00559                                 free(processed_string);
00560                         }
00561                         if(temp_host->notes_url!=NULL && strcmp(temp_host->notes_url,"")){
00562                                 process_macros_r(mac, temp_host->notes_url,&processed_string,0);
00563                                 BEGIN_MULTIURL_LOOP
00564                                 printf("<TR><TD ALIGN='right'>\n");
00565                                 printf("<A HREF='");
00566                                 printf("%s",processed_string);
00567                                 /*print_extra_host_url(temp_host->name,temp_host->notes_url);*/
00568                                 printf("' TARGET='%s'><img src='%s%s%s' border=0 alt='View Additional Notes For This Host' title='View Additional Notes For This Host'></A>\n",(notes_url_target==NULL)?"_blank":notes_url_target,url_images_path,MU_iconstr,NOTES_ICON);
00569                                 printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
00570                                 printf("</TD></TR>\n");
00571                                 END_MULTIURL_LOOP
00572                                 free(processed_string);
00573                         }
00574                         printf("</TABLE>\n");
00575                 }
00576 
00577                 else if(display_type==DISPLAY_SERVICE_INFO && temp_service!=NULL){
00578 
00579                         printf("<TABLE BORDER='0'><TR><TD ALIGN='right'>\n");
00580 
00581                         if(temp_service->action_url!=NULL && strcmp(temp_service->action_url,"")){
00582                                 process_macros_r(mac, temp_service->action_url,&processed_string,0);
00583                                 BEGIN_MULTIURL_LOOP
00584                                 printf("<A HREF='");
00585                                 printf("%s",processed_string);
00586                                 printf("' TARGET='%s'><img src='%s%s%s' border=0 alt='Perform Additional Actions On This Service' title='Perform Additional Actions On This Service'></A>\n",(action_url_target==NULL)?"_blank":action_url_target,url_images_path,MU_iconstr,ACTION_ICON);
00587                                 printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
00588                                 END_MULTIURL_LOOP
00589                                 free(processed_string);
00590                         }
00591                         if(temp_service->notes_url!=NULL && strcmp(temp_service->notes_url,"")){
00592                                 process_macros_r(mac, temp_service->notes_url,&processed_string,0);
00593                                 BEGIN_MULTIURL_LOOP
00594                                 printf("<A HREF='");
00595                                 printf("%s",processed_string);
00596                                 printf("' TARGET='%s'><img src='%s%s%s' border=0 alt='View Additional Notes For This Service' title='View Additional Notes For This Service'></A>\n",(notes_url_target==NULL)?"_blank":notes_url_target,url_images_path,MU_iconstr,NOTES_ICON);
00597                                 printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
00598                                 END_MULTIURL_LOOP
00599                                 free(processed_string);
00600                         }
00601                         printf("</TD></TR></TABLE>\n");
00602                 }
00603 
00604                 if(display_type==DISPLAY_HOSTGROUP_INFO && temp_hostgroup!=NULL){
00605                         printf("<TABLE BORDER='0'>\n");
00606 
00607                         if(temp_hostgroup->action_url!=NULL && strcmp(temp_hostgroup->action_url,"")){
00608                                 printf("<TR><TD ALIGN='right'>\n");
00609                                 printf("<A HREF='");
00610                                 print_extra_hostgroup_url(temp_hostgroup->group_name,temp_hostgroup->action_url);
00611                                 printf("' TARGET='%s'><img src='%s%s' border=0 alt='Perform Additional Actions On This Hostgroup' title='Perform Additional Actions On This Hostgroup'></A>\n",(action_url_target==NULL)?"_blank":action_url_target,url_images_path,ACTION_ICON);
00612                                 printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
00613                                 printf("</TD></TR>\n");
00614                         }
00615                         if(temp_hostgroup->notes_url!=NULL && strcmp(temp_hostgroup->notes_url,"")){
00616                                 printf("<TR><TD ALIGN='right'>\n");
00617                                 printf("<A HREF='");
00618                                 print_extra_hostgroup_url(temp_hostgroup->group_name,temp_hostgroup->notes_url);
00619                                 printf("' TARGET='%s'><img src='%s%s' border=0 alt='View Additional Notes For This Hostgroup' title='View Additional Notes For This Hostgroup'></A>\n",(notes_url_target==NULL)?"_blank":notes_url_target,url_images_path,NOTES_ICON);
00620                                 printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
00621                                 printf("</TD></TR>\n");
00622                         }
00623                         printf("</TABLE>\n");
00624                 }
00625 
00626                 else if(display_type==DISPLAY_SERVICEGROUP_INFO && temp_servicegroup!=NULL){
00627                         printf("<TABLE BORDER='0'>\n");
00628 
00629                         if(temp_servicegroup->action_url!=NULL && strcmp(temp_servicegroup->action_url,"")){
00630                                 printf("<A HREF='");
00631                                 print_extra_servicegroup_url(temp_servicegroup->group_name,temp_servicegroup->action_url);
00632                                 printf("' TARGET='%s'><img src='%s%s' border=0 alt='Perform Additional Actions On This Servicegroup' title='Perform Additional Actions On This Servicegroup'></A>\n",(action_url_target==NULL)?"_blank":action_url_target,url_images_path,ACTION_ICON);
00633                                 printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
00634                         }
00635                         if(temp_servicegroup->notes_url!=NULL && strcmp(temp_servicegroup->notes_url,"")){
00636                                 printf("<A HREF='");
00637                                 print_extra_servicegroup_url(temp_servicegroup->group_name,temp_servicegroup->notes_url);
00638                                 printf("' TARGET='%s'><img src='%s%s' border=0 alt='View Additional Notes For This Servicegroup' title='View Additional Notes For This Servicegroup'></A>\n",(notes_url_target==NULL)?"_blank":notes_url_target,url_images_path,NOTES_ICON);
00639                                 printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
00640                         }
00641                         printf("</TABLE>\n");
00642                 }
00643 
00644                 /* display context-sensitive help */
00645                 if(display_type==DISPLAY_HOST_INFO)
00646                         display_context_help(CONTEXTHELP_EXT_HOST);
00647                 else if(display_type==DISPLAY_SERVICE_INFO)
00648                         display_context_help(CONTEXTHELP_EXT_SERVICE);
00649                 else if(display_type==DISPLAY_HOSTGROUP_INFO)
00650                         display_context_help(CONTEXTHELP_EXT_HOSTGROUP);
00651                 else if(display_type==DISPLAY_SERVICEGROUP_INFO)
00652                         display_context_help(CONTEXTHELP_EXT_SERVICEGROUP);
00653                 else if(display_type==DISPLAY_PROCESS_INFO)
00654                         display_context_help(CONTEXTHELP_EXT_PROCESS);
00655                 else if(display_type==DISPLAY_PERFORMANCE)
00656                         display_context_help(CONTEXTHELP_EXT_PERFORMANCE);
00657                 else if(display_type==DISPLAY_COMMENTS)
00658                         display_context_help(CONTEXTHELP_EXT_COMMENTS);
00659                 else if(display_type==DISPLAY_DOWNTIME)
00660                         display_context_help(CONTEXTHELP_EXT_DOWNTIME);
00661                 else if(display_type==DISPLAY_SCHEDULING_QUEUE)
00662                         display_context_help(CONTEXTHELP_EXT_QUEUE);
00663 
00664                 printf("</td>\n");
00665 
00666                 /* end of top table */
00667                 printf("</tr>\n");
00668                 printf("</table>\n");
00669 
00670         }
00671 
00672         if(content_type==HTML_CONTENT)
00673                 printf("<BR>\n");
00674 
00675         if(display_type==DISPLAY_HOST_INFO) {
00676                 if(content_type==CSV_CONTENT) {
00677                         if (csv_type==CSV_COMMENT)
00678                                 show_comments(HOST_COMMENT);
00679                         else if (csv_type==CSV_DOWNTIME)
00680                                 show_downtime(HOST_DOWNTIME);
00681                         else
00682                                 printf("Please specify the correct csvtype! possible is \"csvtype=comment\" or \"csv_type=downtime\".\n");
00683                 }else
00684                         show_host_info();
00685         }
00686         else if(display_type==DISPLAY_SERVICE_INFO) {
00687                 if(content_type==CSV_CONTENT) {
00688                         if (csv_type==CSV_COMMENT)
00689                                 show_comments(SERVICE_COMMENT);
00690                         else if (csv_type==CSV_DOWNTIME)
00691                                 show_downtime(SERVICE_DOWNTIME);
00692                         else
00693                                 printf("Please specify the correct csvtype! possible is \"csvtype=comment\" or \"csv_type=downtime\".\n");
00694                 }else
00695                         show_service_info();
00696         }
00697         else if(display_type==DISPLAY_COMMENTS) {
00698                 if(is_authorized_for_read_only(&current_authdata)==TRUE)
00699                         printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to view comments.<br>\n");
00700                 else {
00701                         if(content_type==CSV_CONTENT || content_type==JSON_CONTENT) {
00702                                 show_comments(HOST_COMMENT);
00703                                 show_comments(SERVICE_COMMENT);
00704                         } else {
00705                                 printf("<BR />\n");
00706                                 printf("<DIV CLASS='commentNav'>[&nbsp;<A HREF='#HOSTCOMMENTS' CLASS='commentNav'>Host Comments</A>&nbsp;|&nbsp;<A HREF='#SERVICECOMMENTS' CLASS='commentNav'>Service Comments</A>&nbsp;]</DIV>\n");
00707                                 printf("<BR />\n");
00708 
00709                                 /* add export to csv link */
00710                                 printf("<DIV class='csv_export_link'><A HREF='%s&csvtype=comment' target='_blank'>Export to CSV</A></DIV>\n",get_export_csv_link(EXTINFO_CGI));
00711 
00712                                 show_comments(HOST_COMMENT);
00713                                 printf("<BR />\n");
00714                                 show_comments(SERVICE_COMMENT);
00715                         }
00716                 }
00717         }
00718         else if(display_type==DISPLAY_DOWNTIME) {
00719                 if(is_authorized_for_read_only(&current_authdata)==TRUE)
00720                         printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to view downtimes.<br>\n");
00721                 else {
00722                         if(content_type==CSV_CONTENT || content_type==JSON_CONTENT) {
00723                                 show_downtime(HOST_DOWNTIME);
00724                                 show_downtime(SERVICE_DOWNTIME);
00725                         } else {
00726                                 printf("<BR />\n");
00727                                 printf("<DIV CLASS='downtimeNav'>[&nbsp;<A HREF='#HOSTDOWNTIME' CLASS='downtimeNav'>Host Downtime</A>&nbsp;|&nbsp;<A HREF='#SERVICEDOWNTIME' CLASS='downtimeNav'>Service Downtime</A>&nbsp;]</DIV>\n");
00728                                 printf("<BR />\n");
00729 
00730                                 /* add export to csv link */
00731                                 printf("<DIV class='csv_export_link'><A HREF='%s&csvtype=downtime' target='_blank'>Export to CSV</A></DIV>\n",get_export_csv_link(EXTINFO_CGI));
00732 
00733                                 show_downtime(HOST_DOWNTIME);
00734                                 printf("<BR />\n");
00735                                 show_downtime(SERVICE_DOWNTIME);
00736                         }
00737                 }
00738         }
00739         else if(display_type==DISPLAY_PERFORMANCE)
00740                 show_performance_data();
00741         else if(display_type==DISPLAY_HOSTGROUP_INFO)
00742                 show_hostgroup_info();
00743         else if(display_type==DISPLAY_SERVICEGROUP_INFO)
00744                 show_servicegroup_info();
00745         else if(display_type==DISPLAY_SCHEDULING_QUEUE)
00746                 show_scheduling_queue();
00747         else
00748                 show_process_info();
00749 
00750         document_footer(CGI_ID);
00751 
00752         /* free all allocated memory */
00753         free_memory();
00754         free_comment_data();
00755         free_downtime_data();
00756 
00757         return OK;
00758 }
00759 
00760 int process_cgivars(void){
00761         char **variables;
00762         int error=FALSE;
00763         int temp_type;
00764         int x;
00765 
00766         variables=getcgivars();
00767 
00768         for(x=0;variables[x]!=NULL;x++){
00769 
00770                 /* do some basic length checking on the variable identifier to prevent buffer overflows */
00771                 if(strlen(variables[x])>=MAX_INPUT_BUFFER-1){
00772                         x++;
00773                         continue;
00774                 }
00775 
00776                 /* we found the display type */
00777                 else if(!strcmp(variables[x],"type")){
00778                         x++;
00779                         if(variables[x]==NULL){
00780                                 error=TRUE;
00781                                 break;
00782                         }
00783                         temp_type=atoi(variables[x]);
00784                         if(temp_type==DISPLAY_HOST_INFO)
00785                                 display_type=DISPLAY_HOST_INFO;
00786                         else if(temp_type==DISPLAY_SERVICE_INFO)
00787                                 display_type=DISPLAY_SERVICE_INFO;
00788                         else if(temp_type==DISPLAY_COMMENTS)
00789                                 display_type=DISPLAY_COMMENTS;
00790                         else if(temp_type==DISPLAY_PERFORMANCE)
00791                                 display_type=DISPLAY_PERFORMANCE;
00792                         else if(temp_type==DISPLAY_HOSTGROUP_INFO)
00793                                 display_type=DISPLAY_HOSTGROUP_INFO;
00794                         else if(temp_type==DISPLAY_SERVICEGROUP_INFO)
00795                                 display_type=DISPLAY_SERVICEGROUP_INFO;
00796                         else if(temp_type==DISPLAY_DOWNTIME)
00797                                 display_type=DISPLAY_DOWNTIME;
00798                         else if(temp_type==DISPLAY_SCHEDULING_QUEUE)
00799                                 display_type=DISPLAY_SCHEDULING_QUEUE;
00800                         else
00801                                 display_type=DISPLAY_PROCESS_INFO;
00802                 }
00803 
00804                 /* we found the host name */
00805                 else if(!strcmp(variables[x],"host")){
00806                         x++;
00807                         if(variables[x]==NULL){
00808                                 error=TRUE;
00809                                 break;
00810                         }
00811 
00812                         host_name=strdup(variables[x]);
00813                         if(host_name==NULL)
00814                                 host_name="";
00815                         strip_html_brackets(host_name);
00816                 }
00817 
00818                 /* we found the hostgroup name */
00819                 else if(!strcmp(variables[x],"hostgroup")){
00820                         x++;
00821                         if(variables[x]==NULL){
00822                                 error=TRUE;
00823                                 break;
00824                         }
00825 
00826                         hostgroup_name=strdup(variables[x]);
00827                         if(hostgroup_name==NULL)
00828                                 hostgroup_name="";
00829                         strip_html_brackets(hostgroup_name);
00830                 }
00831 
00832                 /* we found the service name */
00833                 else if(!strcmp(variables[x],"service")){
00834                         x++;
00835                         if(variables[x]==NULL){
00836                                 error=TRUE;
00837                                 break;
00838                         }
00839 
00840                         service_desc=strdup(variables[x]);
00841                         if(service_desc==NULL)
00842                                 service_desc="";
00843                         strip_html_brackets(service_desc);
00844                 }
00845 
00846                 /* we found the servicegroup name */
00847                 else if(!strcmp(variables[x],"servicegroup")){
00848                         x++;
00849                         if(variables[x]==NULL){
00850                                 error=TRUE;
00851                                 break;
00852                         }
00853 
00854                         servicegroup_name=strdup(variables[x]);
00855                         if(servicegroup_name==NULL)
00856                                 servicegroup_name="";
00857                         strip_html_brackets(servicegroup_name);
00858                 }
00859 
00860                 /* we found the sort type argument */
00861                 else if(!strcmp(variables[x],"sorttype")){
00862                         x++;
00863                         if(variables[x]==NULL){
00864                                 error=TRUE;
00865                                 break;
00866                         }
00867 
00868                         sort_type=atoi(variables[x]);
00869                 }
00870 
00871                 /* we found the sort option argument */
00872                 else if(!strcmp(variables[x],"sortoption")){
00873                         x++;
00874                         if(variables[x]==NULL){
00875                                 error=TRUE;
00876                                 break;
00877                         }
00878 
00879                         sort_option=atoi(variables[x]);
00880                 }
00881 
00882                 /* we found the CSV output option */
00883                 else if(!strcmp(variables[x],"csvoutput")){
00884                         display_header=FALSE;
00885                         content_type=CSV_CONTENT;
00886                 }
00887 
00888                 /* we found the JSON output option */
00889                 else if(!strcmp(variables[x],"jsonoutput")){
00890                         display_header=FALSE;
00891                         content_type=JSON_CONTENT;
00892                 }
00893 
00894                 else if(!strcmp(variables[x],"csvtype")){
00895                         x++;
00896                         if(variables[x]==NULL){
00897                                 error=TRUE;
00898                                 break;
00899                         }
00900 
00901                         if (!strcmp(variables[x],"comment"))
00902                                 csv_type=CSV_COMMENT;
00903                         else if (!strcmp(variables[x],"downtime"))
00904                                 csv_type=CSV_DOWNTIME;
00905                         else
00906                                 csv_type=CSV_DEFAULT;
00907                 }
00908 
00909                         /* we found the embed option */
00910                 else if(!strcmp(variables[x],"embedded"))
00911                         embedded=TRUE;
00912 
00913                 /* we found the noheader option */
00914                 else if(!strcmp(variables[x],"noheader"))
00915                         display_header=FALSE;
00916 
00917                 /* we found the pause option */
00918                 else if(!strcmp(variables[x],"paused"))
00919                         refresh=FALSE;
00920 
00921                 /* we found the nodaemoncheck option */
00922                 else if(!strcmp(variables[x],"nodaemoncheck"))
00923                         daemon_check=FALSE;
00924         }
00925 
00926 
00927         /* free memory allocated to the CGI variables */
00928         free_cgivars(variables);
00929 
00930         return error;
00931 }
00932 
00933 void show_process_info(void){
00934         char start_time[MAX_DATETIME_LENGTH];
00935         char last_external_check_time[MAX_DATETIME_LENGTH];
00936         char last_log_rotation_time[MAX_DATETIME_LENGTH];
00937         time_t current_time;
00938         unsigned long run_time;
00939         char run_time_string[24];
00940         int days=0;
00941         int hours=0;
00942         int minutes=0;
00943         int seconds=0;
00944 
00945         /* make sure the user has rights to view system information */
00946         if(is_authorized_for_system_information(&current_authdata)==FALSE){
00947 
00948                 print_generic_error_message("It appears as though you do not have permission to view process information...","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);
00949 
00950                 return;
00951         }
00952 
00953         /* program start time */
00954         get_time_string(&program_start,start_time,(int)sizeof(start_time),SHORT_DATE_TIME);
00955 
00956         /* total running time */
00957         time(&current_time);
00958         run_time=(unsigned long)(current_time-program_start);
00959         get_time_breakdown(run_time,&days,&hours,&minutes,&seconds);
00960         sprintf(run_time_string,"%dd %dh %dm %ds",days,hours,minutes,seconds);
00961 
00962         /* last external check */
00963         get_time_string(&last_command_check,last_external_check_time,(int)sizeof(last_external_check_time),SHORT_DATE_TIME);
00964 
00965         /* last log file rotation */
00966         get_time_string(&last_log_rotation,last_log_rotation_time,(int)sizeof(last_log_rotation_time),SHORT_DATE_TIME);
00967 
00968         if (content_type==JSON_CONTENT) {
00969                 printf("\"process_info\": {\n");
00970                 printf("\"program_version\": \"%s\",\n",PROGRAM_VERSION);
00971                 printf("\"program_start_time\": \"%s\",\n",start_time);
00972                 printf("\"total_running_time\": \"%s\",\n",run_time_string);
00973                 if (last_command_check==(time_t)0)
00974                         printf("\"last_external_command_check\": null,\n");
00975                 else
00976                         printf("\"last_external_command_check\": \"%s\",\n",last_external_check_time);
00977                 if (last_log_rotation==(time_t)0)
00978                         printf("\"last_log_file_rotation\": null,\n");
00979                 else
00980                         printf("\"last_log_file_rotation\": \"%s\",\n",last_log_rotation_time);
00981 
00982                 printf("\"icinga_pid\": %d,\n",nagios_pid);
00983                 printf("\"notifications_enabled\": %s,\n",(enable_notifications==TRUE)?"true":"false");
00984                 printf("\"service_checks_being_executed\": %s,\n",(execute_service_checks==TRUE)?"true":"false");
00985                 printf("\"passive_service_checks_being_accepted\": %s,\n",(accept_passive_service_checks==TRUE)?"true":"false");
00986                 printf("\"host_checks_being_executed\": %s,\n",(execute_host_checks==TRUE)?"true":"false");
00987                 printf("\"passive_host_checks_being_accepted\": %s,\n",(accept_passive_host_checks==TRUE)?"true":"false");
00988                 printf("\"event_handlers_enabled\": %s,\n",(enable_event_handlers==TRUE)?"true":"false");
00989                 printf("\"obsessing_over_services\": %s,\n",(obsess_over_services==TRUE)?"true":"false");
00990                 printf("\"obsessing_over_hosts\": %s,\n",(obsess_over_hosts==TRUE)?"true":"false");
00991                 printf("\"flap_detection_enabled\": %s,\n",(enable_flap_detection==TRUE)?"true":"false");
00992                 printf("\"performance_data_being_processed\": %s\n",(process_performance_data==TRUE)?"true":"false");
00993 #ifdef PREDICT_FAILURES
00994                 printf(",\"failure_prediction_enabled\": %s\n",(enable_failure_prediction==TRUE)?"true":"false");
00995 #endif
00996 #ifdef USE_OLDCRUD
00997                 printf(",\"running_as_a_daemon\": %s\n",(daemon_mode==TRUE)?"true":"false");
00998 #endif
00999                 printf("}\n");
01000         } else if (content_type==CSV_CONTENT) {
01001                 /* csv header line */
01002                 printf("%sPROGRAM_VERSION%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01003                 printf("%sPROGRAM_START_TIME%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01004                 printf("%sTOTAL_RUNNING_TIME%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01005                 printf("%sLAST_EXTERNAL_COMMAND_CHECK%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01006                 printf("%sLAST_LOG_FILE_ROTATION%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01007                 printf("%sICINGA_PID%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01008                 printf("%sNOTIFICATIONS_ENABLED%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01009                 printf("%sSERVICE_CHECKS_BEING_EXECUTED%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01010                 printf("%sPASSIVE_SERVICE_CHECKS_BEING_ACCEPTED%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01011                 printf("%sHOST_CHECKS_BEING_EXECUTED%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01012                 printf("%sPASSIVE_HOST_CHECKS_BEING_ACCEPTED%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01013                 printf("%sEVENT_HANDLERS_ENABLED%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01014                 printf("%sOBSESSING_OVER_SERVICES%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01015                 printf("%sOBSESSING_OVER_HOSTS%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01016                 printf("%sFLAP_DETECTION_ENABLED%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01017                 printf("%sPERFORMANCE_DATA_BEING_PROCESSED%s",csv_data_enclosure,csv_data_enclosure);
01018 #ifdef PREDICT_FAILURES
01019                 printf("%s%sFAILURE_PREDICTION_ENABLED%s",csv_delimiter,csv_data_enclosure,csv_data_enclosure);
01020 #endif
01021 #ifdef USE_OLDCRUD
01022                 printf("%s%sRUNNING_AS_A_DAEMON%s",csv_delimiter,csv_data_enclosure,csv_data_enclosure,csv_delimiter);
01023 #endif
01024                 printf("\n");
01025 
01026                 /* csv data line */
01027                 printf("%s%s%s%s",csv_data_enclosure,PROGRAM_VERSION,csv_data_enclosure,csv_delimiter);
01028                 printf("%s%s%s%s",csv_data_enclosure,start_time,csv_data_enclosure,csv_delimiter);
01029                 printf("%s%s%s%s",csv_data_enclosure,run_time_string,csv_data_enclosure,csv_delimiter);
01030                 printf("%s%s%s%s",csv_data_enclosure,(last_command_check==(time_t)0)?"N/A":last_external_check_time,csv_data_enclosure,csv_delimiter);
01031                 printf("%s%s%s%s",csv_data_enclosure,(last_log_rotation==(time_t)0)?"N/A":last_log_rotation_time,csv_data_enclosure,csv_delimiter);
01032                 printf("%s%d%s%s",csv_data_enclosure,nagios_pid,csv_data_enclosure,csv_delimiter);
01033                 printf("%s%s%s%s",csv_data_enclosure,(enable_notifications==TRUE)?"YES":"NO",csv_data_enclosure,csv_delimiter);
01034                 printf("%s%s%s%s",csv_data_enclosure,(execute_service_checks==TRUE)?"YES":"NO",csv_data_enclosure,csv_delimiter);
01035                 printf("%s%s%s%s",csv_data_enclosure,(accept_passive_service_checks==TRUE)?"YES":"NO",csv_data_enclosure,csv_delimiter);
01036                 printf("%s%s%s%s",csv_data_enclosure,(execute_host_checks==TRUE)?"YES":"NO",csv_data_enclosure,csv_delimiter);
01037                 printf("%s%s%s%s",csv_data_enclosure,(accept_passive_host_checks==TRUE)?"YES":"NO",csv_data_enclosure,csv_delimiter);
01038                 printf("%s%s%s%s",csv_data_enclosure,(enable_event_handlers==TRUE)?"YES":"NO",csv_data_enclosure,csv_delimiter);
01039                 printf("%s%s%s%s",csv_data_enclosure,(obsess_over_services==TRUE)?"YES":"NO",csv_data_enclosure,csv_delimiter);
01040                 printf("%s%s%s%s",csv_data_enclosure,(obsess_over_hosts==TRUE)?"YES":"NO",csv_data_enclosure,csv_delimiter);
01041                 printf("%s%s%s%s",csv_data_enclosure,(enable_flap_detection==TRUE)?"YES":"NO",csv_data_enclosure,csv_delimiter);
01042                 printf("%s%s%s",csv_data_enclosure,(process_performance_data==TRUE)?"YES":"NO",csv_data_enclosure);
01043 #ifdef PREDICT_FAILURES
01044                 printf("%s%s%s%s",csv_delimiter,csv_data_enclosure,(enable_failure_prediction==TRUE)?"YES":"NO",csv_data_enclosure);
01045 #endif
01046 #ifdef USE_OLDCRUD
01047                 printf("%s%s%s%s",csv_delimiter,csv_data_enclosure,(daemon_mode==TRUE)?"YES":"NO",csv_data_enclosure);
01048 #endif
01049                 printf("\n");
01050         } else {
01051                 printf("<BR />\n");
01052 
01053                 /* add export to csv link */
01054                 printf("<DIV class='csv_export_link'><A HREF='%s' target='_blank'>Export to CSV</A></DIV>\n",get_export_csv_link(EXTINFO_CGI));
01055 
01056                 printf("<DIV ALIGN=CENTER>\n");
01057 
01058                 printf("<TABLE BORDER=0 CELLPADDING=20>\n");
01059                 printf("<TR><TD VALIGN=TOP>\n");
01060 
01061                 printf("<DIV CLASS='dataTitle'>Process Information</DIV>\n");
01062 
01063                 printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 CLASS='data'>\n");
01064                 printf("<TR><TD class='stateInfoTable1'>\n");
01065                 printf("<TABLE BORDER=0>\n");
01066 
01067                 /* program version */
01068                 printf("<TR><TD CLASS='dataVar'>Program Version:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",PROGRAM_VERSION);
01069 
01070                 /* program start time */
01071                 printf("<TR><TD CLASS='dataVar'>Program Start Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",start_time);
01072 
01073                 /* total running time */
01074                 printf("<TR><TD CLASS='dataVar'>Total Running Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",run_time_string);
01075 
01076                 /* last external check */
01077                 printf("<TR><TD CLASS='dataVar'>Last External Command Check:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(last_command_check==(time_t)0)?"N/A":last_external_check_time);
01078 
01079                 /* last log file rotation */
01080                 printf("<TR><TD CLASS='dataVar'>Last Log File Rotation:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(last_log_rotation==(time_t)0)?"N/A":last_log_rotation_time);
01081 
01082                 /* PID */
01083                 printf("<TR><TD CLASS='dataVar'>Icinga PID</TD><TD CLASS='dataVal'>%d</TD></TR>\n",nagios_pid);
01084 
01085                 /* notifications enabled */
01086                 printf("<TR><TD CLASS='dataVar'>Notifications Enabled?</TD><TD CLASS='dataVal'><DIV CLASS='notifications%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(enable_notifications==TRUE)?"ENABLED":"DISABLED",(enable_notifications==TRUE)?"YES":"NO");
01087 
01088                 /* service check execution enabled */
01089                 printf("<TR><TD CLASS='dataVar'>Service Checks Being Executed?</TD><TD CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(execute_service_checks==TRUE)?"ENABLED":"DISABLED",(execute_service_checks==TRUE)?"YES":"NO");
01090 
01091                 /* passive service check acceptance */
01092                 printf("<TR><TD CLASS='dataVar'>Passive Service Checks Being Accepted?</TD><TD CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(accept_passive_service_checks==TRUE)?"ENABLED":"DISABLED",(accept_passive_service_checks==TRUE)?"YES":"NO");
01093 
01094                 /* host check execution enabled */
01095                 printf("<TR><TD CLASS='dataVar'>Host Checks Being Executed?</TD><TD CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(execute_host_checks==TRUE)?"ENABLED":"DISABLED",(execute_host_checks==TRUE)?"YES":"NO");
01096 
01097                 /* passive host check acceptance */
01098                 printf("<TR><TD CLASS='dataVar'>Passive Host Checks Being Accepted?</TD><TD CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(accept_passive_host_checks==TRUE)?"ENABLED":"DISABLED",(accept_passive_host_checks==TRUE)?"YES":"NO");
01099 
01100                 /* event handlers enabled */
01101                 printf("<TR><TD CLASS='dataVar'>Event Handlers Enabled?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(enable_event_handlers==TRUE)?"Yes":"No");
01102 
01103                 /* obsessing over services */
01104                 printf("<TR><TD CLASS='dataVar'>Obsessing Over Services?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(obsess_over_services==TRUE)?"Yes":"No");
01105 
01106                 /* obsessing over hosts */
01107                 printf("<TR><TD CLASS='dataVar'>Obsessing Over Hosts?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(obsess_over_hosts==TRUE)?"Yes":"No");
01108 
01109                 /* flap detection enabled */
01110                 printf("<TR><TD CLASS='dataVar'>Flap Detection Enabled?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(enable_flap_detection==TRUE)?"Yes":"No");
01111 
01112 #ifdef PREDICT_FAILURES
01113                 /* failure prediction enabled */
01114                 printf("<TR><TD CLASS='dataVar'>Failure Prediction Enabled?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(enable_failure_prediction==TRUE)?"Yes":"No");
01115 #endif
01116 
01117                 /* process performance data */
01118                 printf("<TR><TD CLASS='dataVar'>Performance Data Being Processed?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(process_performance_data==TRUE)?"Yes":"No");
01119 
01120 #ifdef USE_OLDCRUD
01121                 /* daemon mode */
01122                 printf("<TR><TD CLASS='dataVar'>Running As A Daemon?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(daemon_mode==TRUE)?"Yes":"No");
01123 #endif
01124 
01125                 printf("</TABLE>\n");
01126                 printf("</TD></TR>\n");
01127                 printf("</TABLE>\n");
01128 
01129 
01130                 printf("</TD><TD VALIGN=TOP>\n");
01131 
01132                 printf("<DIV CLASS='commandTitle'>Process Commands</DIV>\n");
01133 
01134                 printf("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 CLASS='command'>\n");
01135                 printf("<TR><TD>\n");
01136 
01137                 if(nagios_process_state==STATE_OK){
01138                         printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 CLASS='command'>\n");
01139 
01140 #ifndef DUMMY_INSTALL
01141                         printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Shutdown the Icinga Process' TITLE='Shutdown the Icinga Process'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Shutdown the Icinga process</a></td></tr>\n",url_images_path,STOP_ICON,CMD_CGI,CMD_SHUTDOWN_PROCESS);
01142                         printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Restart the Icinga Process' TITLE='Restart the Icinga Process'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Restart the Icinga process</a></td></tr>\n",url_images_path,RESTART_ICON,CMD_CGI,CMD_RESTART_PROCESS);
01143 #endif
01144 
01145                         if(enable_notifications==TRUE)
01146                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Disable Notifications' TITLE='Disable Notifications'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Disable notifications</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_NOTIFICATIONS);
01147                         else
01148                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Enable Notifications' TITLE='Enable Notifications'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Enable notifications</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_NOTIFICATIONS);
01149 
01150                         if(execute_service_checks==TRUE)
01151                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Stop Executing Service Checks' TITLE='Stop Executing Service Checks'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Stop executing service checks</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_STOP_EXECUTING_SVC_CHECKS);
01152                         else
01153                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Start Executing Service Checks' TITLE='Start Executing Service Checks'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Start executing service checks</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_START_EXECUTING_SVC_CHECKS);
01154 
01155                         if(accept_passive_service_checks==TRUE)
01156                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Stop Accepting Passive Service Checks' TITLE='Stop Accepting Passive Service Checks'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Stop accepting passive service checks</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS);
01157                         else
01158                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Start Accepting Passive Service Checks' TITLE='Start Accepting Passive Service Checks'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Start accepting passive service checks</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS);
01159 
01160                         if(execute_host_checks==TRUE)
01161                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Stop Executing Host Checks' TITLE='Stop Executing Host Checks'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Stop executing host checks</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_STOP_EXECUTING_HOST_CHECKS);
01162                         else
01163                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Start Executing Host Checks' TITLE='Start Executing Host Checks'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Start executing host checks</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_START_EXECUTING_HOST_CHECKS);
01164 
01165                         if(accept_passive_host_checks==TRUE)
01166                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Stop Accepting Passive Host Checks' TITLE='Stop Accepting Passive Host Checks'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Stop accepting passive host checks</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS);
01167                         else
01168                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Start Accepting Passive Host Checks' TITLE='Start Accepting Passive Host Checks'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Start accepting passive host checks</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS);
01169 
01170                         if(enable_event_handlers==TRUE)
01171                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Disable Event Handlers' TITLE='Disable Event Handlers'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Disable event handlers</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_EVENT_HANDLERS);
01172                         else
01173                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Enable Event Handlers' TITLE='Enable Event Handlers'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Enable event handlers</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_EVENT_HANDLERS);
01174 
01175                         if(obsess_over_services==TRUE)
01176                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Stop Obsessing Over Services' TITLE='Stop Obsessing Over Services'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Stop obsessing over services</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_STOP_OBSESSING_OVER_SVC_CHECKS);
01177                         else
01178                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Start Obsessing Over Services' TITLE='Start Obsessing Over Services'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Start obsessing over services</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_START_OBSESSING_OVER_SVC_CHECKS);
01179 
01180                         if(obsess_over_hosts==TRUE)
01181                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Stop Obsessing Over Hosts' TITLE='Stop Obsessing Over Hosts'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Stop obsessing over hosts</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_STOP_OBSESSING_OVER_HOST_CHECKS);
01182                         else
01183                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Start Obsessing Over Hosts' TITLE='Start Obsessing Over Hosts'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Start obsessing over hosts</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_START_OBSESSING_OVER_HOST_CHECKS);
01184 
01185                         if(enable_flap_detection==TRUE)
01186                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Disable Flap Detection' TITLE='Disable Flap Detection'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Disable flap detection</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_FLAP_DETECTION);
01187                         else
01188                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Enable Flap Detection' TITLE='Enable Flap Detection'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Enable flap detection</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_FLAP_DETECTION);
01189 
01190 #ifdef PREDICT_FAILURES
01191                         if(enable_failure_prediction==TRUE)
01192                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Disable Failure Prediction' TITLE='Disable Failure Prediction'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Disable failure prediction</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_FAILURE_PREDICTION);
01193                         else
01194                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Enable Failure Prediction' TITLE='Enable Failure Prediction'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Enable failure prediction</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_FAILURE_PREDICTION);
01195 #endif
01196                         if(process_performance_data==TRUE)
01197                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Disable Performance Data' TITLE='Disable Performance Data'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Disable performance data</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_PERFORMANCE_DATA);
01198                         else
01199                                 printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Enable Performance Data' TITLE='Enable Performance Data'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Enable performance data</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_PERFORMANCE_DATA);
01200 
01201                         printf("</TABLE>\n");
01202                         }
01203                 else{
01204                         printf("<DIV ALIGN=CENTER CLASS='infoMessage'>It appears as though Icinga is not running, so commands are temporarily unavailable...\n");
01205                         if(!strcmp(nagios_check_command,"")){
01206                                 printf("<BR><BR>\n");
01207                                 printf("Hint: It looks as though you have not defined a command for checking the process state by supplying a value for the <b>nagios_check_command</b> option in the CGI configuration file.<BR>\n");
01208                                 printf("Read the documentation for more information on checking the status of the Icinga process in the CGIs.\n");
01209                                 }
01210                         printf("</DIV>\n");
01211                         }
01212 
01213                 printf("</TD></TR>\n");
01214                 printf("</TABLE>\n");
01215 
01216                 printf("</TD></TR></TABLE>\n");
01217                 printf("</DIV>\n");
01218         }
01219 }
01220 
01221 void show_host_info(void){
01222         hoststatus *temp_hoststatus;
01223         host *temp_host;
01224         char date_time[MAX_DATETIME_LENGTH];
01225         char state_duration[48];
01226         char status_age[48];
01227         char state_string[MAX_INPUT_BUFFER];
01228         char *bg_class="";
01229         char *buf=NULL;
01230         int days;
01231         int hours;
01232         int minutes;
01233         int seconds;
01234         time_t current_time;
01235         time_t ts_state_duration;
01236         time_t ts_state_age;
01237         int duration_error=FALSE;
01238 
01239 
01240         /* get host info */
01241         temp_host=find_host(host_name);
01242 
01243         /* make sure the user has rights to view host information */
01244         if(is_authorized_for_host(temp_host,&current_authdata)==FALSE){
01245                 print_generic_error_message("It appears as though you do not have permission to view information for this host...","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);
01246                 return;
01247         }
01248 
01249         /* get host status info */
01250         temp_hoststatus=find_hoststatus(host_name);
01251 
01252         /* make sure host information exists */
01253         if(temp_host==NULL){
01254                 print_generic_error_message("Error: Host Not Found!",NULL,0);
01255                 return;
01256         }
01257         if(temp_hoststatus==NULL){
01258                 print_generic_error_message("Error: Host Status Information Not Found!",NULL,0);
01259                 return;
01260         }
01261 
01262         /* calculate state duration */
01263         current_time=time(NULL);
01264         ts_state_duration=0;
01265         duration_error=FALSE;
01266         if(temp_hoststatus->last_state_change==(time_t)0){
01267                 if(program_start>current_time)
01268                         duration_error=TRUE;
01269                 else
01270                         ts_state_duration=current_time-program_start;
01271         }else{
01272                 if(temp_hoststatus->last_state_change>current_time)
01273                         duration_error=TRUE;
01274                 else
01275                         ts_state_duration=current_time-temp_hoststatus->last_state_change;
01276         }
01277         get_time_breakdown((unsigned long)ts_state_duration,&days,&hours,&minutes,&seconds);
01278         if(duration_error==TRUE)
01279                 snprintf(state_duration,sizeof(state_duration)-1,"???");
01280         else
01281                 snprintf(state_duration,sizeof(state_duration)-1,"%2dd %2dh %2dm %2ds%s",days,hours,minutes,seconds,(temp_hoststatus->last_state_change==(time_t)0)?"+":"");
01282         state_duration[sizeof(state_duration)-1]='\x0';
01283 
01284         /* calculate state age */
01285         ts_state_age=0;
01286         duration_error=FALSE;
01287         if(temp_hoststatus->last_check>current_time)
01288                 duration_error=TRUE;
01289         else
01290                 /*t=current_time-temp_hoststatus->last_check;*/
01291                 ts_state_age=current_time-temp_hoststatus->last_update;
01292         get_time_breakdown((unsigned long)ts_state_age,&days,&hours,&minutes,&seconds);
01293         if(duration_error==TRUE)
01294                 snprintf(status_age,sizeof(status_age)-1,"???");
01295         else if(temp_hoststatus->last_check==(time_t)0)
01296                 snprintf(status_age,sizeof(status_age)-1,"N/A");
01297         else
01298                 snprintf(status_age,sizeof(status_age)-1,"%2dd %2dh %2dm %2ds",days,hours,minutes,seconds);
01299         status_age[sizeof(status_age)-1]='\x0';
01300 
01301 
01302         if(temp_hoststatus->status==HOST_UP){
01303                 strcpy(state_string,"UP");
01304                 bg_class="hostUP";
01305         }else if(temp_hoststatus->status==HOST_DOWN){
01306                 strcpy(state_string,"DOWN");
01307                 bg_class="hostDOWN";
01308         }else if(temp_hoststatus->status==HOST_UNREACHABLE){
01309                 strcpy(state_string,"UNREACHABLE");
01310                 bg_class="hostUNREACHABLE";
01311         }
01312 
01313         if (content_type==JSON_CONTENT) {
01314                 printf("\"host_info\": {\n");
01315                 printf("\"host_name\": \"%s\",\n",json_encode(host_name));
01316                 if(temp_hoststatus->has_been_checked==FALSE)
01317                         printf("\"has_been_checked\": false\n");
01318                 else {
01319                         printf("\"has_been_checked\": true,\n");
01320                         printf("\"status\": \"%s\",\n",state_string);
01321                         printf("\"state_type\": \"%s\",\n",(temp_hoststatus->state_type==HARD_STATE)?"HARD":"SOFT");
01322                         if(duration_error==TRUE)
01323                                 printf("\"status_duration\": false,\n");
01324                         else
01325                                 printf("\"status_duration\": \"%s\",\n",state_duration);
01326                         printf("\"status_duration_in_seconds\": %lu,\n",(unsigned long)ts_state_duration);
01327                         if(temp_hoststatus->long_plugin_output!=NULL)
01328                                 printf("\"status_information\": \"%s %s\",\n",json_encode(temp_hoststatus->long_plugin_output),json_encode(temp_hoststatus->plugin_output));
01329                         else
01330                                 printf("\"status_information\": \"%s\",\n",json_encode(temp_hoststatus->plugin_output));
01331                         if (temp_hoststatus->perf_data==NULL)
01332                                 printf("\"performance_data\": null,\n");
01333                         else
01334                                 printf("\"performance_data\": \"%s\",\n",json_encode(temp_hoststatus->perf_data));
01335                         printf("\"current_attempt\": %d,\n",temp_hoststatus->current_attempt);
01336                         printf("\"max_attempts\": %d,\n",temp_hoststatus->max_attempts);
01337                         printf("\"check_type\": \"%s\",\n",(temp_hoststatus->check_type==HOST_CHECK_ACTIVE)?"active":"passive");
01338 
01339                         get_time_string(&temp_hoststatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01340                         printf("\"last_check_time\": \"%s\",\n",date_time);
01341 
01342                         if(temp_hoststatus->check_type==HOST_CHECK_ACTIVE)
01343                                 printf("\"check_latency\": %.3f,\n",temp_hoststatus->latency);
01344                         else
01345                                 printf("\"check_latency\": null,\n");
01346 
01347                         printf("\"check_duration\": %.3f,\n",temp_hoststatus->execution_time);
01348 
01349                         get_time_string(&temp_hoststatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01350                         if (temp_hoststatus->checks_enabled && temp_hoststatus->next_check!=(time_t)0 && temp_hoststatus->should_be_scheduled==TRUE)
01351                                 printf("\"next_scheduled_active_check\": \"%s\",\n",date_time);
01352                         else
01353                                 printf("\"next_scheduled_active_check\": null,\n");
01354 
01355                         get_time_string(&temp_hoststatus->last_state_change,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01356                         if (temp_hoststatus->last_state_change==(time_t)0)
01357                                 printf("\"last_state_change\": null,\n");
01358                         else
01359                                 printf("\"last_state_change\": \"%s\",\n",date_time);
01360 
01361                         get_time_string(&temp_hoststatus->last_notification,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01362                         if (temp_hoststatus->last_notification==(time_t)0)
01363                                 printf("\"last_notification\": null,\n");
01364                         else
01365                                 printf("\"last_notification\": \"%s\",\n",date_time);
01366                         printf("\"current_notification_number\": %d,\n",temp_hoststatus->current_notification_number);
01367                         if(temp_hoststatus->flap_detection_enabled==FALSE || enable_flap_detection==FALSE)
01368                                 printf("\"host_is_flapping\": null,\n");
01369                         else
01370                                 printf("\"host_is_flapping\": %s,\n",(temp_hoststatus->is_flapping==TRUE)?"true":"false");
01371                         printf("\"flapping_percent_state_change\": %3.2f,\n",temp_hoststatus->percent_state_change);
01372                         printf("\"host_in_scheduled_downtime\": %s,\n",(temp_hoststatus->scheduled_downtime_depth>0)?"true":"false");
01373 
01374                         get_time_string(&temp_hoststatus->last_update,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01375                         printf("\"last_update\": \"%s\",\n",date_time);
01376 
01377                         printf("\"active_checks_enabled\": %s,\n",(temp_hoststatus->checks_enabled==TRUE)?"true":"false");
01378                         printf("\"passive_checks_enabled\": %s,\n",(temp_hoststatus->accept_passive_host_checks==TRUE)?"true":"false");
01379                         printf("\"obsess_over_host\": %s,\n",(temp_hoststatus->obsess_over_host==TRUE)?"true":"false");
01380                         printf("\"notifications_enabled\": %s,\n",(temp_hoststatus->notifications_enabled==TRUE)?"true":"false");
01381                         printf("\"event_handler_enabled\": %s,\n",(temp_hoststatus->event_handler_enabled==TRUE)?"true":"false");
01382                         printf("\"flap_detection_enabled\": %s\n",(temp_hoststatus->flap_detection_enabled==TRUE)?"true":"false");
01383                         if(is_authorized_for_read_only(&current_authdata)==FALSE){
01384                                 /* display comments */
01385                                 printf(", \"comments\": [\n");
01386                                 show_comments(HOST_COMMENT);
01387                                 printf("], \"downtimes\": [\n");
01388                                 /* display downtimes */
01389                                 show_downtime(HOST_DOWNTIME);
01390                                 printf("]\n");
01391                         }
01392                         printf(" }\n");
01393                 }
01394         } else {
01395                 printf("<DIV ALIGN=CENTER>\n");
01396                 printf("<TABLE BORDER=0 CELLPADDING=0 WIDTH=100%%>\n");
01397                 printf("<TR>\n");
01398 
01399                 printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel'>\n");
01400 
01401                 printf("<DIV CLASS='dataTitle'>Host State Information</DIV>\n");
01402 
01403                 if(temp_hoststatus->has_been_checked==FALSE)
01404                         printf("<P><DIV ALIGN=CENTER>This host has not yet been checked, so status information is not available.</DIV></P>\n");
01405 
01406                 else{
01407 
01408                         printf("<TABLE BORDER=0>\n");
01409                         printf("<TR><TD>\n");
01410 
01411                         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
01412                         printf("<TR><TD class='stateInfoTable1'>\n");
01413                         printf("<TABLE BORDER=0>\n");
01414 
01415                         printf("<TR><TD CLASS='dataVar'>Host Status:</td><td CLASS='dataVal'><DIV CLASS='%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV>&nbsp;(for %s)%s</td></tr>\n",bg_class,state_string,state_duration,(temp_hoststatus->problem_has_been_acknowledged==TRUE)?"&nbsp;&nbsp;(Has been acknowledged)":"");
01416 
01417                         printf("<TR><TD CLASS='dataVar' VALIGN='top'>Status Information:</td><td CLASS='dataVal'>%s",(temp_hoststatus->plugin_output==NULL)?"":html_encode(temp_hoststatus->plugin_output,TRUE));
01418                         if(enable_splunk_integration==TRUE){
01419                                 printf("&nbsp;&nbsp;");
01420                                 dummy=asprintf(&buf,"%s %s",temp_host->name,temp_hoststatus->plugin_output);
01421                                 buf[sizeof(buf)-1]='\x0';
01422                                 display_splunk_generic_url(buf,1);
01423                                 free(buf);
01424                         }
01425                         if(temp_hoststatus->long_plugin_output!=NULL)
01426                                 printf("<BR>%s",html_encode(temp_hoststatus->long_plugin_output,TRUE));
01427                         printf("</TD></TR>\n");
01428 
01429                         printf("<TR><TD CLASS='dataVar' VALIGN='top'>Performance Data:</td><td CLASS='dataVal'>%s</td></tr>\n",(temp_hoststatus->perf_data==NULL)?"":html_encode(temp_hoststatus->perf_data,TRUE));
01430 
01431                         printf("<TR><TD CLASS='dataVar'>Current Attempt:</TD><TD CLASS='dataVal'>%d/%d",temp_hoststatus->current_attempt,temp_hoststatus->max_attempts);
01432                         printf("&nbsp;&nbsp;(%s state)</TD></TR>\n",(temp_hoststatus->state_type==HARD_STATE)?"HARD":"SOFT");
01433 
01434                         get_time_string(&temp_hoststatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01435                         printf("<TR><TD CLASS='dataVar'>Last Check Time:</td><td CLASS='dataVal'>%s</td></tr>\n",date_time);
01436 
01437                         if (temp_hoststatus->check_type==HOST_CHECK_ACTIVE)
01438                                 printf("<TR><TD CLASS='dataVar'>Check Type:</TD><TD CLASS='dataVal'><A HREF='%s?type=command&expand=%s'>ACTIVE</A></TD></TR>\n",
01439                                         CONFIG_CGI,url_encode(temp_host->host_check_command));
01440                         else printf("<TR><TD CLASS='dataVar'>Check Type:</TD><TD CLASS='dataVal'>PASSIVE</TD></TR>\n");
01441 
01442                         printf("<TR><TD CLASS='dataVar' NOWRAP>Check Latency / Duration:</TD><TD CLASS='dataVal'>");
01443                         if(temp_hoststatus->check_type==HOST_CHECK_ACTIVE)
01444                                 printf("%.3f",temp_hoststatus->latency);
01445                         else
01446                                 printf("N/A");
01447                         printf("&nbsp;/&nbsp;%.3f seconds",temp_hoststatus->execution_time);
01448                         printf("</TD></TR>\n");
01449 
01450                         get_time_string(&temp_hoststatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01451                         printf("<TR><TD CLASS='dataVar'>Next Scheduled Active Check:&nbsp;&nbsp;</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(temp_hoststatus->checks_enabled && temp_hoststatus->next_check!=(time_t)0 && temp_hoststatus->should_be_scheduled==TRUE)?date_time:"N/A");
01452 
01453                         get_time_string(&temp_hoststatus->last_state_change,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01454                         printf("<TR><TD CLASS='dataVar'>Last State Change:</td><td CLASS='dataVal'>%s</td></tr>\n",(temp_hoststatus->last_state_change==(time_t)0)?"N/A":date_time);
01455 
01456                         get_time_string(&temp_hoststatus->last_notification,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01457                         printf("<TR><TD CLASS='dataVar'>Last Notification:</td><td CLASS='dataVal'>%s&nbsp;(notification %d)</td></tr>\n",(temp_hoststatus->last_notification==(time_t)0)?"N/A":date_time,temp_hoststatus->current_notification_number);
01458 
01459                         printf("<TR><TD CLASS='dataVar'>Is This Host Flapping?</td><td CLASS='dataVal'>");
01460                         if(temp_hoststatus->flap_detection_enabled==FALSE || enable_flap_detection==FALSE)
01461                                 printf("N/A");
01462                         else
01463                                 printf("<DIV CLASS='%sflapping'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV>&nbsp;(%3.2f%% state change)",(temp_hoststatus->is_flapping==TRUE)?"":"not",(temp_hoststatus->is_flapping==TRUE)?"YES":"NO",temp_hoststatus->percent_state_change);
01464                         printf("</td></tr>\n");
01465 
01466                         printf("<TR><TD CLASS='dataVar'>In Scheduled Downtime?</td><td CLASS='dataVal'><DIV CLASS='downtime%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></td></tr>\n",(temp_hoststatus->scheduled_downtime_depth>0)?"ACTIVE":"INACTIVE",(temp_hoststatus->scheduled_downtime_depth>0)?"YES":"NO");
01467 
01468 
01469                         get_time_string(&temp_hoststatus->last_update,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01470                         printf("<TR><TD CLASS='dataVar'>Last Update:</td><td CLASS='dataVal'>%s&nbsp;&nbsp;(%s ago)</td></tr>\n",(temp_hoststatus->last_update==(time_t)0)?"N/A":date_time,status_age);
01471 
01472                         printf("</TABLE>\n");
01473                         printf("</TD></TR>\n");
01474                         printf("</TABLE>\n");
01475 
01476                         printf("</TD></TR>\n");
01477                         printf("<TR><TD>\n");
01478 
01479                         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
01480                         printf("<TR><TD class='stateInfoTable2'>\n");
01481                         printf("<TABLE BORDER=0>\n");
01482 
01483                         if ((temp_host->host_check_command)&&(*temp_host->host_check_command!='\0'))
01484                                 printf("<TR><TD CLASS='dataVar'><A HREF='%s?type=command&expand=%s'>Active Checks:</A></TD><TD CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",CONFIG_CGI,url_encode(temp_host->host_check_command),(temp_hoststatus->checks_enabled==TRUE)?"ENABLED":"DISABLED",(temp_hoststatus->checks_enabled==TRUE)?"ENABLED":"DISABLED");
01485                         else printf("<TR><TD CLASS='dataVar'>Active Checks:</TD><TD CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(temp_hoststatus->checks_enabled==TRUE)?"ENABLED":"DISABLED",(temp_hoststatus->checks_enabled==TRUE)?"ENABLED":"DISABLED");
01486 
01487                         printf("<TR><TD CLASS='dataVar'>Passive Checks:</TD><td CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(temp_hoststatus->accept_passive_host_checks==TRUE)?"ENABLED":"DISABLED",(temp_hoststatus->accept_passive_host_checks)?"ENABLED":"DISABLED");
01488 
01489                         printf("<TR><TD CLASS='dataVar'>Obsessing:</TD><td CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(temp_hoststatus->obsess_over_host==TRUE)?"ENABLED":"DISABLED",(temp_hoststatus->obsess_over_host)?"ENABLED":"DISABLED");
01490 
01491                         printf("<TR><TD CLASS='dataVar'>Notifications:</td><td CLASS='dataVal'><DIV CLASS='notifications%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></td></tr>\n",(temp_hoststatus->notifications_enabled)?"ENABLED":"DISABLED",(temp_hoststatus->notifications_enabled)?"ENABLED":"DISABLED");
01492 
01493                         if ((temp_host->event_handler)&&(*temp_host->event_handler!='\0'))
01494                                 printf("<TR><TD CLASS='dataVar'><A HREF='%s?type=command&expand=%s'>Event Handler:</A></td><td CLASS='dataVal'><DIV CLASS='eventhandlers%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></td></tr>\n",CONFIG_CGI,url_encode(temp_host->event_handler),(temp_hoststatus->event_handler_enabled)?"ENABLED":"DISABLED",(temp_hoststatus->event_handler_enabled)?"ENABLED":"DISABLED");
01495                         else printf("<TR><TD CLASS='dataVar'>Event Handler:</td><td CLASS='dataVal'><DIV CLASS='eventhandlers%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></td></tr>\n",(temp_hoststatus->event_handler_enabled)?"ENABLED":"DISABLED",(temp_hoststatus->event_handler_enabled)?"ENABLED":"DISABLED");
01496 
01497 
01498                         printf("<TR><TD CLASS='dataVar'>Flap Detection:</td><td CLASS='dataVal'><DIV CLASS='flapdetection%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></td></tr>\n",(temp_hoststatus->flap_detection_enabled==TRUE)?"ENABLED":"DISABLED",(temp_hoststatus->flap_detection_enabled==TRUE)?"ENABLED":"DISABLED");
01499 
01500                         printf("</TABLE>\n");
01501                         printf("</TD></TR>\n");
01502                         printf("</TABLE>\n");
01503 
01504                         printf("</TD></TR>\n");
01505                         printf("</TABLE>\n");
01506                 }
01507 
01508                 printf("</TD>\n");
01509 
01510                 printf("<TD ALIGN=CENTER VALIGN=TOP>\n");
01511                 printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR>\n");
01512 
01513                 printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='commandPanel'>\n");
01514 
01515                 printf("<DIV CLASS='commandTitle'>Host Commands</DIV>\n");
01516 
01517                 printf("<TABLE BORDER='1' CELLPADDING=0 CELLSPACING=0><TR><TD>\n");
01518 
01519                 if(nagios_process_state==STATE_OK && is_authorized_for_read_only(&current_authdata)==FALSE){
01520 
01521                         printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
01522         #ifdef USE_STATUSMAP
01523                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Locate Host On Map' TITLE='Locate Host On Map'></td><td CLASS='command'><a href='%s?host=%s'>Locate host on map</a></td></tr>\n",url_images_path,STATUSMAP_ICON,STATUSMAP_CGI,url_encode(host_name));
01524         #endif
01525                         if(temp_hoststatus->checks_enabled==TRUE){
01526                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Active Checks Of This Host' TITLE='Disable Active Checks Of This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Disable active checks of this host</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_HOST_CHECK,url_encode(host_name));
01527                         }else
01528                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Active Checks Of This Host' TITLE='Enable Active Checks Of This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Enable active checks of this host</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_HOST_CHECK,url_encode(host_name));
01529                         printf("<tr CLASS='data'><td><img src='%s%s' border=0 ALT='Re-schedule Next Host Check' TITLE='Re-schedule Next Host Check'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s%s'>Re-schedule the next check of this host</a></td></tr>\n",url_images_path,DELAY_ICON,CMD_CGI,CMD_SCHEDULE_HOST_CHECK,url_encode(host_name),(temp_hoststatus->checks_enabled==TRUE)?"&force_check":"");
01530 
01531                         if(temp_hoststatus->accept_passive_host_checks==TRUE){
01532                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Submit Passive Check Result For This Host' TITLE='Submit Passive Check Result For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Submit passive check result for this host</a></td></tr>\n",url_images_path,PASSIVE_ICON,CMD_CGI,CMD_PROCESS_HOST_CHECK_RESULT,url_encode(host_name));
01533                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Stop Accepting Passive Checks For This Host' TITLE='Stop Accepting Passive Checks For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Stop accepting passive checks for this host</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_PASSIVE_HOST_CHECKS,url_encode(host_name));
01534                         }else
01535                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Start Accepting Passive Checks For This Host' TITLE='Start Accepting Passive Checks For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Start accepting passive checks for this host</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_PASSIVE_HOST_CHECKS,url_encode(host_name));
01536 
01537                         if(temp_hoststatus->obsess_over_host==TRUE)
01538                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Stop Obsessing Over This Host' TITLE='Stop Obsessing Over This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Stop obsessing over this host</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_STOP_OBSESSING_OVER_HOST,url_encode(host_name));
01539                         else
01540                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Start Obsessing Over This Host' TITLE='Start Obsessing Over This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Start obsessing over this host</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_START_OBSESSING_OVER_HOST,url_encode(host_name));
01541 
01542                         if(temp_hoststatus->status==HOST_DOWN || temp_hoststatus->status==HOST_UNREACHABLE){
01543                                 if(temp_hoststatus->problem_has_been_acknowledged==FALSE)
01544                                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Acknowledge This Host Problem' TITLE='Acknowledge This Host Problem'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Acknowledge this host problem</a></td></tr>\n",url_images_path,ACKNOWLEDGEMENT_ICON,CMD_CGI,CMD_ACKNOWLEDGE_HOST_PROBLEM,url_encode(host_name));
01545                                 else
01546                                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Remove Problem Acknowledgement' TITLE='Remove Problem Acknowledgement'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Remove problem acknowledgement</a></td></tr>\n",url_images_path,REMOVE_ACKNOWLEDGEMENT_ICON,CMD_CGI,CMD_REMOVE_HOST_ACKNOWLEDGEMENT,url_encode(host_name));
01547                         }
01548 
01549                         if(temp_hoststatus->notifications_enabled==TRUE)
01550                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Notifications For This Host' TITLE='Disable Notifications For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Disable notifications for this host</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_HOST_NOTIFICATIONS,url_encode(host_name));
01551                         else
01552                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Notifications For This Host' TITLE='Enable Notifications For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Enable notifications for this host</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_HOST_NOTIFICATIONS,url_encode(host_name));
01553 
01554                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Send Custom Notification' TITLE='Send Custom Notification'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Send custom host notification</a></td></tr>\n",url_images_path,NOTIFICATION_ICON,CMD_CGI,CMD_SEND_CUSTOM_HOST_NOTIFICATION,url_encode(host_name));
01555 
01556                         if(temp_hoststatus->status!=HOST_UP)
01557                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Delay Next Host Notification' TITLE='Delay Next Host Notification'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Delay next host notification</a></td></tr>\n",url_images_path,DELAY_ICON,CMD_CGI,CMD_DELAY_HOST_NOTIFICATION,url_encode(host_name));
01558 
01559                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For This Host' TITLE='Schedule Downtime For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Schedule downtime for this host</a></td></tr>\n",url_images_path,DOWNTIME_ICON,CMD_CGI,CMD_SCHEDULE_HOST_DOWNTIME,url_encode(host_name));
01560 
01561                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For This Host and All Services' TITLE='Schedule Downtime For This Host and All Services'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Schedule downtime for this host and all services</a></td></tr>\n",url_images_path,DOWNTIME_ICON,CMD_CGI,CMD_SCHEDULE_HOST_SVC_DOWNTIME,url_encode(host_name));
01562 
01563                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Notifications For All Services On This Host' TITLE='Disable Notifications For All Services On This Host'></td><td CLASS='command' NOWRAP><a href='%s?cmd_typ=%d&host=%s'>Disable notifications for all services on this host</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_HOST_SVC_NOTIFICATIONS,url_encode(host_name));
01564 
01565                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Notifications For All Services On This Host' TITLE='Enable Notifications For All Services On This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Enable notifications for all services on this host</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_HOST_SVC_NOTIFICATIONS,url_encode(host_name));
01566 
01567                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule A Check Of All Services On This Host' TITLE='Schedule A Check Of All Services On This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Schedule a check of all services on this host</a></td></tr>\n",url_images_path,DELAY_ICON,CMD_CGI,CMD_SCHEDULE_HOST_SVC_CHECKS,url_encode(host_name));
01568 
01569                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Checks Of All Services On This Host' TITLE='Disable Checks Of All Services On This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Disable checks of all services on this host</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_HOST_SVC_CHECKS,url_encode(host_name));
01570 
01571                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Checks Of All Services On This Host' TITLE='Enable Checks Of All Services On This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Enable checks of all services on this host</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_HOST_SVC_CHECKS,url_encode(host_name));
01572 
01573                         if(temp_hoststatus->event_handler_enabled==TRUE)
01574                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Event Handler For This Host' TITLE='Disable Event Handler For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Disable event handler for this host</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_HOST_EVENT_HANDLER,url_encode(host_name));
01575                         else
01576                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Event Handler For This Host' TITLE='Enable Event Handler For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Enable event handler for this host</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_HOST_EVENT_HANDLER,url_encode(host_name));
01577                         if(temp_hoststatus->flap_detection_enabled==TRUE)
01578                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Flap Detection For This Host' TITLE='Disable Flap Detection For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Disable flap detection for this host</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_HOST_FLAP_DETECTION,url_encode(host_name));
01579                         else
01580                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Flap Detection For This Host' TITLE='Enable Flap Detection For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Enable flap detection for this host</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_HOST_FLAP_DETECTION,url_encode(host_name));
01581 
01582                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Add a new Host comment' TITLE='Add a new Host comment'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>",url_images_path,COMMENT_ICON,CMD_CGI,CMD_ADD_HOST_COMMENT,(display_type==DISPLAY_COMMENTS)?"":url_encode(host_name));
01583                         printf("Add a new Host comment</a></td>");
01584 
01585 
01586                         printf("</TABLE>\n");
01587                 }else if (is_authorized_for_read_only(&current_authdata)==TRUE){
01588                         printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to execute commands.<br>\n");
01589                 }else{
01590                         printf("<DIV ALIGN=CENTER CLASS='infoMessage'>It appears as though Icinga is not running, so commands are temporarily unavailable...<br>\n");
01591                         printf("Click <a href='%s?type=%d'>here</a> to view Icinga process information</DIV>\n",EXTINFO_CGI,DISPLAY_PROCESS_INFO);
01592                 }
01593                 printf("</TD></TR></TABLE>\n");
01594 
01595                 printf("</TD>\n");
01596 
01597                 printf("</TR>\n");
01598                 printf("</TABLE></TR>\n");
01599 
01600                 printf("<TR>\n");
01601 
01602                 printf("<TD COLSPAN=2 ALIGN=CENTER VALIGN=TOP CLASS='commentPanel'>\n");
01603 
01604                 if(is_authorized_for_read_only(&current_authdata)==FALSE){
01605                         /* display comments */
01606                         show_comments(HOST_COMMENT);
01607                         printf("<BR>");
01608                         /* display downtimes */
01609                         show_downtime(HOST_DOWNTIME);
01610                 }
01611 
01612                 printf("</TD>\n");
01613 
01614                 printf("</TR>\n");
01615                 printf("</TABLE>\n");
01616                 printf("</DIV>\n");
01617         }
01618 
01619         return;
01620 }
01621 
01622 void show_service_info(void){
01623         service *temp_service;
01624         char date_time[MAX_DATETIME_LENGTH];
01625         char status_age[48];
01626         char state_duration[48];
01627         servicestatus *temp_svcstatus;
01628         char state_string[MAX_INPUT_BUFFER];
01629         char *bg_class="";
01630         char *buf=NULL;
01631         int days;
01632         int hours;
01633         int minutes;
01634         int seconds;
01635         time_t ts_state_duration=0L;
01636         time_t ts_state_age=0L;
01637         time_t current_time;
01638         int duration_error=FALSE;
01639 
01640         /* find the service */
01641         temp_service=find_service(host_name,service_desc);
01642 
01643         /* make sure the user has rights to view service information */
01644         if(is_authorized_for_service(temp_service,&current_authdata)==FALSE){
01645 
01646                 print_generic_error_message("It appears as though you do not have permission to view information for this service...","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);
01647 
01648                 return;
01649         }
01650 
01651         /* get service status info */
01652         temp_svcstatus=find_servicestatus(host_name,service_desc);
01653 
01654         /* make sure service information exists */
01655         if(temp_service==NULL){
01656                 print_generic_error_message("Error: Service Not Found!",NULL,0);
01657                 return;
01658         }
01659         if(temp_svcstatus==NULL){
01660                 print_generic_error_message("Error: Service Status Not Found!",NULL,0);
01661                 return;
01662         }
01663 
01664 
01665         current_time=time(NULL);
01666         duration_error=FALSE;
01667         if(temp_svcstatus->last_state_change==(time_t)0){
01668                 if(program_start>current_time)
01669                         duration_error=TRUE;
01670                 else
01671                         ts_state_duration=current_time-program_start;
01672         }else{
01673                 if(temp_svcstatus->last_state_change>current_time)
01674                         duration_error=TRUE;
01675                 else
01676                         ts_state_duration=current_time-temp_svcstatus->last_state_change;
01677         }
01678         get_time_breakdown((unsigned long)ts_state_duration,&days,&hours,&minutes,&seconds);
01679         if(duration_error==TRUE)
01680                 snprintf(state_duration,sizeof(state_duration)-1,"???");
01681         else
01682                 snprintf(state_duration,sizeof(state_duration)-1,"%2dd %2dh %2dm %2ds%s",days,hours,minutes,seconds,(temp_svcstatus->last_state_change==(time_t)0)?"+":"");
01683         state_duration[sizeof(state_duration)-1]='\x0';
01684 
01685         if(temp_svcstatus->status==SERVICE_OK){
01686                 strcpy(state_string,"OK");
01687                 bg_class="serviceOK";
01688         }else if(temp_svcstatus->status==SERVICE_WARNING){
01689                 strcpy(state_string,"WARNING");
01690                 bg_class="serviceWARNING";
01691         }else if(temp_svcstatus->status==SERVICE_CRITICAL){
01692                 strcpy(state_string,"CRITICAL");
01693                 bg_class="serviceCRITICAL";
01694         }else{
01695                 strcpy(state_string,"UNKNOWN");
01696                 bg_class="serviceUNKNOWN";
01697         }
01698 
01699         duration_error=FALSE;
01700         if(temp_svcstatus->last_check>current_time)
01701                 duration_error=TRUE;
01702         else
01703                 ts_state_age=current_time-temp_svcstatus->last_update;
01704         get_time_breakdown((unsigned long)ts_state_age,&days,&hours,&minutes,&seconds);
01705         if(duration_error==TRUE)
01706                 snprintf(status_age,sizeof(status_age)-1,"???");
01707         else if(temp_svcstatus->last_check==(time_t)0)
01708                 snprintf(status_age,sizeof(status_age)-1,"N/A");
01709         else
01710                 snprintf(status_age,sizeof(status_age)-1,"%2dd %2dh %2dm %2ds",days,hours,minutes,seconds);
01711         status_age[sizeof(status_age)-1]='\x0';
01712         
01713         if (content_type==JSON_CONTENT) {
01714                 printf("\"service_info\": {\n");
01715                 printf("\"host_name\": \"%s\",\n",json_encode(host_name));
01716                 printf("\"service_description\": \"%s\",\n",json_encode(service_desc));
01717                 if(temp_svcstatus->has_been_checked==FALSE)
01718                         printf("\"has_been_checked\": false\n");
01719                 else {
01720                         printf("\"has_been_checked\": true,\n");
01721                         printf("\"status\": \"%s\",\n",state_string);
01722                         printf("\"state_type\": \"%s\",\n",(temp_svcstatus->state_type==HARD_STATE)?"HARD":"SOFT");
01723                         if(duration_error==TRUE)
01724                                 printf("\"status_duration\": false,\n");
01725                         else
01726                                 printf("\"status_duration\": \"%s\",\n",state_duration);
01727                         printf("\"status_duration_in_seconds\": %lu,\n",(unsigned long)ts_state_duration);
01728                         if(temp_svcstatus->long_plugin_output!=NULL)
01729                                 printf("\"status_information\": \"%s %s\",\n",json_encode(temp_svcstatus->long_plugin_output),json_encode(temp_svcstatus->plugin_output));
01730                         else
01731                                 printf("\"status_information\": \"%s\",\n",json_encode(temp_svcstatus->plugin_output));
01732                         if (temp_svcstatus->perf_data==NULL)
01733                                 printf("\"performance_data\": null,\n");
01734                         else
01735                                 printf("\"performance_data\": \"%s\",\n",json_encode(temp_svcstatus->perf_data));
01736                         printf("\"current_attempt\": %d,\n",temp_svcstatus->current_attempt);
01737                         printf("\"max_attempts\": %d,\n",temp_svcstatus->max_attempts);
01738                         printf("\"check_type\": \"%s\",\n",(temp_svcstatus->check_type==SERVICE_CHECK_ACTIVE)?"active":"passive");
01739 
01740                         get_time_string(&temp_svcstatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01741                         printf("\"last_check_time\": \"%s\",\n",date_time);
01742 
01743                         if(temp_svcstatus->check_type==SERVICE_CHECK_ACTIVE)
01744                                 printf("\"check_latency\": %.3f,\n",temp_svcstatus->latency);
01745                         else
01746                                 printf("\"check_latency\": null,\n");
01747                         printf("\"check_duration\": %.3f,\n",temp_svcstatus->execution_time);
01748 
01749                         get_time_string(&temp_svcstatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01750                         if (temp_svcstatus->checks_enabled && temp_svcstatus->next_check!=(time_t)0 && temp_svcstatus->should_be_scheduled==TRUE)
01751                                 printf("\"next_scheduled_active_check\": \"%s\",\n",date_time);
01752                         else
01753                                 printf("\"next_scheduled_active_check\": null,\n");
01754 
01755                         get_time_string(&temp_svcstatus->last_state_change,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01756                         if (temp_svcstatus->last_state_change==(time_t)0)
01757                                 printf("\"last_state_change\": null,\n");
01758                         else
01759                                 printf("\"last_state_change\": \"%s\",\n",date_time);
01760 
01761                         get_time_string(&temp_svcstatus->last_notification,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01762                         if (temp_svcstatus->last_notification==(time_t)0)
01763                                 printf("\"last_notification\": null,\n");
01764                         else
01765                                 printf("\"last_notification\": \"%s\",\n",date_time);
01766                         printf("\"current_notification_number\": %d,\n",temp_svcstatus->current_notification_number);
01767                         if(temp_svcstatus->flap_detection_enabled==FALSE || enable_flap_detection==FALSE)
01768                                 printf("\"service_is_flapping\": null,\n");
01769                         else
01770                                 printf("\"service_is_flapping\": %s,\n",(temp_svcstatus->is_flapping==TRUE)?"true":"false");
01771                         printf("\"flapping_percent_state_change\": %3.2f,\n",temp_svcstatus->percent_state_change);
01772                         printf("\"service_in_scheduled_downtime\": %s,\n",(temp_svcstatus->scheduled_downtime_depth>0)?"true":"false");
01773 
01774                         get_time_string(&temp_svcstatus->last_update,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01775                         printf("\"last_update\": \"%s\",\n",date_time);
01776 
01777                         printf("\"active_checks_enabled\": %s,\n",(temp_svcstatus->checks_enabled==TRUE)?"true":"false");
01778                         printf("\"passive_checks_enabled\": %s,\n",(temp_svcstatus->accept_passive_service_checks==TRUE)?"true":"false");
01779                         printf("\"obsess_over_service\": %s,\n",(temp_svcstatus->obsess_over_service==TRUE)?"true":"false");
01780                         printf("\"notifications_enabled\": %s,\n",(temp_svcstatus->notifications_enabled==TRUE)?"true":"false");
01781                         printf("\"event_handler_enabled\": %s,\n",(temp_svcstatus->event_handler_enabled==TRUE)?"true":"false");
01782                         printf("\"flap_detection_enabled\": %s\n",(temp_svcstatus->flap_detection_enabled==TRUE)?"true":"false");
01783                         if(is_authorized_for_read_only(&current_authdata)==FALSE){
01784                                 /* display comments */
01785                                 printf(", \"comments\": [\n");
01786                                 show_comments(SERVICE_COMMENT);
01787                                 printf("], \"downtimes\": [\n");
01788                                 /* display downtimes */
01789                                 show_downtime(SERVICE_DOWNTIME);
01790                                 printf("]\n");
01791                         }
01792                         printf(" }\n");
01793                 }
01794         }else{
01795                 printf("<DIV ALIGN=CENTER>\n");
01796                 printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%%>\n");
01797                 printf("<TR>\n");
01798 
01799                 printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel'>\n");
01800 
01801                 printf("<DIV CLASS='dataTitle'>Service State Information</DIV>\n");
01802 
01803                 if(temp_svcstatus->has_been_checked==FALSE)
01804                         printf("<P><DIV ALIGN=CENTER>This service has not yet been checked, so status information is not available.</DIV></P>\n");
01805 
01806                 else{
01807 
01808                         printf("<TABLE BORDER=0>\n");
01809 
01810                         printf("<TR><TD>\n");
01811 
01812                         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
01813                         printf("<TR><TD class='stateInfoTable1'>\n");
01814                         printf("<TABLE BORDER=0>\n");
01815 
01816                         printf("<TR><TD CLASS='dataVar'>Current Status:</TD><TD CLASS='dataVal'><DIV CLASS='%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV>&nbsp;(for %s)%s</TD></TR>\n",bg_class,state_string,state_duration,(temp_svcstatus->problem_has_been_acknowledged==TRUE)?"&nbsp;&nbsp;(Has been acknowledged)":"");
01817 
01818                         printf("<TR><TD CLASS='dataVar' VALIGN='top'>Status Information:</TD><TD CLASS='dataVal'>%s",(temp_svcstatus->plugin_output==NULL)?"":html_encode(temp_svcstatus->plugin_output,TRUE));
01819                         if(enable_splunk_integration==TRUE){
01820                                 printf("&nbsp;&nbsp;");
01821                                 dummy=asprintf(&buf,"%s %s %s",temp_service->host_name,temp_service->description,temp_svcstatus->plugin_output);
01822                                 buf[sizeof(buf)-1]='\x0';
01823                                 display_splunk_generic_url(buf,1);
01824                                 free(buf);
01825                         }
01826                         if(temp_svcstatus->long_plugin_output!=NULL)
01827                                 printf("<BR>%s",html_encode(temp_svcstatus->long_plugin_output,TRUE));
01828                         printf("</TD></TR>\n");
01829 
01830                         printf("<TR><TD CLASS='dataVar' VALIGN='top'>Performance Data:</td><td CLASS='dataVal'>%s</td></tr>\n",(temp_svcstatus->perf_data==NULL)?"":html_encode(temp_svcstatus->perf_data,TRUE));
01831 
01832                         printf("<TR><TD CLASS='dataVar'>Current Attempt:</TD><TD CLASS='dataVal'>%d/%d",temp_svcstatus->current_attempt,temp_svcstatus->max_attempts);
01833                         printf("&nbsp;&nbsp;(%s state)</TD></TR>\n",(temp_svcstatus->state_type==HARD_STATE)?"HARD":"SOFT");
01834 
01835                         get_time_string(&temp_svcstatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01836                         printf("<TR><TD CLASS='dataVar'>Last Check Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",date_time);
01837 
01838                         if (temp_svcstatus->check_type==SERVICE_CHECK_ACTIVE)
01839                                 printf("<TR><TD CLASS='dataVar'>Check Type:</TD><TD CLASS='dataVal'><A HREF='%s?type=command&expand=%s'>ACTIVE</A></TD></TR>\n",
01840                                         CONFIG_CGI,url_encode(temp_service->service_check_command));
01841                         else printf("<TR><TD CLASS='dataVar'>Check Type:</TD><TD CLASS='dataVal'>PASSIVE</TD></TR>\n");
01842 
01843                         printf("<TR><TD CLASS='dataVar' NOWRAP>Check Latency / Duration:</TD><TD CLASS='dataVal'>");
01844                         if(temp_svcstatus->check_type==SERVICE_CHECK_ACTIVE)
01845                                 printf("%.3f",temp_svcstatus->latency);
01846                         else
01847                                 printf("N/A");
01848                         printf("&nbsp;/&nbsp;%.3f seconds",temp_svcstatus->execution_time);
01849                         printf("</TD></TR>\n");
01850 
01851                         get_time_string(&temp_svcstatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01852                         printf("<TR><TD CLASS='dataVar'>Next Scheduled Check:&nbsp;&nbsp;</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(temp_svcstatus->checks_enabled && temp_svcstatus->next_check!=(time_t)0 && temp_svcstatus->should_be_scheduled==TRUE)?date_time:"N/A");
01853 
01854                         get_time_string(&temp_svcstatus->last_state_change,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01855                         printf("<TR><TD CLASS='dataVar'>Last State Change:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(temp_svcstatus->last_state_change==(time_t)0)?"N/A":date_time);
01856 
01857                         get_time_string(&temp_svcstatus->last_notification,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01858                         printf("<TR><TD CLASS='dataVar'>Last Notification:</TD><TD CLASS='dataVal'>%s&nbsp;(notification %d)</TD></TR>\n",(temp_svcstatus->last_notification==(time_t)0)?"N/A":date_time,temp_svcstatus->current_notification_number);
01859 
01860                         printf("<TR><TD CLASS='dataVar'>Is This Service Flapping?</TD><TD CLASS='dataVal'>");
01861                         if(temp_svcstatus->flap_detection_enabled==FALSE || enable_flap_detection==FALSE)
01862                                 printf("N/A");
01863                         else
01864                                 printf("<DIV CLASS='%sflapping'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV>&nbsp;(%3.2f%% state change)",(temp_svcstatus->is_flapping==TRUE)?"":"not",(temp_svcstatus->is_flapping==TRUE)?"YES":"NO",temp_svcstatus->percent_state_change);
01865                         printf("</TD></TR>\n");
01866 
01867                         printf("<TR><TD CLASS='dataVar'>In Scheduled Downtime?</TD><TD CLASS='dataVal'><DIV CLASS='downtime%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(temp_svcstatus->scheduled_downtime_depth>0)?"ACTIVE":"INACTIVE",(temp_svcstatus->scheduled_downtime_depth>0)?"YES":"NO");
01868 
01869 
01870                         get_time_string(&temp_svcstatus->last_update,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
01871                         printf("<TR><TD CLASS='dataVar'>Last Update:</TD><TD CLASS='dataVal'>%s&nbsp;&nbsp;(%s ago)</TD></TR>\n",(temp_svcstatus->last_update==(time_t)0)?"N/A":date_time,status_age);
01872 
01873 
01874                         printf("</TABLE>\n");
01875                         printf("</TD></TR>\n");
01876                         printf("</TABLE>\n");
01877 
01878                         printf("</TD></TR>\n");
01879 
01880                         printf("<TR><TD>\n");
01881 
01882                         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
01883                         printf("<TR><TD class='stateInfoTable2'>\n");
01884                         printf("<TABLE BORDER=0>\n");
01885 
01886                         if ((temp_service->service_check_command)&&(*temp_service->service_check_command!='\0'))
01887                                 printf("<TR><TD CLASS='dataVar'><A HREF='%s?type=command&expand=%s'>Active Checks:</A></TD><td CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",CONFIG_CGI,url_encode(temp_service->service_check_command),(temp_svcstatus->checks_enabled)?"ENABLED":"DISABLED",(temp_svcstatus->checks_enabled)?"ENABLED":"DISABLED");
01888                         else printf("<TR><TD CLASS='dataVar'>Active Checks:</TD><td CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(temp_svcstatus->checks_enabled)?"ENABLED":"DISABLED",(temp_svcstatus->checks_enabled)?"ENABLED":"DISABLED");
01889 
01890                         printf("<TR><TD CLASS='dataVar'>Passive Checks:</TD><td CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(temp_svcstatus->accept_passive_service_checks==TRUE)?"ENABLED":"DISABLED",(temp_svcstatus->accept_passive_service_checks)?"ENABLED":"DISABLED");
01891 
01892                         printf("<TR><TD CLASS='dataVar'>Obsessing:</TD><td CLASS='dataVal'><DIV CLASS='checks%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(temp_svcstatus->obsess_over_service==TRUE)?"ENABLED":"DISABLED",(temp_svcstatus->obsess_over_service)?"ENABLED":"DISABLED");
01893 
01894                         printf("<TR><td CLASS='dataVar'>Notifications:</TD><td CLASS='dataVal'><DIV CLASS='notifications%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(temp_svcstatus->notifications_enabled)?"ENABLED":"DISABLED",(temp_svcstatus->notifications_enabled)?"ENABLED":"DISABLED");
01895 
01896                         if ((temp_service->event_handler)&&(*temp_service->event_handler!='\0'))
01897                                 printf("<TR><TD CLASS='dataVar'><A HREF='%s?type=command&expand=%s'>Event Handler:</A></td><td CLASS='dataVal'><DIV CLASS='eventhandlers%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></td></tr>\n",CONFIG_CGI,url_encode(temp_service->event_handler),(temp_svcstatus->event_handler_enabled)?"ENABLED":"DISABLED",(temp_svcstatus->event_handler_enabled)?"ENABLED":"DISABLED");
01898                         else printf("<TR><TD CLASS='dataVar'>Event Handler:</td><td CLASS='dataVal'><DIV CLASS='eventhandlers%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></td></tr>\n",(temp_svcstatus->event_handler_enabled)?"ENABLED":"DISABLED",(temp_svcstatus->event_handler_enabled)?"ENABLED":"DISABLED");
01899 
01900                         printf("<TR><TD CLASS='dataVar'>Flap Detection:</TD><td CLASS='dataVal'><DIV CLASS='flapdetection%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",(temp_svcstatus->flap_detection_enabled==TRUE)?"ENABLED":"DISABLED",(temp_svcstatus->flap_detection_enabled==TRUE)?"ENABLED":"DISABLED");
01901 
01902 
01903                         printf("</TABLE>\n");
01904                         printf("</TD></TR>\n");
01905                         printf("</TABLE>\n");
01906 
01907                         printf("</TD></TR>\n");
01908 
01909                         printf("</TABLE>\n");
01910                 }
01911         
01912 
01913                 printf("</TD>\n");
01914 
01915                 printf("<TD ALIGN=CENTER VALIGN=TOP>\n");
01916                 printf("<TABLE BORDER='0' CELLPADDING=0 CELLSPACING=0><TR>\n");
01917 
01918                 printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='commandPanel'>\n");
01919 
01920                 printf("<DIV CLASS='dataTitle'>Service Commands</DIV>\n");
01921 
01922                 printf("<TABLE BORDER='1' CELLSPACING=0 CELLPADDING=0>\n");
01923                 printf("<TR><TD>\n");
01924 
01925                 if(nagios_process_state==STATE_OK &&  is_authorized_for_read_only(&current_authdata)==FALSE){
01926                         printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
01927 
01928                         if(temp_svcstatus->checks_enabled){
01929 
01930                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Active Checks Of This Service' TITLE='Disable Active Checks Of This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_SVC_CHECK,url_encode(host_name));
01931                                 printf("&service=%s'>Disable active checks of this service</a></td></tr>\n",url_encode(service_desc));
01932                         }else{
01933                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Active Checks Of This Service' TITLE='Enable Active Checks Of This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_SVC_CHECK,url_encode(host_name));
01934                                 printf("&service=%s'>Enable active checks of this service</a></td></tr>\n",url_encode(service_desc));
01935                         }
01936                         printf("<tr CLASS='data'><td><img src='%s%s' border=0 ALT='Re-schedule Next Service Check' TITLE='Re-schedule Next Service Check'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,DELAY_ICON,CMD_CGI,CMD_SCHEDULE_SVC_CHECK,url_encode(host_name));
01937                         printf("&service=%s%s'>Re-schedule the next check of this service</a></td></tr>\n",url_encode(service_desc),(temp_svcstatus->checks_enabled==TRUE)?"&force_check":"");
01938 
01939                         if(temp_svcstatus->accept_passive_service_checks==TRUE){
01940                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Submit Passive Check Result For This Service' TITLE='Submit Passive Check Result For This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,PASSIVE_ICON,CMD_CGI,CMD_PROCESS_SERVICE_CHECK_RESULT,url_encode(host_name));
01941                                 printf("&service=%s'>Submit passive check result for this service</a></td></tr>\n",url_encode(service_desc));
01942 
01943                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Stop Accepting Passive Checks For This Service' TITLE='Stop Accepting Passive Checks For This Service'></td><td CLASS='command' NOWRAP><a href='%s?cmd_typ=%d&host=%s",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_PASSIVE_SVC_CHECKS,url_encode(host_name));
01944                                 printf("&service=%s'>Stop accepting passive checks for this service</a></td></tr>\n",url_encode(service_desc));
01945                         }else{
01946                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Start Accepting Passive Checks For This Service' TITLE='Start Accepting Passive Checks For This Service'></td><td CLASS='command' NOWRAP><a href='%s?cmd_typ=%d&host=%s",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_PASSIVE_SVC_CHECKS,url_encode(host_name));
01947                                 printf("&service=%s'>Start accepting passive checks for this service</a></td></tr>\n",url_encode(service_desc));
01948                         }
01949 
01950                         if(temp_svcstatus->obsess_over_service==TRUE){
01951                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Stop Obsessing Over This Service' TITLE='Stop Obsessing Over This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,DISABLED_ICON,CMD_CGI,CMD_STOP_OBSESSING_OVER_SVC,url_encode(host_name));
01952                                 printf("&service=%s'>Stop obsessing over this service</a></td></tr>\n",url_encode(service_desc));
01953                         }else{
01954                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Start Obsessing Over This Service' TITLE='Start Obsessing Over This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,ENABLED_ICON,CMD_CGI,CMD_START_OBSESSING_OVER_SVC,url_encode(host_name));
01955                                 printf("&service=%s'>Start obsessing over this service</a></td></tr>\n",url_encode(service_desc));
01956                         }
01957 
01958                         if((temp_svcstatus->status==SERVICE_WARNING || temp_svcstatus->status==SERVICE_UNKNOWN || temp_svcstatus->status==SERVICE_CRITICAL) && temp_svcstatus->state_type==HARD_STATE){
01959                                 if(temp_svcstatus->problem_has_been_acknowledged==FALSE){
01960                                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Acknowledge This Service Problem' TITLE='Acknowledge This Service Problem'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,ACKNOWLEDGEMENT_ICON,CMD_CGI,CMD_ACKNOWLEDGE_SVC_PROBLEM,url_encode(host_name));
01961                                         printf("&service=%s'>Acknowledge this service problem</a></td></tr>\n",url_encode(service_desc));
01962                                 }else{
01963                                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Remove Problem Acknowledgement' TITLE='Remove Problem Acknowledgement'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,REMOVE_ACKNOWLEDGEMENT_ICON,CMD_CGI,CMD_REMOVE_SVC_ACKNOWLEDGEMENT,url_encode(host_name));
01964                                         printf("&service=%s'>Remove problem acknowledgement</a></td></tr>\n",url_encode(service_desc));
01965                                 }
01966                         }
01967                         if(temp_svcstatus->notifications_enabled==TRUE){
01968                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Notifications For This Service' TITLE='Disable Notifications For This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_SVC_NOTIFICATIONS,url_encode(host_name));
01969                                 printf("&service=%s'>Disable notifications for this service</a></td></tr>\n",url_encode(service_desc));
01970                                 if(temp_svcstatus->status!=SERVICE_OK){
01971                                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Delay Next Service Notification' TITLE='Delay Next Service Notification'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,DELAY_ICON,CMD_CGI,CMD_DELAY_SVC_NOTIFICATION,url_encode(host_name));
01972                                         printf("&service=%s'>Delay next service notification</a></td></tr>\n",url_encode(service_desc));
01973                                 }
01974                         }else{
01975                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Notifications For This Service' TITLE='Enable Notifications For This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_SVC_NOTIFICATIONS,url_encode(host_name));
01976                                 printf("&service=%s'>Enable notifications for this service</a></td></tr>\n",url_encode(service_desc));
01977                         }
01978 
01979                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Send Custom Notification' TITLE='Send Custom Notification'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,NOTIFICATION_ICON,CMD_CGI,CMD_SEND_CUSTOM_SVC_NOTIFICATION,url_encode(host_name));
01980                         printf("&service=%s'>Send custom service notification</a></td></tr>\n",url_encode(service_desc));
01981 
01982                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For This Service' TITLE='Schedule Downtime For This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,DOWNTIME_ICON,CMD_CGI,CMD_SCHEDULE_SVC_DOWNTIME,url_encode(host_name));
01983                         printf("&service=%s'>Schedule downtime for this service</a></td></tr>\n",url_encode(service_desc));
01984 
01985                         /*
01986                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Cancel Scheduled Downtime For This Service' TITLE='Cancel Scheduled Downtime For This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,SCHEDULED_DOWNTIME_ICON,CMD_CGI,CMD_CANCEL_SVC_DOWNTIME,url_encode(host_name));
01987                         printf("&service=%s'>Cancel scheduled downtime for this service</a></td></tr>\n",url_encode(service_desc));
01988                         */
01989 
01990                         if(temp_svcstatus->event_handler_enabled==TRUE){
01991                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Event Handler For This Service' TITLE='Disable Event Handler For This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_SVC_EVENT_HANDLER,url_encode(host_name));
01992                                 printf("&service=%s'>Disable event handler for this service</a></td></tr>\n",url_encode(service_desc));
01993                         }else{
01994                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Event Handler For This Service' TITLE='Enable Event Handler For This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_SVC_EVENT_HANDLER,url_encode(host_name));
01995                                 printf("&service=%s'>Enable event handler for this service</a></td></tr>\n",url_encode(service_desc));
01996                         }
01997 
01998                         if(temp_svcstatus->flap_detection_enabled==TRUE){
01999                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Flap Detection For This Service' TITLE='Disable Flap Detection For This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_SVC_FLAP_DETECTION,url_encode(host_name));
02000                                 printf("&service=%s'>Disable flap detection for this service</a></td></tr>\n",url_encode(service_desc));
02001                         }else{
02002                                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Flap Detection For This Service' TITLE='Enable Flap Detection For This Service'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_SVC_FLAP_DETECTION,url_encode(host_name));
02003                                 printf("&service=%s'>Enable flap detection for this service</a></td></tr>\n",url_encode(service_desc));
02004                         }
02005 
02006                         printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Add a new Service comment' TITLE='Add a new Service comment'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s&",url_images_path,COMMENT_ICON,CMD_CGI,CMD_ADD_SVC_COMMENT,(display_type==DISPLAY_COMMENTS)?"":url_encode(host_name));
02007                         printf("service=%s'>",(display_type==DISPLAY_COMMENTS)?"":url_encode(service_desc));
02008                         printf("Add a new Service comment</a></td>");
02009 
02010 
02011                         printf("</table>\n");
02012                 }else if (is_authorized_for_read_only(&current_authdata)==TRUE){
02013                         printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to execute commands.<br>\n");
02014                 }else{
02015                         printf("<DIV CLASS='infoMessage'>It appears as though Icinga is not running, so commands are temporarily unavailable...<br>\n");
02016                         printf("Click <a href='%s?type=%d'>here</a> to view Icinga process information</DIV>\n",EXTINFO_CGI,DISPLAY_PROCESS_INFO);
02017                 }
02018 
02019                 printf("</td></tr>\n");
02020                 printf("</table>\n");
02021 
02022                 printf("</TD>\n");
02023 
02024                 printf("</TR></TABLE></TD>\n");
02025                 printf("</TR>\n");
02026 
02027                 printf("<TR><TD COLSPAN=2><BR></TD></TR>\n");
02028 
02029                 printf("<TR>\n");
02030                 printf("<TD COLSPAN=2 ALIGN=CENTER VALIGN=TOP CLASS='commentPanel'>\n");
02031 
02032                 if (is_authorized_for_read_only(&current_authdata)==FALSE) {
02033                         /* display comments */
02034                         show_comments(SERVICE_COMMENT);
02035                         printf("<BR>");
02036                         /* display downtimes */
02037                         show_downtime(SERVICE_DOWNTIME);
02038                 }
02039                 printf("</TD>\n");
02040                 printf("</TR>\n");
02041 
02042                 printf("</TABLE>\n");
02043                 printf("</DIV>\n");
02044         }
02045 
02046         return;
02047 }
02048 
02049 void show_hostgroup_info(void){
02050         hostgroup *temp_hostgroup;
02051 
02052 
02053         /* get hostgroup info */
02054         temp_hostgroup=find_hostgroup(hostgroup_name);
02055 
02056         /* make sure the user has rights to view hostgroup information */
02057         if(is_authorized_for_hostgroup(temp_hostgroup,&current_authdata)==FALSE){
02058 
02059                 print_generic_error_message("It appears as though you do not have permission to view information for this hostgroup...","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);
02060 
02061                 return;
02062                 }
02063 
02064         /* make sure hostgroup information exists */
02065         if(temp_hostgroup==NULL){
02066                 print_generic_error_message("Error: Hostgroup Not Found!",NULL,0);
02067                 return;
02068                 }
02069 
02070 
02071         printf("<DIV ALIGN=CENTER>\n");
02072         printf("<TABLE BORDER=0 WIDTH=100%%>\n");
02073         printf("<TR>\n");
02074 
02075 
02076         /* top left panel */
02077         printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel'>\n");
02078 
02079         /* right top panel */
02080         printf("</TD><TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel' ROWSPAN=2>\n");
02081 
02082         printf("<DIV CLASS='dataTitle'>Hostgroup Commands</DIV>\n");
02083 
02084         if(nagios_process_state==STATE_OK && is_authorized_for_read_only(&current_authdata)==FALSE){
02085 
02086                 printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
02087                 printf("<TR><TD>\n");
02088 
02089                 printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
02090 
02091                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For All Hosts In This Hostgroup' TITLE='Schedule Downtime For All Hosts In This Hostgroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&hostgroup=%s'>Schedule downtime for all hosts in this hostgroup</a></td></tr>\n",url_images_path,DOWNTIME_ICON,CMD_CGI,CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME,url_encode(hostgroup_name));
02092 
02093                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For All Services In This Hostgroup' TITLE='Schedule Downtime For All Services In This Hostgroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&hostgroup=%s'>Schedule downtime for all services in this hostgroup</a></td></tr>\n",url_images_path,DOWNTIME_ICON,CMD_CGI,CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME,url_encode(hostgroup_name));
02094 
02095                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Notifications For All Hosts In This Hostgroup' TITLE='Enable Notifications For All Hosts In This Hostgroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&hostgroup=%s'>Enable notifications for all hosts in this hostgroup</a></td></tr>\n",url_images_path,NOTIFICATION_ICON,CMD_CGI,CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS,url_encode(hostgroup_name));
02096 
02097                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Notifications For All Hosts In This Hostgroup' TITLE='Disable Notifications For All Hosts In This Hostgroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&hostgroup=%s'>Disable notifications for all hosts in this hostgroup</a></td></tr>\n",url_images_path,NOTIFICATIONS_DISABLED_ICON,CMD_CGI,CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS,url_encode(hostgroup_name));
02098 
02099                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Notifications For All Services In This Hostgroup' TITLE='Enable Notifications For All Services In This Hostgroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&hostgroup=%s'>Enable notifications for all services in this hostgroup</a></td></tr>\n",url_images_path,NOTIFICATION_ICON,CMD_CGI,CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS,url_encode(hostgroup_name));
02100 
02101                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Notifications For All Services In This Hostgroup' TITLE='Disable Notifications For All Services In This Hostgroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&hostgroup=%s'>Disable notifications for all services in this hostgroup</a></td></tr>\n",url_images_path,NOTIFICATIONS_DISABLED_ICON,CMD_CGI,CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS,url_encode(hostgroup_name));
02102 
02103                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Active Checks Of All Services In This Hostgroup' TITLE='Enable Active Checks Of All Services In This Hostgroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&hostgroup=%s'>Enable active checks of all services in this hostgroup</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_HOSTGROUP_SVC_CHECKS,url_encode(hostgroup_name));
02104 
02105                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Active Checks Of All Services In This Hostgroup' TITLE='Disable Active Checks Of All Services In This Hostgroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&hostgroup=%s'>Disable active checks of all services in this hostgroup</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_HOSTGROUP_SVC_CHECKS,url_encode(hostgroup_name));
02106 
02107                 printf("</table>\n");
02108 
02109                 printf("</TD></TR>\n");
02110                 printf("</TABLE>\n");
02111                 }
02112         else if (is_authorized_for_read_only(&current_authdata)==TRUE){
02113                 printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to execute commands.<br>\n");
02114                 }
02115         else{
02116                 printf("<DIV CLASS='infoMessage'>It appears as though Icinga is not running, so commands are temporarily unavailable...<br>\n");
02117                 printf("Click <a href='%s?type=%d'>here</a> to view Icinga process information</DIV>\n",EXTINFO_CGI,DISPLAY_PROCESS_INFO);
02118                 }
02119 
02120         printf("</TD></TR>\n");
02121         printf("<TR>\n");
02122 
02123         /* left bottom panel */
02124         printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel'>\n");
02125 
02126         printf("</TD></TR>\n");
02127         printf("</TABLE>\n");
02128         printf("</DIV>\n");
02129 
02130 
02131         printf("</div>\n");
02132 
02133         printf("</TD>\n");
02134 
02135 
02136 
02137         return;
02138 }
02139 
02140 void show_servicegroup_info(){
02141         servicegroup *temp_servicegroup;
02142 
02143 
02144         /* get servicegroup info */
02145         temp_servicegroup=find_servicegroup(servicegroup_name);
02146 
02147         /* make sure the user has rights to view servicegroup information */
02148         if(is_authorized_for_servicegroup(temp_servicegroup,&current_authdata)==FALSE){
02149                 print_generic_error_message("It appears as though you do not have permission to view information for this servicegroup...","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);
02150                 return;
02151         }
02152 
02153         /* make sure servicegroup information exists */
02154         if(temp_servicegroup==NULL){
02155                 print_generic_error_message("Error: Servicegroup Not Found!",NULL,0);
02156                 return;
02157         }
02158 
02159 
02160         printf("<DIV ALIGN=CENTER>\n");
02161         printf("<TABLE BORDER=0 WIDTH=100%%>\n");
02162         printf("<TR>\n");
02163 
02164 
02165         /* top left panel */
02166         printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel'>\n");
02167 
02168         /* right top panel */
02169         printf("</TD><TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel' ROWSPAN=2>\n");
02170 
02171         printf("<DIV CLASS='dataTitle'>Servicegroup Commands</DIV>\n");
02172 
02173         if(nagios_process_state==STATE_OK){
02174 
02175                 printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
02176                 printf("<TR><TD>\n");
02177 
02178                 printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
02179 
02180                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For All Hosts In This Servicegroup' TITLE='Schedule Downtime For All Hosts In This Servicegroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&servicegroup=%s'>Schedule downtime for all hosts in this servicegroup</a></td></tr>\n",url_images_path,DOWNTIME_ICON,CMD_CGI,CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME,url_encode(servicegroup_name));
02181 
02182                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For All Services In This Servicegroup' TITLE='Schedule Downtime For All Services In This Servicegroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&servicegroup=%s'>Schedule downtime for all services in this servicegroup</a></td></tr>\n",url_images_path,DOWNTIME_ICON,CMD_CGI,CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME,url_encode(servicegroup_name));
02183 
02184                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Notifications For All Hosts In This Servicegroup' TITLE='Enable Notifications For All Hosts In This Servicegroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&servicegroup=%s'>Enable notifications for all hosts in this servicegroup</a></td></tr>\n",url_images_path,NOTIFICATION_ICON,CMD_CGI,CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS,url_encode(servicegroup_name));
02185 
02186                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Notifications For All Hosts In This Servicegroup' TITLE='Disable Notifications For All Hosts In This Servicegroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&servicegroup=%s'>Disable notifications for all hosts in this servicegroup</a></td></tr>\n",url_images_path,NOTIFICATIONS_DISABLED_ICON,CMD_CGI,CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS,url_encode(servicegroup_name));
02187 
02188                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Notifications For All Services In This Servicegroup' TITLE='Enable Notifications For All Services In This Servicegroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&servicegroup=%s'>Enable notifications for all services in this servicegroup</a></td></tr>\n",url_images_path,NOTIFICATION_ICON,CMD_CGI,CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS,url_encode(servicegroup_name));
02189 
02190                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Notifications For All Services In This Servicegroup' TITLE='Disable Notifications For All Services In This Servicegroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&servicegroup=%s'>Disable notifications for all services in this servicegroup</a></td></tr>\n",url_images_path,NOTIFICATIONS_DISABLED_ICON,CMD_CGI,CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS,url_encode(servicegroup_name));
02191 
02192                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Enable Active Checks Of All Services In This Servicegroup' TITLE='Enable Active Checks Of All Services In This Servicegroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&servicegroup=%s'>Enable active checks of all services in this servicegroup</a></td></tr>\n",url_images_path,ENABLED_ICON,CMD_CGI,CMD_ENABLE_SERVICEGROUP_SVC_CHECKS,url_encode(servicegroup_name));
02193 
02194                 printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Disable Active Checks Of All Services In This Servicegroup' TITLE='Disable Active Checks Of All Services In This Servicegroup'></td><td CLASS='command'><a href='%s?cmd_typ=%d&servicegroup=%s'>Disable active checks of all services in this servicegroup</a></td></tr>\n",url_images_path,DISABLED_ICON,CMD_CGI,CMD_DISABLE_SERVICEGROUP_SVC_CHECKS,url_encode(servicegroup_name));
02195 
02196                 printf("</table>\n");
02197 
02198                 printf("</TD></TR>\n");
02199                 printf("</TABLE>\n");
02200                 }
02201         else{
02202                 printf("<DIV CLASS='infoMessage'>It appears as though Icinga is not running, so commands are temporarily unavailable...<br>\n");
02203                 printf("Click <a href='%s?type=%d'>here</a> to view Icinga process information</DIV>\n",EXTINFO_CGI,DISPLAY_PROCESS_INFO);
02204                 }
02205 
02206         printf("</TD></TR>\n");
02207         printf("<TR>\n");
02208 
02209         /* left bottom panel */
02210         printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel'>\n");
02211 
02212         printf("</TD></TR>\n");
02213         printf("</TABLE>\n");
02214         printf("</DIV>\n");
02215 
02216 
02217         printf("</div>\n");
02218 
02219         printf("</TD>\n");
02220 
02221 
02222         return;
02223 }
02224 
02225 void show_performance_data(void){
02226         service *temp_service=NULL;
02227         servicestatus *temp_servicestatus=NULL;
02228         host *temp_host=NULL;
02229         hoststatus *temp_hoststatus=NULL;
02230         int total_active_service_checks=0;
02231         int total_passive_service_checks=0;
02232         double min_service_execution_time=0.0;
02233         double max_service_execution_time=0.0;
02234         double total_service_execution_time=0.0;
02235         int have_min_service_execution_time=FALSE;
02236         int have_max_service_execution_time=FALSE;
02237         double min_service_latency=0.0;
02238         double max_service_latency=0.0;
02239         double long total_service_latency=0.0;
02240         int have_min_service_latency=FALSE;
02241         int have_max_service_latency=FALSE;
02242         double min_host_latency=0.0;
02243         double max_host_latency=0.0;
02244         double total_host_latency=0.0;
02245         int have_min_host_latency=FALSE;
02246         int have_max_host_latency=FALSE;
02247         double min_service_percent_change_a=0.0;
02248         double max_service_percent_change_a=0.0;
02249         double total_service_percent_change_a=0.0;
02250         int have_min_service_percent_change_a=FALSE;
02251         int have_max_service_percent_change_a=FALSE;
02252         double min_service_percent_change_b=0.0;
02253         double max_service_percent_change_b=0.0;
02254         double total_service_percent_change_b=0.0;
02255         int have_min_service_percent_change_b=FALSE;
02256         int have_max_service_percent_change_b=FALSE;
02257         int active_service_checks_1min=0;
02258         int active_service_checks_5min=0;
02259         int active_service_checks_15min=0;
02260         int active_service_checks_1hour=0;
02261         int active_service_checks_start=0;
02262         int active_service_checks_ever=0;
02263         int passive_service_checks_1min=0;
02264         int passive_service_checks_5min=0;
02265         int passive_service_checks_15min=0;
02266         int passive_service_checks_1hour=0;
02267         int passive_service_checks_start=0;
02268         int passive_service_checks_ever=0;
02269         int total_active_host_checks=0;
02270         int total_passive_host_checks=0;
02271         double min_host_execution_time=0.0;
02272         double max_host_execution_time=0.0;
02273         double total_host_execution_time=0.0;
02274         int have_min_host_execution_time=FALSE;
02275         int have_max_host_execution_time=FALSE;
02276         double min_host_percent_change_a=0.0;
02277         double max_host_percent_change_a=0.0;
02278         double total_host_percent_change_a=0.0;
02279         int have_min_host_percent_change_a=FALSE;
02280         int have_max_host_percent_change_a=FALSE;
02281         double min_host_percent_change_b=0.0;
02282         double max_host_percent_change_b=0.0;
02283         double total_host_percent_change_b=0.0;
02284         int have_min_host_percent_change_b=FALSE;
02285         int have_max_host_percent_change_b=FALSE;
02286         int active_host_checks_1min=0;
02287         int active_host_checks_5min=0;
02288         int active_host_checks_15min=0;
02289         int active_host_checks_1hour=0;
02290         int active_host_checks_start=0;
02291         int active_host_checks_ever=0;
02292         int passive_host_checks_1min=0;
02293         int passive_host_checks_5min=0;
02294         int passive_host_checks_15min=0;
02295         int passive_host_checks_1hour=0;
02296         int passive_host_checks_start=0;
02297         int passive_host_checks_ever=0;
02298         time_t current_time;
02299 /* make sure gcc3 won't hit here */
02300 #ifndef GCCTOOOLD
02301         profile_object *t, *p = profiled_data;
02302         int count=0;
02303         double elapsed=0.0, total_time=0.0;
02304         char *name=NULL;
02305 #endif
02306 
02307         time(&current_time);
02308 
02309         /* check all services */
02310         for(temp_servicestatus=servicestatus_list;temp_servicestatus!=NULL;temp_servicestatus=temp_servicestatus->next){
02311 
02312                 /* find the service */
02313                 temp_service=find_service(temp_servicestatus->host_name,temp_servicestatus->description);
02314 
02315                 /* make sure the user has rights to view service information */
02316                 if(is_authorized_for_service(temp_service,&current_authdata)==FALSE)
02317                         continue;
02318 
02319                 /* is this an active or passive check? */
02320                 if(temp_servicestatus->check_type==SERVICE_CHECK_ACTIVE){
02321 
02322                         total_active_service_checks++;
02323 
02324                         total_service_execution_time+=temp_servicestatus->execution_time;
02325                         if(have_min_service_execution_time==FALSE || temp_servicestatus->execution_time<min_service_execution_time){
02326                                 have_min_service_execution_time=TRUE;
02327                                 min_service_execution_time=temp_servicestatus->execution_time;
02328                                 }
02329                         if(have_max_service_execution_time==FALSE || temp_servicestatus->execution_time>max_service_execution_time){
02330                                 have_max_service_execution_time=TRUE;
02331                                 max_service_execution_time=temp_servicestatus->execution_time;
02332                                 }
02333 
02334                         total_service_percent_change_a+=temp_servicestatus->percent_state_change;
02335                         if(have_min_service_percent_change_a==FALSE || temp_servicestatus->percent_state_change<min_service_percent_change_a){
02336                                 have_min_service_percent_change_a=TRUE;
02337                                 min_service_percent_change_a=temp_servicestatus->percent_state_change;
02338                                 }
02339                         if(have_max_service_percent_change_a==FALSE || temp_servicestatus->percent_state_change>max_service_percent_change_a){
02340                                 have_max_service_percent_change_a=TRUE;
02341                                 max_service_percent_change_a=temp_servicestatus->percent_state_change;
02342                                 }
02343 
02344                         total_service_latency+=temp_servicestatus->latency;
02345                         if(have_min_service_latency==FALSE || temp_servicestatus->latency<min_service_latency){
02346                                 have_min_service_latency=TRUE;
02347                                 min_service_latency=temp_servicestatus->latency;
02348                                 }
02349                         if(have_max_service_latency==FALSE || temp_servicestatus->latency>max_service_latency){
02350                                 have_max_service_latency=TRUE;
02351                                 max_service_latency=temp_servicestatus->latency;
02352                                 }
02353 
02354                         if(temp_servicestatus->last_check>=(current_time-60))
02355                                 active_service_checks_1min++;
02356                         if(temp_servicestatus->last_check>=(current_time-300))
02357                                 active_service_checks_5min++;
02358                         if(temp_servicestatus->last_check>=(current_time-900))
02359                                 active_service_checks_15min++;
02360                         if(temp_servicestatus->last_check>=(current_time-3600))
02361                                 active_service_checks_1hour++;
02362                         if(temp_servicestatus->last_check>=program_start)
02363                                 active_service_checks_start++;
02364                         if(temp_servicestatus->last_check!=(time_t)0)
02365                                 active_service_checks_ever++;
02366                         }
02367 
02368                 else{
02369                         total_passive_service_checks++;
02370 
02371                         total_service_percent_change_b+=temp_servicestatus->percent_state_change;
02372                         if(have_min_service_percent_change_b==FALSE || temp_servicestatus->percent_state_change<min_service_percent_change_b){
02373                                 have_min_service_percent_change_b=TRUE;
02374                                 min_service_percent_change_b=temp_servicestatus->percent_state_change;
02375                                 }
02376                         if(have_max_service_percent_change_b==FALSE || temp_servicestatus->percent_state_change>max_service_percent_change_b){
02377                                 have_max_service_percent_change_b=TRUE;
02378                                 max_service_percent_change_b=temp_servicestatus->percent_state_change;
02379                                 }
02380 
02381                         if(temp_servicestatus->last_check>=(current_time-60))
02382                                 passive_service_checks_1min++;
02383                         if(temp_servicestatus->last_check>=(current_time-300))
02384                                 passive_service_checks_5min++;
02385                         if(temp_servicestatus->last_check>=(current_time-900))
02386                                 passive_service_checks_15min++;
02387                         if(temp_servicestatus->last_check>=(current_time-3600))
02388                                 passive_service_checks_1hour++;
02389                         if(temp_servicestatus->last_check>=program_start)
02390                                 passive_service_checks_start++;
02391                         if(temp_servicestatus->last_check!=(time_t)0)
02392                                 passive_service_checks_ever++;
02393                         }
02394                 }
02395 
02396         /* check all hosts */
02397         for(temp_hoststatus=hoststatus_list;temp_hoststatus!=NULL;temp_hoststatus=temp_hoststatus->next){
02398 
02399                 /* find the host */
02400                 temp_host=find_host(temp_hoststatus->host_name);
02401 
02402                 /* make sure the user has rights to view host information */
02403                 if(is_authorized_for_host(temp_host,&current_authdata)==FALSE)
02404                         continue;
02405 
02406                 /* is this an active or passive check? */
02407                 if(temp_hoststatus->check_type==HOST_CHECK_ACTIVE){
02408 
02409                         total_active_host_checks++;
02410 
02411                         total_host_execution_time+=temp_hoststatus->execution_time;
02412                         if(have_min_host_execution_time==FALSE || temp_hoststatus->execution_time<min_host_execution_time){
02413                                 have_min_host_execution_time=TRUE;
02414                                 min_host_execution_time=temp_hoststatus->execution_time;
02415                                 }
02416                         if(have_max_host_execution_time==FALSE || temp_hoststatus->execution_time>max_host_execution_time){
02417                                 have_max_host_execution_time=TRUE;
02418                                 max_host_execution_time=temp_hoststatus->execution_time;
02419                                 }
02420 
02421                         total_host_percent_change_a+=temp_hoststatus->percent_state_change;
02422                         if(have_min_host_percent_change_a==FALSE || temp_hoststatus->percent_state_change<min_host_percent_change_a){
02423                                 have_min_host_percent_change_a=TRUE;
02424                                 min_host_percent_change_a=temp_hoststatus->percent_state_change;
02425                                 }
02426                         if(have_max_host_percent_change_a==FALSE || temp_hoststatus->percent_state_change>max_host_percent_change_a){
02427                                 have_max_host_percent_change_a=TRUE;
02428                                 max_host_percent_change_a=temp_hoststatus->percent_state_change;
02429                                 }
02430 
02431                         total_host_latency+=temp_hoststatus->latency;
02432                         if(have_min_host_latency==FALSE || temp_hoststatus->latency<min_host_latency){
02433                                 have_min_host_latency=TRUE;
02434                                 min_host_latency=temp_hoststatus->latency;
02435                                 }
02436                         if(have_max_host_latency==FALSE || temp_hoststatus->latency>max_host_latency){
02437                                 have_max_host_latency=TRUE;
02438                                 max_host_latency=temp_hoststatus->latency;
02439                                 }
02440 
02441                         if(temp_hoststatus->last_check>=(current_time-60))
02442                                 active_host_checks_1min++;
02443                         if(temp_hoststatus->last_check>=(current_time-300))
02444                                 active_host_checks_5min++;
02445                         if(temp_hoststatus->last_check>=(current_time-900))
02446                                 active_host_checks_15min++;
02447                         if(temp_hoststatus->last_check>=(current_time-3600))
02448                                 active_host_checks_1hour++;
02449                         if(temp_hoststatus->last_check>=program_start)
02450                                 active_host_checks_start++;
02451                         if(temp_hoststatus->last_check!=(time_t)0)
02452                                 active_host_checks_ever++;
02453                         }
02454 
02455                 else{
02456                         total_passive_host_checks++;
02457 
02458                         total_host_percent_change_b+=temp_hoststatus->percent_state_change;
02459                         if(have_min_host_percent_change_b==FALSE || temp_hoststatus->percent_state_change<min_host_percent_change_b){
02460                                 have_min_host_percent_change_b=TRUE;
02461                                 min_host_percent_change_b=temp_hoststatus->percent_state_change;
02462                                 }
02463                         if(have_max_host_percent_change_b==FALSE || temp_hoststatus->percent_state_change>max_host_percent_change_b){
02464                                 have_max_host_percent_change_b=TRUE;
02465                                 max_host_percent_change_b=temp_hoststatus->percent_state_change;
02466                                 }
02467 
02468                         if(temp_hoststatus->last_check>=(current_time-60))
02469                                 passive_host_checks_1min++;
02470                         if(temp_hoststatus->last_check>=(current_time-300))
02471                                 passive_host_checks_5min++;
02472                         if(temp_hoststatus->last_check>=(current_time-900))
02473                                 passive_host_checks_15min++;
02474                         if(temp_hoststatus->last_check>=(current_time-3600))
02475                                 passive_host_checks_1hour++;
02476                         if(temp_hoststatus->last_check>=program_start)
02477                                 passive_host_checks_start++;
02478                         if(temp_hoststatus->last_check!=(time_t)0)
02479                                 passive_host_checks_ever++;
02480                         }
02481                 }
02482 
02483 
02484         printf("<div align=center>\n");
02485 
02486 
02487         printf("<DIV CLASS='dataTitle'>Program-Wide Performance Information</DIV>\n");
02488 
02489         printf("<table border='0' cellpadding='10'>\n");
02490 
02491 
02492         /***** ACTIVE SERVICE CHECKS *****/
02493 
02494         printf("<tr>\n");
02495         printf("<td valign=middle><div class='perfTypeTitle'>Services Actively Checked:</div></td>\n");
02496         printf("<td valign=top>\n");
02497 
02498         /* fake this so we don't divide by zero for just showing the table */
02499         if(total_active_service_checks==0)
02500                 total_active_service_checks=1;
02501 
02502         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02503         printf("<TR><TD class='stateInfoTable1'>\n");
02504         printf("<TABLE BORDER=0>\n");
02505 
02506         printf("<tr class='data'><th class='data'>Time Frame</th><th class='data'>Services Checked</th></tr>\n");
02507         printf("<tr><td class='dataVar'>&lt;= 1 minute:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",active_service_checks_1min,(double)(((double)active_service_checks_1min*100.0)/(double)total_active_service_checks));
02508         printf("<tr><td class='dataVar'>&lt;= 5 minutes:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",active_service_checks_5min,(double)(((double)active_service_checks_5min*100.0)/(double)total_active_service_checks));
02509         printf("<tr><td class='dataVar'>&lt;= 15 minutes:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",active_service_checks_15min,(double)(((double)active_service_checks_15min*100.0)/(double)total_active_service_checks));
02510         printf("<tr><td class='dataVar'>&lt;= 1 hour:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",active_service_checks_1hour,(double)(((double)active_service_checks_1hour*100.0)/(double)total_active_service_checks));
02511         printf("<tr><td class='dataVar'>Since program start:&nbsp;&nbsp;</td><td class='dataVal'>%d (%.1f%%)</td>",active_service_checks_start,(double)(((double)active_service_checks_start*100.0)/(double)total_active_service_checks));
02512 
02513         printf("</TABLE>\n");
02514         printf("</TD></TR>\n");
02515         printf("</TABLE>\n");
02516 
02517         printf("</td><td valign=top>\n");
02518 
02519         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02520         printf("<TR><TD class='stateInfoTable2'>\n");
02521         printf("<TABLE BORDER=0>\n");
02522 
02523         printf("<tr class='data'><th class='data'>Metric</th><th class='data'>Min.</th><th class='data'>Max.</th><th class='data'>Average</th></tr>\n");
02524 
02525         printf("<tr><td class='dataVar'>Check Execution Time:&nbsp;&nbsp;</td><td class='dataVal'>%.2f sec</td><td class='dataVal'>%.2f sec</td><td class='dataVal'>%.3f sec</td></tr>\n",min_service_execution_time,max_service_execution_time,(double)((double)total_service_execution_time/(double)total_active_service_checks));
02526 
02527         printf("<tr><td class='dataVar'>Check Latency:</td><td class='dataVal'>%.2f sec</td><td class='dataVal'>%.2f sec</td><td class='dataVal'>%.3f sec</td></tr>\n",min_service_latency,max_service_latency,(double)((double)total_service_latency/(double)total_active_service_checks));
02528 
02529         printf("<tr><td class='dataVar'>Percent State Change:</td><td class='dataVal'>%.2f%%</td><td class='dataVal'>%.2f%%</td><td class='dataVal'>%.2f%%</td></tr>\n",min_service_percent_change_a,max_service_percent_change_a,(double)((double)total_service_percent_change_a/(double)total_active_service_checks));
02530 
02531         printf("</TABLE>\n");
02532         printf("</TD></TR>\n");
02533         printf("</TABLE>\n");
02534 
02535 
02536         printf("</td>\n");
02537         printf("</tr>\n");
02538 
02539 
02540         /***** PASSIVE SERVICE CHECKS *****/
02541 
02542         printf("<tr>\n");
02543         printf("<td valign=middle><div class='perfTypeTitle'>Services Passively Checked:</div></td>\n");
02544         printf("<td valign=top>\n");
02545 
02546 
02547         /* fake this so we don't divide by zero for just showing the table */
02548         if(total_passive_service_checks==0)
02549                 total_passive_service_checks=1;
02550 
02551         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02552         printf("<TR><TD class='stateInfoTable1'>\n");
02553         printf("<TABLE BORDER=0>\n");
02554 
02555         printf("<tr class='data'><th class='data'>Time Frame</th><th class='data'>Services Checked</th></tr>\n");
02556         printf("<tr><td class='dataVar'>&lt;= 1 minute:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_service_checks_1min,(double)(((double)passive_service_checks_1min*100.0)/(double)total_passive_service_checks));
02557         printf("<tr><td class='dataVar'>&lt;= 5 minutes:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_service_checks_5min,(double)(((double)passive_service_checks_5min*100.0)/(double)total_passive_service_checks));
02558         printf("<tr><td class='dataVar'>&lt;= 15 minutes:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_service_checks_15min,(double)(((double)passive_service_checks_15min*100.0)/(double)total_passive_service_checks));
02559         printf("<tr><td class='dataVar'>&lt;= 1 hour:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_service_checks_1hour,(double)(((double)passive_service_checks_1hour*100.0)/(double)total_passive_service_checks));
02560         printf("<tr><td class='dataVar'>Since program start:&nbsp;&nbsp;</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_service_checks_start,(double)(((double)passive_service_checks_start*100.0)/(double)total_passive_service_checks));
02561 
02562         printf("</TABLE>\n");
02563         printf("</TD></TR>\n");
02564         printf("</TABLE>\n");
02565 
02566         printf("</td><td valign=top>\n");
02567 
02568         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02569         printf("<TR><TD class='stateInfoTable2'>\n");
02570         printf("<TABLE BORDER=0>\n");
02571 
02572         printf("<tr class='data'><th class='data'>Metric</th><th class='data'>Min.</th><th class='data'>Max.</th><th class='data'>Average</th></tr>\n");
02573         printf("<tr><td class='dataVar'>Percent State Change:&nbsp;&nbsp;</td><td class='dataVal'>%.2f%%</td><td class='dataVal'>%.2f%%</td><td class='dataVal'>%.2f%%</td></tr>\n",min_service_percent_change_b,max_service_percent_change_b,(double)((double)total_service_percent_change_b/(double)total_passive_service_checks));
02574 
02575         printf("</TABLE>\n");
02576         printf("</TD></TR>\n");
02577         printf("</TABLE>\n");
02578 
02579         printf("</td>\n");
02580         printf("</tr>\n");
02581 
02582 
02583         /***** ACTIVE HOST CHECKS *****/
02584 
02585         printf("<tr>\n");
02586         printf("<td valign=middle><div class='perfTypeTitle'>Hosts Actively Checked:</div></td>\n");
02587         printf("<td valign=top>\n");
02588 
02589         /* fake this so we don't divide by zero for just showing the table */
02590         if(total_active_host_checks==0)
02591                 total_active_host_checks=1;
02592 
02593         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02594         printf("<TR><TD class='stateInfoTable1'>\n");
02595         printf("<TABLE BORDER=0>\n");
02596 
02597         printf("<tr class='data'><th class='data'>Time Frame</th><th class='data'>Hosts Checked</th></tr>\n");
02598         printf("<tr><td class='dataVar'>&lt;= 1 minute:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",active_host_checks_1min,(double)(((double)active_host_checks_1min*100.0)/(double)total_active_host_checks));
02599         printf("<tr><td class='dataVar'>&lt;= 5 minutes:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",active_host_checks_5min,(double)(((double)active_host_checks_5min*100.0)/(double)total_active_host_checks));
02600         printf("<tr><td class='dataVar'>&lt;= 15 minutes:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",active_host_checks_15min,(double)(((double)active_host_checks_15min*100.0)/(double)total_active_host_checks));
02601         printf("<tr><td class='dataVar'>&lt;= 1 hour:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",active_host_checks_1hour,(double)(((double)active_host_checks_1hour*100.0)/(double)total_active_host_checks));
02602         printf("<tr><td class='dataVar'>Since program start:&nbsp;&nbsp;</td><td class='dataVal'>%d (%.1f%%)</td>",active_host_checks_start,(double)(((double)active_host_checks_start*100.0)/(double)total_active_host_checks));
02603 
02604         printf("</TABLE>\n");
02605         printf("</TD></TR>\n");
02606         printf("</TABLE>\n");
02607 
02608         printf("</td><td valign=top>\n");
02609 
02610         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02611         printf("<TR><TD class='stateInfoTable2'>\n");
02612         printf("<TABLE BORDER=0>\n");
02613 
02614         printf("<tr class='data'><th class='data'>Metric</th><th class='data'>Min.</th><th class='data'>Max.</th><th class='data'>Average</th></tr>\n");
02615 
02616         printf("<tr><td class='dataVar'>Check Execution Time:&nbsp;&nbsp;</td><td class='dataVal'>%.2f sec</td><td class='dataVal'>%.2f sec</td><td class='dataVal'>%.3f sec</td></tr>\n",min_host_execution_time,max_host_execution_time,(double)((double)total_host_execution_time/(double)total_active_host_checks));
02617 
02618         printf("<tr><td class='dataVar'>Check Latency:</td><td class='dataVal'>%.2f sec</td><td class='dataVal'>%.2f sec</td><td class='dataVal'>%.3f sec</td></tr>\n",min_host_latency,max_host_latency,(double)((double)total_host_latency/(double)total_active_host_checks));
02619 
02620         printf("<tr><td class='dataVar'>Percent State Change:</td><td class='dataVal'>%.2f%%</td><td class='dataVal'>%.2f%%</td><td class='dataVal'>%.2f%%</td></tr>\n",min_host_percent_change_a,max_host_percent_change_a,(double)((double)total_host_percent_change_a/(double)total_active_host_checks));
02621 
02622         printf("</TABLE>\n");
02623         printf("</TD></TR>\n");
02624         printf("</TABLE>\n");
02625 
02626 
02627         printf("</td>\n");
02628         printf("</tr>\n");
02629 
02630 
02631         /***** PASSIVE HOST CHECKS *****/
02632 
02633         printf("<tr>\n");
02634         printf("<td valign=middle><div class='perfTypeTitle'>Hosts Passively Checked:</div></td>\n");
02635         printf("<td valign=top>\n");
02636 
02637 
02638         /* fake this so we don't divide by zero for just showing the table */
02639         if(total_passive_host_checks==0)
02640                 total_passive_host_checks=1;
02641 
02642         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02643         printf("<TR><TD class='stateInfoTable1'>\n");
02644         printf("<TABLE BORDER=0>\n");
02645 
02646         printf("<tr class='data'><th class='data'>Time Frame</th><th class='data'>Hosts Checked</th></tr>\n");
02647         printf("<tr><td class='dataVar'>&lt;= 1 minute:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_host_checks_1min,(double)(((double)passive_host_checks_1min*100.0)/(double)total_passive_host_checks));
02648         printf("<tr><td class='dataVar'>&lt;= 5 minutes:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_host_checks_5min,(double)(((double)passive_host_checks_5min*100.0)/(double)total_passive_host_checks));
02649         printf("<tr><td class='dataVar'>&lt;= 15 minutes:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_host_checks_15min,(double)(((double)passive_host_checks_15min*100.0)/(double)total_passive_host_checks));
02650         printf("<tr><td class='dataVar'>&lt;= 1 hour:</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_host_checks_1hour,(double)(((double)passive_host_checks_1hour*100.0)/(double)total_passive_host_checks));
02651         printf("<tr><td class='dataVar'>Since program start:&nbsp;&nbsp;</td><td class='dataVal'>%d (%.1f%%)</td></tr>",passive_host_checks_start,(double)(((double)passive_host_checks_start*100.0)/(double)total_passive_host_checks));
02652 
02653         printf("</TABLE>\n");
02654         printf("</TD></TR>\n");
02655         printf("</TABLE>\n");
02656 
02657         printf("</td><td valign=top>\n");
02658 
02659         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02660         printf("<TR><TD class='stateInfoTable2'>\n");
02661         printf("<TABLE BORDER=0>\n");
02662 
02663         printf("<tr class='data'><th class='data'>Metric</th><th class='data'>Min.</th><th class='data'>Max.</th><th class='data'>Average</th></tr>\n");
02664         printf("<tr><td class='dataVar'>Percent State Change:&nbsp;&nbsp;</td><td class='dataVal'>%.2f%%</td><td class='dataVal'>%.2f%%</td><td class='dataVal'>%.2f%%</td></tr>\n",min_host_percent_change_b,max_host_percent_change_b,(double)((double)total_host_percent_change_b/(double)total_passive_host_checks));
02665 
02666         printf("</TABLE>\n");
02667         printf("</TD></TR>\n");
02668         printf("</TABLE>\n");
02669 
02670         printf("</td>\n");
02671         printf("</tr>\n");
02672 
02673 
02674 
02675         /***** CHECK STATS *****/
02676 
02677         printf("<tr>\n");
02678         printf("<td valign=center><div class='perfTypeTitle'>Check Statistics:</div></td>\n");
02679         printf("<td valign=top colspan='2'>\n");
02680 
02681 
02682         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02683         printf("<TR><TD class='stateInfoTable1'>\n");
02684         printf("<TABLE BORDER=0>\n");
02685 
02686         printf("<tr class='data'><th class='data'>Type</th><th class='data'>Last 1 Min</th><th class='data'>Last 5 Min</th><th class='data'>Last 15 Min</th></tr>\n");
02687         printf("<tr><td class='dataVar'>Active Scheduled Host Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[ACTIVE_SCHEDULED_HOST_CHECK_STATS][0],program_stats[ACTIVE_SCHEDULED_HOST_CHECK_STATS][1],program_stats[ACTIVE_SCHEDULED_HOST_CHECK_STATS][2]);
02688         printf("<tr><td class='dataVar'>Active On-Demand Host Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[ACTIVE_ONDEMAND_HOST_CHECK_STATS][0],program_stats[ACTIVE_ONDEMAND_HOST_CHECK_STATS][1],program_stats[ACTIVE_ONDEMAND_HOST_CHECK_STATS][2]);
02689         printf("<tr><td class='dataVar'>Parallel Host Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[PARALLEL_HOST_CHECK_STATS][0],program_stats[PARALLEL_HOST_CHECK_STATS][1],program_stats[PARALLEL_HOST_CHECK_STATS][2]);
02690         printf("<tr><td class='dataVar'>Serial Host Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[SERIAL_HOST_CHECK_STATS][0],program_stats[SERIAL_HOST_CHECK_STATS][1],program_stats[SERIAL_HOST_CHECK_STATS][2]);
02691         printf("<tr><td class='dataVar'>Cached Host Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[ACTIVE_CACHED_HOST_CHECK_STATS][0],program_stats[ACTIVE_CACHED_HOST_CHECK_STATS][1],program_stats[ACTIVE_CACHED_HOST_CHECK_STATS][2]);
02692         printf("<tr><td class='dataVar'>Passive Host Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[PASSIVE_HOST_CHECK_STATS][0],program_stats[PASSIVE_HOST_CHECK_STATS][1],program_stats[PASSIVE_HOST_CHECK_STATS][2]);
02693 
02694         printf("<tr><td class='dataVar'>Active Scheduled Service Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[ACTIVE_SCHEDULED_SERVICE_CHECK_STATS][0],program_stats[ACTIVE_SCHEDULED_SERVICE_CHECK_STATS][1],program_stats[ACTIVE_SCHEDULED_SERVICE_CHECK_STATS][2]);
02695         printf("<tr><td class='dataVar'>Active On-Demand Service Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[ACTIVE_ONDEMAND_SERVICE_CHECK_STATS][0],program_stats[ACTIVE_ONDEMAND_SERVICE_CHECK_STATS][1],program_stats[ACTIVE_ONDEMAND_SERVICE_CHECK_STATS][2]);
02696         printf("<tr><td class='dataVar'>Cached Service Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[ACTIVE_CACHED_SERVICE_CHECK_STATS][0],program_stats[ACTIVE_CACHED_SERVICE_CHECK_STATS][1],program_stats[ACTIVE_CACHED_SERVICE_CHECK_STATS][2]);
02697         printf("<tr><td class='dataVar'>Passive Service Checks</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[PASSIVE_SERVICE_CHECK_STATS][0],program_stats[PASSIVE_SERVICE_CHECK_STATS][1],program_stats[PASSIVE_SERVICE_CHECK_STATS][2]);
02698 
02699         printf("<tr><td class='dataVar'>External Commands</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",program_stats[EXTERNAL_COMMAND_STATS][0],program_stats[EXTERNAL_COMMAND_STATS][1],program_stats[EXTERNAL_COMMAND_STATS][2]);
02700 
02701         printf("</TABLE>\n");
02702         printf("</TD></TR>\n");
02703         printf("</TABLE>\n");
02704 
02705         printf("</td>\n");
02706         printf("</tr>\n");
02707 
02708 
02709 
02710         /***** BUFFER STATS *****/
02711 
02712         printf("<tr>\n");
02713         printf("<td valign=center><div class='perfTypeTitle'>Buffer Usage:</div></td>\n");
02714         printf("<td valign=top colspan='2'>\n");
02715 
02716 
02717         printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02718         printf("<TR><TD class='stateInfoTable1'>\n");
02719         printf("<TABLE BORDER=0>\n");
02720 
02721         printf("<tr class='data'><th class='data'>Type</th><th class='data'>In Use</th><th class='data'>Max Used</th><th class='data'>Total Available</th></tr>\n");
02722         printf("<tr><td class='dataVar'>External Commands&nbsp;</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td><td class='dataVal'>%d</td></tr>",buffer_stats[0][1],buffer_stats[0][2],buffer_stats[0][0]);
02723 
02724         printf("</TABLE>\n");
02725         printf("</TD></TR>\n");
02726         printf("</TABLE>\n");
02727 
02728 /* make sure gcc3 won't hit here */
02729 #ifndef GCCTOOOLD
02730         if (event_profiling_enabled){
02731                 printf("<tr>\n");
02732                 printf("<td valign=center><div class='perfTypeTitle'>Event profiling:</div></td>\n");
02733                 printf("<td valign=top colspan='2'>\n");
02734 
02735                 printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
02736                 printf("<TR><TD class='stateInfoTable1'>\n");
02737                 printf("<TABLE BORDER=0>\n");
02738 
02739 
02740                 printf("<tr class='data'><th class='data'>EVENT PROFILE DATA:</th><th class='data'>total seconds spent</th><th class='data'>number of events</th><th class='data'>avg time per event</th><th class='data'>events per second</th></tr>\n");
02741                 while(p){
02742                         name = p->name;
02743                         count = p->count;
02744                         elapsed = p->elapsed;
02745                         t=profile_object_find_by_name("EVENT_LOOP_COMPLETION");
02746                         total_time = t->elapsed;
02747 
02748                         printf("<tr><td class='dataVar'>%s&nbsp;</td><td class='dataVal'>%.2f</td><td class='dataVal'>%d</td><td class='dataVal'>%.3f</td><td class='dataVal'>%.3f</td></tr>",name,elapsed,count,safe_divide(elapsed,count,0),safe_divide(total_time,count,1));
02749                         p = p->next;
02750                 }
02751 
02752 
02753                 printf("</TABLE>\n");
02754                 printf("</TD></TR>\n");
02755                 printf("</TABLE>\n");
02756         }
02757 #endif
02758 
02759 
02760         printf("</td>\n");
02761         printf("</tr>\n");
02762 
02763 
02764 
02765         printf("</table>\n");
02766 
02767 
02768         printf("</div>\n");
02769 
02770         return;
02771 }
02772 
02773 void show_comments(int type){
02774         host *temp_host=NULL;
02775         service *temp_service=NULL;
02776         int total_comments=0;
02777         char *bg_class="";
02778         int odd=1;
02779         char date_time[MAX_DATETIME_LENGTH];
02780         comment *temp_comment;
02781         char *comment_type;
02782         char expire_time[MAX_DATETIME_LENGTH];
02783         int colspan=8;
02784         int json_start=TRUE;
02785 
02786         /* define colspan */
02787         if(display_type==DISPLAY_COMMENTS) {
02788                 colspan=(type!=SERVICE_COMMENT)?9:10;
02789         }
02790 
02791         if(content_type==JSON_CONTENT) {
02792                 if(display_type==DISPLAY_COMMENTS && type==HOST_COMMENT)
02793                         printf("\"comments\": [\n");
02794                 if(display_type==DISPLAY_COMMENTS && type==SERVICE_COMMENT)
02795                         json_start=FALSE;
02796         }else if(content_type==CSV_CONTENT) {
02797                 /* csv header */
02798                 if(display_type==DISPLAY_COMMENTS && type==HOST_COMMENT) {
02799                         printf("%sHOST_NAME%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
02800                         printf("%sSERVICE%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
02801                 }
02802                 if(display_type!=DISPLAY_COMMENTS || (display_type==DISPLAY_COMMENTS && type==HOST_COMMENT)) {
02803                         printf("%sENTRY_TIME%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
02804                         printf("%sAUTHOR%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
02805                         printf("%sCOMMENT%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
02806                         printf("%sCOMMENT_ID%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
02807                         printf("%sPERSISTENT%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
02808                         printf("%sTYPE%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
02809                         printf("%sEXPIRES%s\n",csv_data_enclosure,csv_data_enclosure);
02810                 }
02811         }else{
02812                 printf("<A NAME=%sCOMMENTS></A>\n",(type==HOST_COMMENT)?"HOST":"SERVICE");
02813                 printf("<DIV CLASS='commentTitle'>%s Comments</DIV>\n",(type==HOST_COMMENT)?"Host":"Service");
02814 
02815                 printf("<form name='tableform%scomment' id='tableform%scomment'>",(type==HOST_COMMENT)?"host":"service",(type==HOST_COMMENT)?"host":"service");
02816                 printf("<input type=hidden name=buttonCheckboxChecked>");
02817                 printf("<input type=hidden name='hiddencmdfield' value=%d>",(type==HOST_COMMENT)?CMD_DEL_HOST_COMMENT:CMD_DEL_SVC_COMMENT);
02818                 printf("<DIV ALIGN=CENTER>\n");
02819                 printf("<TABLE BORDER=0 CLASS='comment'>\n");
02820 
02821                 /* add export to csv link */
02822                 if(display_type!=DISPLAY_COMMENTS)
02823                         printf("<TR><TD colspan='%d'><DIV class='csv_export_link'><A HREF='%s&csvtype=comment' target='_blank'>Export to CSV</A></DIV></TD></TR>\n",colspan,get_export_csv_link(EXTINFO_CGI));
02824 
02825                 printf("<TR><TD colspan='%d' align='right'><input type='button' name='CommandButton' value='Delete Comments' onClick=cmd_submit(\'tableform%scomment\') disabled=\"disabled\"></TD></TR>\n",colspan,(type==HOST_COMMENT)?"host":"service");
02826 
02827                 printf("<TR CLASS='comment'>");
02828                 if(display_type==DISPLAY_COMMENTS) {
02829                         printf("<TH CLASS='comment'>Host Name</TH>");
02830                         if(type==SERVICE_COMMENT)
02831                                 printf("<TH CLASS='comment'>Service</TH>");
02832                 }
02833                 printf("<TH CLASS='comment'>Entry Time</TH><TH CLASS='comment'>Author</TH><TH CLASS='comment'>Comment</TH><TH CLASS='comment'>Comment ID</TH><TH CLASS='comment'>Persistent</TH><TH CLASS='comment'>Type</TH><TH CLASS='comment'>Expires</TH><TH CLASS='comment' nowrap>Actions&nbsp;&nbsp;<input type='checkbox' value=all onclick=\"checkAll(\'tableform%scomment\');isValidForSubmit(\'tableform%scomment\');\"></TH></TR>\n",(type==HOST_COMMENT)?"host":"service",(type==HOST_COMMENT)?"host":"service");
02834         }
02835 
02836         /* display all the service comments */
02837         for(temp_comment=comment_list,total_comments=0;temp_comment!=NULL;temp_comment=temp_comment->next){
02838 
02839                 if(type==HOST_COMMENT && temp_comment->comment_type!=HOST_COMMENT)
02840                         continue;
02841 
02842                 if(type==SERVICE_COMMENT && temp_comment->comment_type!=SERVICE_COMMENT)
02843                         continue;
02844 
02845                 if(display_type!=DISPLAY_COMMENTS) {
02846                         /* if not our host -> continue */
02847                         if(strcmp(temp_comment->host_name,host_name))
02848                                 continue;
02849 
02850                         if(type==SERVICE_COMMENT) {
02851                                 /* if not our service -> continue */
02852                                 if(strcmp(temp_comment->service_description,service_desc))
02853                                         continue;
02854                         }
02855                 } else {
02856                         temp_host=find_host(temp_comment->host_name);
02857 
02858                         /* make sure the user has rights to view host information */
02859                         if(is_authorized_for_host(temp_host,&current_authdata)==FALSE)
02860                                 continue;
02861 
02862                         if(type==SERVICE_COMMENT){
02863                                 temp_service=find_service(temp_comment->host_name,temp_comment->service_description);
02864 
02865                                 /* make sure the user has rights to view service information */
02866                                 if(is_authorized_for_service(temp_service,&current_authdata)==FALSE)
02867                                         continue;
02868                         }
02869                 }
02870 
02871                 if(odd){
02872                         odd=0;
02873                         bg_class="commentOdd";
02874                 } else {
02875                         odd=1;
02876                         bg_class="commentEven";
02877                 }
02878 
02879                 switch(temp_comment->entry_type){
02880                 case USER_COMMENT:
02881                         comment_type="User";
02882                         break;
02883                 case DOWNTIME_COMMENT:
02884                         comment_type="Scheduled Downtime";
02885                         break;
02886                 case FLAPPING_COMMENT:
02887                         comment_type="Flap Detection";
02888                         break;
02889                 case ACKNOWLEDGEMENT_COMMENT:
02890                         comment_type="Acknowledgement";
02891                         break;
02892                 default:
02893                         comment_type="?";
02894                 }
02895 
02896                 get_time_string(&temp_comment->entry_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
02897                 get_time_string(&temp_comment->expire_time,expire_time,(int)sizeof(date_time),SHORT_DATE_TIME);
02898 
02899                 if(content_type==JSON_CONTENT) {
02900                         // always add a comma, except for the first line
02901                         if (json_start==FALSE)
02902                                 printf(",\n");
02903                         json_start=FALSE;
02904 
02905                         printf("{ ");
02906                         if(display_type==DISPLAY_COMMENTS) {
02907                                 printf("\"host_name\": \"%s\", ",json_encode(temp_host->name));
02908                                 if(type==SERVICE_COMMENT)
02909                                         printf("\"service_description\": \"%s\", ",json_encode(temp_service->description));
02910                                 printf("\"comment_type\": \"%s\", ",(type==HOST_COMMENT)?"HOST":"SERVICE");
02911                         }
02912                         printf("\"entry_time\": \"%s\", ",date_time);
02913                         printf("\"author\": \"%s\", ",json_encode(temp_comment->author));
02914                         printf("\"comment\": \"%s\", ",json_encode(temp_comment->comment_data));
02915                         printf("\"comment_id\": %lu, ",temp_comment->comment_id);
02916                         printf("\"persistent\": %s, ",(temp_comment->persistent==TRUE)?"true":"false");
02917                         printf("\"comment_type\": \"%s\", ",comment_type);
02918                         if (temp_comment->expires==TRUE)
02919                                 printf("\"expires\": null }");
02920                         else
02921                                 printf("\"expires\": \"%s\" }",expire_time);
02922                 }else if(content_type==CSV_CONTENT) {
02923                         if(display_type==DISPLAY_COMMENTS) {
02924                                 printf("%s%s%s%s",csv_data_enclosure,(temp_host->display_name!=NULL)?temp_host->display_name:temp_host->name,csv_data_enclosure,csv_delimiter);
02925                                 if(type==SERVICE_COMMENT)
02926                                         printf("%s%s%s%s",csv_data_enclosure,(temp_service->display_name!=NULL)?temp_service->display_name:temp_service->description,csv_data_enclosure,csv_delimiter);
02927                                 else
02928                                         printf("%s%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
02929                         }
02930                         printf("%s%s%s%s",csv_data_enclosure,date_time,csv_data_enclosure,csv_delimiter);
02931                         printf("%s%s%s%s",csv_data_enclosure,temp_comment->author,csv_data_enclosure,csv_delimiter);
02932                         printf("%s%s%s%s",csv_data_enclosure,temp_comment->comment_data,csv_data_enclosure,csv_delimiter);
02933                         printf("%s%lu%s%s",csv_data_enclosure,temp_comment->comment_id,csv_data_enclosure,csv_delimiter);
02934                         printf("%s%s%s%s",csv_data_enclosure,(temp_comment->persistent)?"YES":"NO",csv_data_enclosure,csv_delimiter);
02935                         printf("%s%s%s%s",csv_data_enclosure,comment_type,csv_data_enclosure,csv_delimiter);
02936                         printf("%s%s%s\n",csv_data_enclosure,(temp_comment->expires==TRUE)?expire_time:"N/A",csv_data_enclosure);
02937                 }else{
02938                         printf("<tr CLASS='%s'>",bg_class);
02939                         if(display_type==DISPLAY_COMMENTS) {
02940                                 printf("<td><A HREF='%s?type=%d&host=%s'>%s</A></td>",EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_comment->host_name),(temp_host->display_name!=NULL)?temp_host->display_name:temp_host->name);
02941                                 if(type==SERVICE_COMMENT) {
02942                                         printf("<td><A HREF='%s?type=%d&host=%s",EXTINFO_CGI,DISPLAY_SERVICE_INFO,url_encode(temp_comment->host_name));
02943                                         printf("&service=%s'>%s</A></td>",url_encode(temp_comment->service_description),(temp_service->display_name!=NULL)?temp_service->display_name:temp_service->description);
02944                                 }
02945                         }
02946                         printf("<td name='comment_time'>%s</td><td name='comment_author'>%s</td><td name='comment_data'>%s</td><td name='comment_id'>%lu</td><td name='comment_persist'>%s</td><td name='comment_type'>%s</td><td name='comment_expire'>%s</td>",date_time,temp_comment->author,temp_comment->comment_data,temp_comment->comment_id,(temp_comment->persistent)?"Yes":"No",comment_type,(temp_comment->expires==TRUE)?expire_time:"N/A");
02947                         printf("<td align='center'><a href='%s?cmd_typ=%d&com_id=%lu'><img src='%s%s' border=0 ALT='Delete This Comment' TITLE='Delete This Comment'></a>",CMD_CGI,(type==HOST_COMMENT)?CMD_DEL_HOST_COMMENT:CMD_DEL_SVC_COMMENT,temp_comment->comment_id,url_images_path,DELETE_ICON);
02948                         printf("<input onclick=\"isValidForSubmit(\'tableform%scomment\');\" type='checkbox' name='checkbox' value='&com_id=%lu'></td>",(type==HOST_COMMENT)?"host":"service",temp_comment->comment_id);
02949                         printf("</td></tr>\n");
02950                 }
02951                 total_comments++;
02952         }
02953 
02954         /* see if this host or service has any comments associated with it */
02955         if(content_type!=CSV_CONTENT && content_type!=JSON_CONTENT) {
02956                 if(total_comments==0) {
02957                         printf("<TR CLASS='commentOdd'><TD align='center' COLSPAN='%d'>",colspan);
02958                         if(display_type==DISPLAY_COMMENTS)      
02959                                 printf("There are no %s comments",(type==HOST_COMMENT)?"host":"service");
02960                         else
02961                                 printf("This %s has no comments associated with it",(type==HOST_COMMENT)?"host":"service");
02962                         printf("</TD></TR>\n");
02963                 }
02964                 printf("</TABLE></FORM></DIV>\n");
02965         }
02966         if(content_type==JSON_CONTENT && display_type==DISPLAY_COMMENTS && type==SERVICE_COMMENT)
02967                 printf("\n]\n");
02968 
02969         return;
02970 }
02971 
02972 /* shows service and host scheduled downtime */
02973 void show_downtime(int type){
02974         char *bg_class="";
02975         char date_time[MAX_DATETIME_LENGTH];
02976         scheduled_downtime *temp_downtime;
02977         host *temp_host=NULL;
02978         service *temp_service=NULL;
02979         int days;
02980         int hours;
02981         int minutes;
02982         int seconds;
02983         int odd=0;
02984         int total_downtime=0;
02985         int colspan=10;
02986         int json_start=TRUE;
02987 
02988         /* define colspan */
02989         if(display_type==DISPLAY_DOWNTIME) {
02990                 colspan=(type!=SERVICE_DOWNTIME)?11:12;
02991         }
02992 
02993         if(content_type==JSON_CONTENT) {
02994                 if(display_type==DISPLAY_DOWNTIME && type==HOST_DOWNTIME)
02995                         printf("\"downtimes\": [\n");
02996                 if(display_type==DISPLAY_DOWNTIME && type==SERVICE_DOWNTIME)
02997                         json_start=FALSE;
02998         }else if(content_type==CSV_CONTENT) {
02999                 /* csv header */
03000                 if(display_type==DISPLAY_DOWNTIME && type==HOST_DOWNTIME) {
03001                         printf("%sHOST_NAME%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03002                         printf("%sSERVICE%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03003                 }
03004                 if(display_type!=DISPLAY_DOWNTIME || (display_type==DISPLAY_DOWNTIME && type==HOST_DOWNTIME)) {
03005                         printf("%sENTRY_TIME%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03006                         printf("%sAUTHOR%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03007                         printf("%sCOMMENT%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03008                         printf("%sSTART_TIME%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03009                         printf("%sEND_TIME%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03010                         printf("%sTYPE%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03011                         printf("%sDURATION%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03012                         printf("%sDOWNTIME_ID%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03013                         printf("%sTRIGGER_ID%s\n",csv_data_enclosure,csv_data_enclosure);
03014                 }
03015         } else {
03016                 printf("<A NAME=%sDOWNTIME></A>\n",(type==HOST_DOWNTIME)?"HOST":"SERVICE");
03017                 printf("<DIV CLASS='downtimeTitle'>Scheduled %s Downtime</DIV>\n",(type==HOST_DOWNTIME)?"Host":"Service");
03018 
03019                 printf("<form name='tableform%sdowntime' id='tableform%sdowntime'>",(type==HOST_DOWNTIME)?"host":"service",(type==HOST_DOWNTIME)?"host":"service");
03020                 printf("<input type=hidden name=buttonCheckboxChecked>");
03021                 printf("<input type=hidden name='hiddencmdfield' value=%d>",(type==HOST_DOWNTIME)?CMD_DEL_HOST_DOWNTIME:CMD_DEL_SVC_DOWNTIME);
03022 
03023                 printf("<TABLE BORDER=0 CLASS='downtime'>\n");
03024 
03025                 /* add export to csv link */
03026                 if(display_type!=DISPLAY_DOWNTIME)
03027                         printf("<TR><TD colspan='%d'><DIV class='csv_export_link'><A HREF='%s&csvtype=downtime' target='_blank'>Export to CSV</A></DIV></TD></TR>\n",colspan,get_export_csv_link(EXTINFO_CGI));
03028 
03029                 printf("<TR><TD colspan='%d' align='right'><input type='button' name='CommandButton' value='Delete Downtimes' onClick=cmd_submit(\'tableform%sdowntime\') disabled=\"disabled\"></TD></TR>\n",colspan,(type==HOST_DOWNTIME)?"host":"service");
03030 
03031                 printf("<TR CLASS='downtime'>");
03032                 if(display_type==DISPLAY_DOWNTIME) {
03033                 printf("<TH CLASS='downtime'>Host Name</TH>");
03034                         if(type==SERVICE_DOWNTIME)
03035                                 printf("<TH CLASS='downtime'>Service</TH>");
03036                 }
03037                 printf("<TH CLASS='downtime'>Entry Time</TH><TH CLASS='downtime'>Author</TH><TH CLASS='downtime'>Comment</TH><TH CLASS='downtime'>Start Time</TH><TH CLASS='downtime'>End Time</TH><TH CLASS='downtime'>Type</TH><TH CLASS='downtime'>Duration</TH><TH CLASS='downtime'>Downtime ID</TH><TH CLASS='downtime'>Trigger ID</TH><TH CLASS='comment' nowrap>Actions&nbsp;&nbsp;<input type='checkbox' value='all' onclick=\"checkAll(\'tableform%sdowntime\');isValidForSubmit(\'tableform%sdowntime\');\"></TH></TR>\n",(type==HOST_DOWNTIME)?"host":"service",(type==HOST_DOWNTIME)?"host":"service");
03038         }
03039 
03040         /* display all the downtime */
03041         for(temp_downtime=scheduled_downtime_list,total_downtime=0;temp_downtime!=NULL;temp_downtime=temp_downtime->next){
03042 
03043                 if(type==HOST_DOWNTIME && temp_downtime->type!=HOST_DOWNTIME)
03044                         continue;
03045 
03046                 if(type==SERVICE_DOWNTIME && temp_downtime->type!=SERVICE_DOWNTIME)
03047                         continue;
03048 
03049                 if(display_type!=DISPLAY_DOWNTIME) {
03050                         /* if not our host -> continue */
03051                         if(strcmp(temp_downtime->host_name,host_name))
03052                                 continue;
03053 
03054                         if(type==SERVICE_DOWNTIME) {
03055                                 /* if not our service -> continue */
03056                                 if(strcmp(temp_downtime->service_description,service_desc))
03057                                         continue;
03058                         }
03059                 } else {
03060                         temp_host=find_host(temp_downtime->host_name);
03061 
03062                         /* make sure the user has rights to view host information */
03063                         if(is_authorized_for_host(temp_host,&current_authdata)==FALSE)
03064                                 continue;
03065 
03066                         if(type==SERVICE_DOWNTIME) {
03067                                 temp_service=find_service(temp_downtime->host_name,temp_downtime->service_description);
03068 
03069                                 /* make sure the user has rights to view service information */
03070                                 if(is_authorized_for_service(temp_service,&current_authdata)==FALSE)
03071                                         continue;
03072                         }
03073                 }
03074 
03075                 if(odd){
03076                         odd=0;
03077                         bg_class="downtimeOdd";
03078                 } else {
03079                         odd=1;
03080                         bg_class="downtimeEven";
03081                 }
03082 
03083                 if(content_type==JSON_CONTENT) {
03084                         // always add a comma, except for the first line
03085                         if (json_start==FALSE)
03086                                 printf(",\n");
03087                         json_start=FALSE;
03088 
03089                         printf("{ ");
03090                         if(display_type==DISPLAY_DOWNTIME) {
03091                                 printf("\"host_name\": \"%s\", ",json_encode(temp_host->name));
03092                                 if(type==SERVICE_DOWNTIME)
03093                                         printf("\"service_description\": \"%s\", ",json_encode(temp_service->description));
03094                                 printf("\"downtime_type\": \"%s\", ",(type==HOST_DOWNTIME)?"HOST":"SERVICE");
03095                         }
03096                 }else if(content_type==CSV_CONTENT) {
03097                         if(display_type==DISPLAY_DOWNTIME) {
03098                                 printf("%s%s%s%s",csv_data_enclosure,(temp_host->display_name!=NULL)?temp_host->display_name:temp_host->name,csv_data_enclosure,csv_delimiter);
03099                                 if(type==SERVICE_DOWNTIME)
03100                                         printf("%s%s%s%s",csv_data_enclosure,(temp_service->display_name!=NULL)?temp_service->display_name:temp_service->description,csv_data_enclosure,csv_delimiter);
03101                                 else
03102                                         printf("%s%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03103                         }
03104                 } else {
03105                         printf("<tr CLASS='%s'>",bg_class);
03106                         if(display_type==DISPLAY_DOWNTIME) {
03107                                 printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s'>%s</A></td>",bg_class,EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_downtime->host_name),(temp_host->display_name!=NULL)?temp_host->display_name:temp_host->name);
03108                                 if(type==SERVICE_DOWNTIME) {
03109                                         printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s",bg_class,EXTINFO_CGI,DISPLAY_SERVICE_INFO,url_encode(temp_downtime->host_name));
03110                                         printf("&service=%s'>%s</A></td>",url_encode(temp_downtime->service_description),(temp_service->display_name!=NULL)?temp_service->display_name:temp_service->description);
03111                                 }
03112                         }
03113                 }
03114 
03115                 get_time_string(&temp_downtime->entry_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
03116                 if(content_type==JSON_CONTENT) {
03117                         printf("\"entry_time\": \"%s\", ",date_time);
03118                         if (temp_downtime->author==NULL)
03119                                 printf("\"author\": null, ");
03120                         else
03121                                 printf("\"author\": \"%s\", ",json_encode(temp_downtime->author));
03122                         if (temp_downtime->author==NULL)
03123                                 printf("\"comment\": null, ");
03124                         else
03125                                 printf("\"comment\": \"%s\", ",json_encode(temp_downtime->comment));
03126                 } else if(content_type==CSV_CONTENT) {
03127                         printf("%s%s%s%s",csv_data_enclosure,date_time,csv_data_enclosure,csv_delimiter);
03128                         printf("%s%s%s%s",csv_data_enclosure,(temp_downtime->author==NULL)?"N/A":temp_downtime->author,csv_data_enclosure,csv_delimiter);
03129                         printf("%s%s%s%s",csv_data_enclosure,(temp_downtime->comment==NULL)?"N/A":temp_downtime->comment,csv_data_enclosure,csv_delimiter);
03130                 } else {
03131                         printf("<td CLASS='%s'>%s</td>",bg_class,date_time);
03132                         printf("<td CLASS='%s'>%s</td>",bg_class,(temp_downtime->author==NULL)?"N/A":temp_downtime->author);
03133                         printf("<td CLASS='%s'>%s</td>",bg_class,(temp_downtime->comment==NULL)?"N/A":temp_downtime->comment);
03134                 }
03135 
03136                 get_time_string(&temp_downtime->start_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
03137                 if(content_type==JSON_CONTENT)
03138                         printf("\"start_time\": \"%s\", ",date_time);
03139                 else if(content_type==CSV_CONTENT)
03140                         printf("%s%s%s%s",csv_data_enclosure,date_time,csv_data_enclosure,csv_delimiter);
03141                 else
03142                         printf("<td CLASS='%s'>%s</td>",bg_class,date_time);
03143 
03144                 get_time_string(&temp_downtime->end_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
03145                 if(content_type==JSON_CONTENT) {
03146                         printf("\"end_time\": \"%s\", ",date_time);
03147                         printf("\"type\": \"%s\", ",(temp_downtime->fixed==TRUE)?"Fixed":"Flexible");
03148                 }else if(content_type==CSV_CONTENT) {
03149                         printf("%s%s%s%s",csv_data_enclosure,date_time,csv_data_enclosure,csv_delimiter);
03150                         printf("%s%s%s%s",csv_data_enclosure,(temp_downtime->fixed==TRUE)?"Fixed":"Flexible",csv_data_enclosure,csv_delimiter);
03151                 } else {
03152                         printf("<td CLASS='%s'>%s</td>",bg_class,date_time);
03153                         printf("<td CLASS='%s'>%s</td>",bg_class,(temp_downtime->fixed==TRUE)?"Fixed":"Flexible");
03154                 }
03155 
03156                 get_time_breakdown(temp_downtime->duration,&days,&hours,&minutes,&seconds);
03157                 if(content_type==JSON_CONTENT) {
03158                         printf("\"duration\": \"%dd %dh %dm %ds\", ",days,hours,minutes,seconds);
03159                         printf("\"downtime_id\": %lu, ",temp_downtime->downtime_id);
03160                         printf("\"trigger_id\": \"");
03161                 }else if(content_type==CSV_CONTENT) {
03162                         printf("%s%dd %dh %dm %ds%s%s",csv_data_enclosure,days,hours,minutes,seconds,csv_data_enclosure,csv_delimiter);
03163                         printf("%s%lu%s%s",csv_data_enclosure,temp_downtime->downtime_id,csv_data_enclosure,csv_delimiter);
03164                         printf("%s",csv_data_enclosure);
03165                 } else {
03166                         printf("<td CLASS='%s'>%dd %dh %dm %ds</td>",bg_class,days,hours,minutes,seconds);
03167                         printf("<td CLASS='%s'>%lu</td>",bg_class,temp_downtime->downtime_id);
03168                         printf("<td CLASS='%s'>",bg_class);
03169                 }
03170                 if(temp_downtime->triggered_by==0) {
03171                         if (content_type==JSON_CONTENT)
03172                                 printf("null");
03173                         else
03174                                 printf("N/A");
03175                 }else
03176                         printf("%lu",temp_downtime->triggered_by);
03177 
03178                 if(content_type==JSON_CONTENT) {
03179                         printf("\" }\n");
03180                 }else if(content_type==CSV_CONTENT) {
03181                         printf("%s\n",csv_data_enclosure);
03182                 } else {
03183                         printf("</td>\n");
03184                         if(type==HOST_DOWNTIME)
03185                                 printf("<td align='center' CLASS='%s'><a href='%s?cmd_typ=%d",bg_class,CMD_CGI,CMD_DEL_HOST_DOWNTIME);
03186                         else
03187                                 printf("<td align='center' CLASS='%s'><a href='%s?cmd_typ=%d",bg_class,CMD_CGI,CMD_DEL_SVC_DOWNTIME);
03188                         printf("&down_id=%lu'><img src='%s%s' border=0 ALT='Delete/Cancel This Scheduled Downtime Entry' TITLE='Delete/Cancel This Scheduled Downtime Entry'></a>",temp_downtime->downtime_id,url_images_path,DELETE_ICON);
03189                         printf("<input onclick=\"isValidForSubmit(\'tableform%sdowntime\');\" type='checkbox' name='checkbox' value='&down_id=%lu'></td>",(type==HOST_DOWNTIME)?"host":"service",temp_downtime->downtime_id);
03190                         printf("</td></tr>\n");
03191                 }
03192                 total_downtime++;
03193         }
03194 
03195         if(content_type!=CSV_CONTENT && content_type!=JSON_CONTENT) {
03196                 if (total_downtime==0) {
03197                         printf("<TR CLASS='downtimeOdd'><TD  align='center' COLSPAN=%d>",colspan);
03198                         if(display_type==DISPLAY_DOWNTIME)
03199                                 printf("There are no %s with scheduled downtime",(type==HOST_DOWNTIME)?"host":"service");
03200                         else
03201                                 printf("This %s has no scheduled downtime associated with it",(type==HOST_DOWNTIME)?"host":"service");
03202                         printf("</TD></TR>\n");
03203                 }
03204                 printf("</TABLE></FORM></DIV>\n");
03205         }
03206         if(content_type==JSON_CONTENT && display_type==DISPLAY_DOWNTIME && type==SERVICE_DOWNTIME)
03207                 printf("\n]\n");
03208 
03209         return;
03210 }
03211 
03212 /* shows check scheduling queue */
03213 void show_scheduling_queue(void){
03214         sortdata *temp_sortdata;
03215         host *temp_host=NULL;
03216         service *temp_service=NULL;
03217         servicestatus *temp_svcstatus=NULL;
03218         hoststatus *temp_hststatus=NULL;
03219         char date_time[MAX_DATETIME_LENGTH];
03220         char temp_url[MAX_INPUT_BUFFER];
03221         char service_link[MAX_INPUT_BUFFER];
03222         char action_link_enable_disable[MAX_INPUT_BUFFER];
03223         char action_link_schedule[MAX_INPUT_BUFFER];
03224         char display_host[MAX_INPUT_BUFFER];
03225         char display_service[MAX_INPUT_BUFFER];
03226         char url_encoded_service[MAX_INPUT_BUFFER];
03227         char url_encoded_host[MAX_INPUT_BUFFER];
03228         char *last_check="", *next_check="", *type="";
03229         int checks_enabled=FALSE;
03230         int odd=0;
03231         char *bgclass="";
03232         int json_start=TRUE;
03233 
03234         /* make sure the user has rights to view system information */
03235         if(is_authorized_for_system_information(&current_authdata)==FALSE){
03236                 print_generic_error_message("It appears as though you do not have permission to view cheduling queue...","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);
03237                 return;
03238         }
03239 
03240         /* sort hosts and services */
03241         sort_data(sort_type,sort_option);
03242 
03243         if(content_type==JSON_CONTENT) {
03244                         printf("\"scheduling_queue\": [\n");
03245         }else if(content_type==CSV_CONTENT) {
03246                 /* csv header line */
03247                 printf("%sHOST%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03248                 printf("%sSERVICE%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03249                 printf("%sLAST_CHECK%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03250                 printf("%sNEXT_CHECK%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03251                 printf("%sTYPE%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter);
03252                 printf("%sACTIVE_CHECKS%s\n",csv_data_enclosure,csv_data_enclosure);
03253         } else {
03254                 printf("<DIV ALIGN=CENTER CLASS='statusSort'>Entries sorted by <b>");
03255                 if(sort_option==SORT_HOSTNAME)
03256                         printf("host name");
03257                 else if(sort_option==SORT_SERVICENAME)
03258                         printf("service name");
03259                 else if(sort_option==SORT_SERVICESTATUS)
03260                         printf("service status");
03261                 else if(sort_option==SORT_LASTCHECKTIME)
03262                         printf("last check time");
03263                 else if(sort_option==SORT_NEXTCHECKTIME)
03264                         printf("next check time");
03265                 printf("</b> (%s)\n",(sort_type==SORT_ASCENDING)?"ascending":"descending");
03266                 printf("</DIV>\n");
03267 
03268                 printf("<DIV ALIGN=CENTER>\n");
03269                 printf("<TABLE BORDER=0 CLASS='queue'>\n");
03270 
03271                 /* add export to csv link */
03272                 printf("<TR><TD colspan='7'><DIV class='csv_export_link'><A HREF='%s' target='_blank'>Export to CSV</A></DIV></TD></TR>\n",get_export_csv_link(EXTINFO_CGI));
03273 
03274                 printf("<TR CLASS='queue'>");
03275 
03276                 snprintf(temp_url,sizeof(temp_url)-1,"%s?type=%d",EXTINFO_CGI,DISPLAY_SCHEDULING_QUEUE);
03277                 temp_url[sizeof(temp_url)-1]='\x0';
03278 
03279                 printf("<TH CLASS='queue'>Host&nbsp;<A HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by host name (ascending)' TITLE='Sort by host name (ascending)'></A><A HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by host name (descending)' TITLE='Sort by host name (descending)'></A></TH>",temp_url,SORT_ASCENDING,SORT_HOSTNAME,url_images_path,UP_ARROW_ICON,temp_url,SORT_DESCENDING,SORT_HOSTNAME,url_images_path,DOWN_ARROW_ICON);
03280                 printf("<TH CLASS='queue'>Service&nbsp;<A HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by service name (ascending)' TITLE='Sort by service name (ascending)'></A><A HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by service name (descending)' TITLE='Sort by service name (descending)'></A></TH>",temp_url,SORT_ASCENDING,SORT_SERVICENAME,url_images_path,UP_ARROW_ICON,temp_url,SORT_DESCENDING,SORT_SERVICENAME,url_images_path,DOWN_ARROW_ICON);
03281                 printf("<TH CLASS='queue'>Last Check&nbsp;<A HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by last check time (ascending)' TITLE='Sort by last check time (ascending)'></A><A HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by last check time (descending)' TITLE='Sort by last check time (descending)'></A></TH>",temp_url,SORT_ASCENDING,SORT_LASTCHECKTIME,url_images_path,UP_ARROW_ICON,temp_url,SORT_DESCENDING,SORT_LASTCHECKTIME,url_images_path,DOWN_ARROW_ICON);
03282                 printf("<TH CLASS='queue'>Next Check&nbsp;<A HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by next check time (ascending)' TITLE='Sort by next check time (ascending)'></A><A HREF='%s&sorttype=%d&sortoption=%d'><IMG SRC='%s%s' BORDER=0 ALT='Sort by next check time (descending)' TITLE='Sort by next check time (descending)'></A></TH>",temp_url,SORT_ASCENDING,SORT_NEXTCHECKTIME,url_images_path,UP_ARROW_ICON,temp_url,SORT_DESCENDING,SORT_NEXTCHECKTIME,url_images_path,DOWN_ARROW_ICON);
03283                 printf("<TH CLASS='queue'>Type</TH><TH CLASS='queue'>Active Checks</TH><TH CLASS='queue'>Actions</TH></TR>\n");
03284         }
03285 
03286         /* display all services and hosts */
03287         for(temp_sortdata=sortdata_list;temp_sortdata!=NULL;temp_sortdata=temp_sortdata->next){
03288 
03289                 /* skip hosts and services that shouldn't be scheduled */
03290                 if(temp_sortdata->is_service==TRUE){
03291                         temp_svcstatus=temp_sortdata->svcstatus;
03292                         if(temp_svcstatus->should_be_scheduled==FALSE){
03293                                 /* passive-only checks should appear if they're being forced */
03294                                 if(!(temp_svcstatus->checks_enabled==FALSE && temp_svcstatus->next_check!=(time_t)0L && (temp_svcstatus->check_options & CHECK_OPTION_FORCE_EXECUTION)))
03295                                         continue;
03296                         }
03297                 }else{
03298                         temp_hststatus=temp_sortdata->hststatus;
03299                         if(temp_hststatus->should_be_scheduled==FALSE){
03300                                 /* passive-only checks should appear if they're being forced */
03301                                 if(!(temp_hststatus->checks_enabled==FALSE && temp_hststatus->next_check!=(time_t)0L && (temp_hststatus->check_options & CHECK_OPTION_FORCE_EXECUTION)))
03302                                         continue;
03303                         }
03304                 }
03305 
03306                 if(odd){
03307                         odd=0;
03308                         bgclass="Even";
03309                 }else{
03310                         odd=1;
03311                         bgclass="Odd";
03312                 }
03313 
03314                 /* get the service status */
03315                 if(temp_sortdata->is_service==TRUE){
03316                         /* find the host */
03317                         temp_host=find_host(temp_svcstatus->host_name);
03318                         snprintf(url_encoded_host,sizeof(url_encoded_host)-1,"%s",url_encode(temp_svcstatus->host_name));
03319                         url_encoded_host[sizeof(url_encoded_host)-1]='\x0';
03320 
03321                         /* find the service */
03322                         temp_service=find_service(temp_svcstatus->host_name,temp_svcstatus->description);
03323                         snprintf(url_encoded_service,sizeof(url_encoded_service)-1,"%s",url_encode(temp_svcstatus->description));
03324                         url_encoded_service[sizeof(url_encoded_service)-1]='\x0';
03325 
03326                         /* host name */
03327                         if(temp_host!=NULL)
03328                                 snprintf(display_host,sizeof(display_host)-1,"%s",(temp_host->display_name!=NULL)?temp_host->display_name:temp_host->name);
03329                         else
03330                                 snprintf(display_host,sizeof(display_host)-1,"%s",temp_svcstatus->host_name);
03331                         display_host[sizeof(display_host)-1]='\x0';
03332 
03333                         /* service name */
03334                         if(temp_service!=NULL)
03335                                 snprintf(display_service,sizeof(display_service)-1,"%s",(temp_service->display_name!=NULL)?temp_service->display_name:temp_svcstatus->description);
03336                         else
03337                                 snprintf(display_service,sizeof(display_service)-1,"%s",temp_svcstatus->description);
03338                         display_service[sizeof(display_service)-1]='\x0';
03339 
03340                         /* service link*/
03341                         snprintf(service_link,sizeof(service_link)-1,"%s?type=%d&host=%s&service=%s",EXTINFO_CGI,DISPLAY_SERVICE_INFO,url_encoded_host,url_encoded_service);
03342                         service_link[sizeof(service_link)-1]='\x0';
03343 
03344                         /* last check */
03345                         get_time_string(&temp_svcstatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
03346                         last_check=(temp_svcstatus->last_check==(time_t)0)?"N/A":date_time;
03347 
03348                         /* next check */
03349                         get_time_string(&temp_svcstatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
03350                         next_check=(temp_svcstatus->next_check==(time_t)0)?"N/A":date_time;
03351 
03352                         /* type */
03353                         if(temp_svcstatus->check_options==CHECK_OPTION_NONE)
03354                                 type="Normal";
03355                         else{
03356                                 if(temp_svcstatus->check_options & CHECK_OPTION_FORCE_EXECUTION)
03357                                         type="Forced";
03358                                 if(temp_svcstatus->check_options & CHECK_OPTION_FRESHNESS_CHECK)
03359                                         type="Freshness";
03360                                 if(temp_svcstatus->check_options & CHECK_OPTION_ORPHAN_CHECK)
03361                                         type="Orphan";
03362                         }
03363 
03364                         /* active checks */
03365                         checks_enabled=temp_svcstatus->checks_enabled;
03366 
03367                         /* action links */
03368                         if(temp_svcstatus->checks_enabled==TRUE)
03369                                 snprintf(action_link_enable_disable,sizeof(action_link_enable_disable)-1,"%s?cmd_typ=%d&host=%s&service=%s",CMD_CGI,CMD_DISABLE_SVC_CHECK,url_encoded_host,url_encoded_service);
03370                         else
03371                                 snprintf(action_link_enable_disable,sizeof(action_link_enable_disable)-1,"%s?cmd_typ=%d&host=%s&service=%s",CMD_CGI,CMD_ENABLE_SVC_CHECK,url_encoded_host,url_encoded_service);
03372                         action_link_enable_disable[sizeof(action_link_enable_disable)-1]='\x0';
03373 
03374                         snprintf(action_link_schedule,sizeof(action_link_schedule)-1,"%s?cmd_typ=%d&host=%s&service=%s%s",CMD_CGI,CMD_SCHEDULE_SVC_CHECK,url_encoded_host,url_encoded_service,(temp_svcstatus->checks_enabled==TRUE)?"&force_check":"");
03375                         action_link_schedule[sizeof(action_link_schedule)-1]='\x0';
03376 
03377                 /* get the host status */
03378                 }else{
03379                         /* find the host */
03380                         temp_host=find_host(temp_hststatus->host_name);
03381                         snprintf(url_encoded_host,sizeof(url_encoded_host)-1,"%s",url_encode(temp_hststatus->host_name));
03382                         url_encoded_host[sizeof(url_encoded_host)-1]='\x0';
03383 
03384                         /* host name*/
03385                         if(temp_host!=NULL)
03386                                 snprintf(display_host,sizeof(display_host)-1,"%s",(temp_host->display_name!=NULL)?temp_host->display_name:temp_host->name);
03387                         else
03388                                 snprintf(display_host,sizeof(display_host)-1,"%s",temp_hststatus->host_name);
03389                         display_host[sizeof(display_host)-1]='\x0';
03390 
03391                         /* last check */
03392                         get_time_string(&temp_hststatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
03393                         last_check=(temp_hststatus->last_check==(time_t)0)?"N/A":date_time;
03394 
03395                         /* next check */
03396                         get_time_string(&temp_hststatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
03397                         next_check=(temp_hststatus->next_check==(time_t)0)?"N/A":date_time;
03398 
03399                         /* type */
03400                         if(temp_hststatus->check_options==CHECK_OPTION_NONE)
03401                                 type="Normal";
03402                         else {
03403                                 if(temp_hststatus->check_options & CHECK_OPTION_FORCE_EXECUTION)
03404                                         type="Forced";
03405                                 if(temp_hststatus->check_options & CHECK_OPTION_FRESHNESS_CHECK)
03406                                         type="Freshness";
03407                                 if(temp_hststatus->check_options & CHECK_OPTION_ORPHAN_CHECK)
03408                                         type="Orphan";
03409                         }
03410 
03411                         /* active checks */
03412                         checks_enabled=temp_hststatus->checks_enabled;
03413 
03414                         /* action links */
03415                         if(temp_hststatus->checks_enabled==TRUE)
03416                                 snprintf(action_link_enable_disable,sizeof(action_link_enable_disable)-1,"%s?cmd_typ=%d&host=%s",CMD_CGI,CMD_DISABLE_HOST_CHECK,url_encoded_host);
03417                         else
03418                                 snprintf(action_link_enable_disable,sizeof(action_link_enable_disable)-1,"%s?cmd_typ=%d&host=%s",CMD_CGI,CMD_ENABLE_HOST_CHECK,url_encoded_host);
03419                         action_link_enable_disable[sizeof(action_link_enable_disable)-1]='\x0';
03420 
03421                         snprintf(action_link_schedule,sizeof(action_link_schedule)-1,"%s?cmd_typ=%d&host=%s%s",CMD_CGI,CMD_SCHEDULE_HOST_CHECK,url_encoded_host,(temp_hststatus->checks_enabled==TRUE)?"&force_check":"");
03422                         action_link_schedule[sizeof(action_link_schedule)-1]='\x0';
03423                 }
03424 
03425                 if(content_type==JSON_CONTENT) {
03426                         // always add a comma, except for the first line
03427                         if (json_start==FALSE)
03428                                 printf(",\n");
03429                         json_start=FALSE;
03430 
03431                         printf("{ \"host_name\": \"%s\", ",json_encode(display_host));
03432                         if (temp_sortdata->is_service==TRUE) {
03433                                 printf("\"service_description\": \"%s\", ",json_encode(display_service));
03434                                 printf("\"type\": \"SERVICE_CHECK\", ");
03435                         }else
03436                                 printf("\"type\": \"HOST_CHECK\", ");
03437 
03438                         printf("\"last_check\": \"%s\", ",last_check);
03439                         printf("\"next_check\": \"%s\", ",next_check);
03440                         printf("\"type\": \"%s\", ",type);
03441                         printf("\"active_check\": %s }",(checks_enabled==TRUE)?"true":"false");
03442                 }else if(content_type==CSV_CONTENT) {
03443                         printf("%s%s%s%s",csv_data_enclosure,display_host,csv_data_enclosure,csv_delimiter);
03444                         printf("%s%s%s%s",csv_data_enclosure,(temp_sortdata->is_service==TRUE)?display_service:"",csv_data_enclosure,csv_delimiter);
03445                         printf("%s%s%s%s",csv_data_enclosure,last_check,csv_data_enclosure,csv_delimiter);
03446                         printf("%s%s%s%s",csv_data_enclosure,next_check,csv_data_enclosure,csv_delimiter);
03447                         printf("%s%s%s%s",csv_data_enclosure,type,csv_data_enclosure,csv_delimiter);
03448                         printf("%s%s%s\n",csv_data_enclosure,(checks_enabled==TRUE)?"ENABLED":"DISABLED",csv_data_enclosure);
03449                 }else{
03450                         printf("<TR CLASS='queue%s'>",bgclass);
03451 
03452                         /* Host */
03453                         printf("<TD CLASS='queue%s'><A HREF='%s?type=%d&host=%s'>%s</A></TD>",bgclass,EXTINFO_CGI,DISPLAY_HOST_INFO,url_encoded_host,display_host);
03454 
03455                         /* Service */
03456                         if(temp_sortdata->is_service==TRUE)
03457                                 printf("<TD CLASS='queue%s'><A HREF='%s'>%s</A></TD>",bgclass,service_link,display_service);
03458                         else
03459                                 printf("<TD CLASS='queue%s'>&nbsp;</TD>",bgclass);
03460 
03461                         /* last check */
03462                         printf("<TD CLASS='queue%s'>%s</TD>",bgclass,last_check);
03463 
03464                         /* next check */
03465                         printf("<TD CLASS='queue%s'>%s</TD>",bgclass,next_check);
03466 
03467                         /* type */
03468                         printf("<TD align='center' CLASS='queue%s'>%s</TD>",bgclass,type);
03469 
03470                         /* active checks */
03471                         printf("<TD CLASS='queue%s'>%s</TD>",(checks_enabled==TRUE)?"ENABLED":"DISABLED",(checks_enabled==TRUE)?"ENABLED":"DISABLED");
03472 
03473                         /* actions */
03474                         printf("<TD align='center' CLASS='queue%s'>",bgclass);
03475                         printf("<a href='%s'><img src='%s%s' border=0 ALT='%s Active Checks Of This %s' TITLE='%s Active Checks Of This %s'></a>\n",action_link_enable_disable,url_images_path,(checks_enabled==TRUE)?DISABLED_ICON:ENABLED_ICON,(checks_enabled==TRUE)?"Disable":"Enable",(temp_sortdata->is_service==TRUE)?"Service":"Host",(checks_enabled==TRUE)?"Disable":"Enable",(temp_sortdata->is_service==TRUE)?"Service":"Host");
03476                         printf("<a href='%s'><img src='%s%s' border=0 ALT='Re-schedule This %s Check' TITLE='Re-schedule This %s Check'></a>",action_link_schedule,url_images_path,DELAY_ICON,(temp_sortdata->is_service==TRUE)?"Service":"Host",(temp_sortdata->is_service==TRUE)?"Service":"Host");
03477 
03478                         printf("</TD></TR>\n");
03479                 }
03480         }
03481 
03482         if (content_type!=CSV_CONTENT && content_type!=JSON_CONTENT) {
03483                 printf("</TABLE>\n");
03484                 printf("</DIV>\n");
03485         }else if(content_type==JSON_CONTENT)
03486                 printf(" ] \n");
03487 
03488         /* free memory allocated to sorted data list */
03489         free_sortdata_list();
03490 
03491         return;
03492 }
03493 
03494 /* sorts host and service data */
03495 int sort_data(int s_type, int s_option){
03496         sortdata *new_sortdata;
03497         sortdata *last_sortdata;
03498         sortdata *temp_sortdata;
03499         servicestatus *temp_svcstatus;
03500         hoststatus *temp_hststatus;
03501 
03502         if(s_type==SORT_NONE)
03503                 return ERROR;
03504 
03505         /* sort all service status entries */
03506         for(temp_svcstatus=servicestatus_list;temp_svcstatus!=NULL;temp_svcstatus=temp_svcstatus->next){
03507 
03508                 /* allocate memory for a new sort structure */
03509                 new_sortdata=(sortdata *)malloc(sizeof(sortdata));
03510                 if(new_sortdata==NULL)
03511                         return ERROR;
03512 
03513                 new_sortdata->is_service=TRUE;
03514                 new_sortdata->svcstatus=temp_svcstatus;
03515                 new_sortdata->hststatus=NULL;
03516 
03517                 last_sortdata=sortdata_list;
03518                 for(temp_sortdata=sortdata_list;temp_sortdata!=NULL;temp_sortdata=temp_sortdata->next){
03519 
03520                         if(compare_sortdata_entries(s_type,s_option,new_sortdata,temp_sortdata)==TRUE){
03521                                 new_sortdata->next=temp_sortdata;
03522                                 if(temp_sortdata==sortdata_list)
03523                                         sortdata_list=new_sortdata;
03524                                 else
03525                                         last_sortdata->next=new_sortdata;
03526                                 break;
03527                                 }
03528                         else
03529                                 last_sortdata=temp_sortdata;
03530                         }
03531 
03532                 if(sortdata_list==NULL){
03533                         new_sortdata->next=NULL;
03534                         sortdata_list=new_sortdata;
03535                         }
03536                 else if(temp_sortdata==NULL){
03537                         new_sortdata->next=NULL;
03538                         last_sortdata->next=new_sortdata;
03539                         }
03540                 }
03541 
03542         /* sort all host status entries */
03543         for(temp_hststatus=hoststatus_list;temp_hststatus!=NULL;temp_hststatus=temp_hststatus->next){
03544 
03545                 /* allocate memory for a new sort structure */
03546                 new_sortdata=(sortdata *)malloc(sizeof(sortdata));
03547                 if(new_sortdata==NULL)
03548                         return ERROR;
03549 
03550                 new_sortdata->is_service=FALSE;
03551                 new_sortdata->svcstatus=NULL;
03552                 new_sortdata->hststatus=temp_hststatus;
03553 
03554                 last_sortdata=sortdata_list;
03555                 for(temp_sortdata=sortdata_list;temp_sortdata!=NULL;temp_sortdata=temp_sortdata->next){
03556 
03557                         if(compare_sortdata_entries(s_type,s_option,new_sortdata,temp_sortdata)==TRUE){
03558                                 new_sortdata->next=temp_sortdata;
03559                                 if(temp_sortdata==sortdata_list)
03560                                         sortdata_list=new_sortdata;
03561                                 else
03562                                         last_sortdata->next=new_sortdata;
03563                                 break;
03564                                 }
03565                         else
03566                                 last_sortdata=temp_sortdata;
03567                         }
03568 
03569                 if(sortdata_list==NULL){
03570                         new_sortdata->next=NULL;
03571                         sortdata_list=new_sortdata;
03572                         }
03573                 else if(temp_sortdata==NULL){
03574                         new_sortdata->next=NULL;
03575                         last_sortdata->next=new_sortdata;
03576                         }
03577                 }
03578 
03579         return OK;
03580 }
03581 
03582 int compare_sortdata_entries(int s_type, int s_option, sortdata *new_sortdata, sortdata *temp_sortdata){
03583         hoststatus *temp_hststatus=NULL;
03584         servicestatus *temp_svcstatus=NULL;
03585         time_t last_check[2];
03586         time_t next_check[2];
03587         int current_attempt[2];
03588         int status[2];
03589         char *host_name[2];
03590         char *service_description[2];
03591 
03592         if(new_sortdata->is_service==TRUE){
03593                 temp_svcstatus=new_sortdata->svcstatus;
03594                 last_check[0]=temp_svcstatus->last_check;
03595                 next_check[0]=temp_svcstatus->next_check;
03596                 status[0]=temp_svcstatus->status;
03597                 host_name[0]=temp_svcstatus->host_name;
03598                 service_description[0]=temp_svcstatus->description;
03599                 current_attempt[0]=temp_svcstatus->current_attempt;
03600                 }
03601         else{
03602                 temp_hststatus=new_sortdata->hststatus;
03603                 last_check[0]=temp_hststatus->last_check;
03604                 next_check[0]=temp_hststatus->next_check;
03605                 status[0]=temp_hststatus->status;
03606                 host_name[0]=temp_hststatus->host_name;
03607                 service_description[0]="";
03608                 current_attempt[0]=temp_hststatus->current_attempt;
03609                 }
03610         if(temp_sortdata->is_service==TRUE){
03611                 temp_svcstatus=temp_sortdata->svcstatus;
03612                 last_check[1]=temp_svcstatus->last_check;
03613                 next_check[1]=temp_svcstatus->next_check;
03614                 status[1]=temp_svcstatus->status;
03615                 host_name[1]=temp_svcstatus->host_name;
03616                 service_description[1]=temp_svcstatus->description;
03617                 current_attempt[1]=temp_svcstatus->current_attempt;
03618                 }
03619         else{
03620                 temp_hststatus=temp_sortdata->hststatus;
03621                 last_check[1]=temp_hststatus->last_check;
03622                 next_check[1]=temp_hststatus->next_check;
03623                 status[1]=temp_hststatus->status;
03624                 host_name[1]=temp_hststatus->host_name;
03625                 service_description[1]="";
03626                 current_attempt[1]=temp_hststatus->current_attempt;
03627                 }
03628 
03629         if(s_type==SORT_ASCENDING){
03630 
03631                 if(s_option==SORT_LASTCHECKTIME){
03632                         if(last_check[0] <= last_check[1])
03633                                 return TRUE;
03634                         else
03635                                 return FALSE;
03636                         }
03637                 if(s_option==SORT_NEXTCHECKTIME){
03638                         if(next_check[0] <= next_check[1])
03639                                 return TRUE;
03640                         else
03641                                 return FALSE;
03642                         }
03643                 else if(s_option==SORT_CURRENTATTEMPT){
03644                         if(current_attempt[0] <= current_attempt[1])
03645                                 return TRUE;
03646                         else
03647                                 return FALSE;
03648                         }
03649                 else if(s_option==SORT_SERVICESTATUS){
03650                         if(status[0] <= status[1])
03651                                 return TRUE;
03652                         else
03653                                 return FALSE;
03654                         }
03655                 else if(s_option==SORT_HOSTNAME){
03656                         if(strcasecmp(host_name[0],host_name[1])<0)
03657                                 return TRUE;
03658                         else
03659                                 return FALSE;
03660                         }
03661                 else if(s_option==SORT_SERVICENAME){
03662                         if(strcasecmp(service_description[0],service_description[1])<0)
03663                                 return TRUE;
03664                         else
03665                                 return FALSE;
03666                         }
03667                 }
03668         else{
03669                 if(s_option==SORT_LASTCHECKTIME){
03670                         if(last_check[0] > last_check[1])
03671                                 return TRUE;
03672                         else
03673                                 return FALSE;
03674                         }
03675                 if(s_option==SORT_NEXTCHECKTIME){
03676                         if(next_check[0] > next_check[1])
03677                                 return TRUE;
03678                         else
03679                                 return FALSE;
03680                         }
03681                 else if(s_option==SORT_CURRENTATTEMPT){
03682                         if(current_attempt[0] > current_attempt[1])
03683                                 return TRUE;
03684                         else
03685                                 return FALSE;
03686                         }
03687                 else if(s_option==SORT_SERVICESTATUS){
03688                         if(status[0] > status[1])
03689                                 return TRUE;
03690                         else
03691                                 return FALSE;
03692                         }
03693                 else if(s_option==SORT_HOSTNAME){
03694                         if(strcasecmp(host_name[0],host_name[1])>0)
03695                                 return TRUE;
03696                         else
03697                                 return FALSE;
03698                         }
03699                 else if(s_option==SORT_SERVICENAME){
03700                         if(strcasecmp(service_description[0],service_description[1])>0)
03701                                 return TRUE;
03702                         else
03703                                 return FALSE;
03704                         }
03705                 }
03706 
03707         return TRUE;
03708 }
03709 
03710 /* free all memory allocated to the sortdata structures */
03711 void free_sortdata_list(void){
03712         sortdata *this_sortdata;
03713         sortdata *next_sortdata;
03714 
03715         /* free memory for the sortdata list */
03716         for(this_sortdata=sortdata_list;this_sortdata!=NULL;this_sortdata=next_sortdata){
03717                 next_sortdata=this_sortdata->next;
03718                 free(this_sortdata);
03719         }
03720 
03721         return;
03722 }
03723 
 All Data Structures Files Functions Variables Typedefs Defines