~yolanda.robla/ubuntu/saucy/nagios3/dep-8-tests

« back to all changes in this revision

Viewing changes to cgi/extinfo.c

  • Committer: Package Import Robot
  • Author(s): Alexander Wirt
  • Date: 2012-06-16 09:05:19 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120616090519-ne14zejkhhyboolc
Tags: 3.4.1-1
* [28e077b] Imported Upstream version 3.3.1
* [d5314e0] don't call updatepo in clean target
* [45b3eb9] Don't remove config foo
* [54e3dff] Don't fix permissions in cgi postinst
* [d7be9db] Build-depend on libpng-dev (Closes: #662441)
* [4c47006] Add dutch po translation (Closes: #654855)
* [2b6573b] Refresh 10_p1_pl_shebang.dpatch
* [316fd7a] Update 40_fix_spurious_dollar_signs_added_to_command_lines
* [5ff2780] Refresh 55_strip_logarchivepath.dpatch
* [811d269] Refresh 60_fix_p1.pl_patch_mini_epn.dpatch
* [39a1e9c] Remove now unneeded patch 98_fix_XSS_CVE-2011-2179
* [785a4e8] Remove unneded patch 99_fix_XSS_CVE-2011-1523
* [6ce98ef] Remove unneeded patchs from 00list
* [1d18266] Imported Upstream version 3.4.0
* [05584c8] Refresh patches
* [58098cd] Imported Upstream version 3.4.1
* [3e9e07a] Bump standards version
* [fe991e2] wrap-and-sort
* [1ba78f7] Also create /var/run/nagios in cgi package (Closes: #626854)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Last Modified: 06-17-2009
7
7
 *
8
8
 * License:
9
 
 * 
 
9
 *
10
10
 * This program is free software; you can redistribute it and/or modify
11
11
 * it under the terms of the GNU General Public License version 2 as
12
12
 * published by the Free Software Foundation.
33
33
#include "../include/getcgi.h"
34
34
#include "../include/cgiauth.h"
35
35
 
 
36
static nagios_macros *mac;
 
37
 
36
38
extern char             nagios_check_command[MAX_INPUT_BUFFER];
37
39
extern char             nagios_process_info[MAX_INPUT_BUFFER];
38
40
extern int              nagios_process_state;
85
87
#define HEALTH_CRITICAL_PERCENTAGE      75
86
88
 
87
89
/* SORTDATA structure */
88
 
typedef struct sortdata_struct{
 
90
typedef struct sortdata_struct {
89
91
        int is_service;
90
92
        servicestatus *svcstatus;
91
93
        hoststatus *hststatus;
92
94
        struct sortdata_struct *next;
93
 
        }sortdata;
 
95
        } sortdata;
94
96
 
95
97
void document_header(int);
96
98
void document_footer(void);
107
109
void show_scheduling_queue(void);
108
110
void display_comments(int);
109
111
 
110
 
int sort_data(int,int);
111
 
int compare_sortdata_entries(int,int,sortdata *,sortdata *);
 
112
int sort_data(int, int);
 
113
int compare_sortdata_entries(int, int, sortdata *, sortdata *);
112
114
void free_sortdata_list(void);
113
115
 
114
116
authdata current_authdata;
115
117
 
116
 
sortdata *sortdata_list=NULL;
117
 
 
118
 
char *host_name="";
119
 
char *hostgroup_name="";
120
 
char *servicegroup_name="";
121
 
char *service_desc="";
122
 
 
123
 
int display_type=DISPLAY_PROCESS_INFO;
124
 
 
125
 
int sort_type=SORT_ASCENDING;
126
 
int sort_option=SORT_NEXTCHECKTIME;
127
 
 
128
 
int embedded=FALSE;
129
 
int display_header=TRUE;
130
 
 
131
 
 
132
 
 
133
 
int main(void){
134
 
        int result=OK;
135
 
        int found=FALSE;
136
 
        char temp_buffer[MAX_INPUT_BUFFER]="";
137
 
        char *processed_string=NULL;
138
 
        host *temp_host=NULL;
139
 
        hostsmember *temp_parenthost=NULL;
140
 
        hostgroup *temp_hostgroup=NULL;
141
 
        service *temp_service=NULL;
142
 
        servicegroup *temp_servicegroup=NULL;
143
 
        
 
118
sortdata *sortdata_list = NULL;
 
119
 
 
120
char *host_name = "";
 
121
char *hostgroup_name = "";
 
122
char *servicegroup_name = "";
 
123
char *service_desc = "";
 
124
 
 
125
int display_type = DISPLAY_PROCESS_INFO;
 
126
 
 
127
int sort_type = SORT_ASCENDING;
 
128
int sort_option = SORT_NEXTCHECKTIME;
 
129
 
 
130
int embedded = FALSE;
 
131
int display_header = TRUE;
 
132
 
 
133
 
 
134
 
 
135
int main(void) {
 
136
        int result = OK;
 
137
        int found = FALSE;
 
138
        char temp_buffer[MAX_INPUT_BUFFER] = "";
 
139
        char *processed_string = NULL;
 
140
        host *temp_host = NULL;
 
141
        hostsmember *temp_parenthost = NULL;
 
142
        hostgroup *temp_hostgroup = NULL;
 
143
        service *temp_service = NULL;
 
144
        servicegroup *temp_servicegroup = NULL;
 
145
 
 
146
        mac = get_global_macros();
144
147
 
145
148
        /* get the arguments passed in the URL */
146
149
        process_cgivars();
149
152
        reset_cgi_vars();
150
153
 
151
154
        /* read the CGI configuration file */
152
 
        result=read_cgi_config_file(get_cgi_config_location());
153
 
        if(result==ERROR){
 
155
        result = read_cgi_config_file(get_cgi_config_location());
 
156
        if(result == ERROR) {
154
157
                document_header(FALSE);
155
158
                cgi_config_file_error(get_cgi_config_location());
156
159
                document_footer();
157
160
                return ERROR;
158
 
                }
 
161
                }
159
162
 
160
163
        /* read the main configuration file */
161
 
        result=read_main_config_file(main_config_file);
162
 
        if(result==ERROR){
 
164
        result = read_main_config_file(main_config_file);
 
165
        if(result == ERROR) {
163
166
                document_header(FALSE);
164
167
                main_config_file_error(main_config_file);
165
168
                document_footer();
166
169
                return ERROR;
167
 
                }
 
170
                }
168
171
 
169
172
        /* read all object configuration data */
170
 
        result=read_all_object_configuration_data(main_config_file,READ_ALL_OBJECT_DATA);
171
 
        if(result==ERROR){
 
173
        result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
 
174
        if(result == ERROR) {
172
175
                document_header(FALSE);
173
176
                object_data_error();
174
177
                document_footer();
175
178
                return ERROR;
176
 
                }
 
179
                }
177
180
 
178
181
        /* read all status data */
179
 
        result=read_all_status_data(get_cgi_config_location(),READ_ALL_STATUS_DATA);
180
 
        if(result==ERROR){
 
182
        result = read_all_status_data(get_cgi_config_location(), READ_ALL_STATUS_DATA);
 
183
        if(result == ERROR) {
181
184
                document_header(FALSE);
182
185
                status_data_error();
183
186
                document_footer();
184
187
                free_memory();
185
188
                return ERROR;
186
 
                }
 
189
                }
187
190
 
188
191
        /* initialize macros */
189
192
        init_macros();
194
197
        get_authentication_information(&current_authdata);
195
198
 
196
199
 
197
 
        if(display_header==TRUE){
 
200
        if(display_header == TRUE) {
198
201
 
199
202
                /* begin top table */
200
203
                printf("<table border=0 width=100%%>\n");
203
206
                /* left column of the first row */
204
207
                printf("<td align=left valign=top width=33%%>\n");
205
208
 
206
 
                if(display_type==DISPLAY_HOST_INFO)
207
 
                        snprintf(temp_buffer,sizeof(temp_buffer)-1,"Host Information");
208
 
                else if(display_type==DISPLAY_SERVICE_INFO)
209
 
                        snprintf(temp_buffer,sizeof(temp_buffer)-1,"Service Information");
210
 
                else if(display_type==DISPLAY_COMMENTS)
211
 
                        snprintf(temp_buffer,sizeof(temp_buffer)-1,"All Host and Service Comments");
212
 
                else if(display_type==DISPLAY_PERFORMANCE)
213
 
                        snprintf(temp_buffer,sizeof(temp_buffer)-1,"Performance Information");
214
 
                else if(display_type==DISPLAY_HOSTGROUP_INFO)
215
 
                        snprintf(temp_buffer,sizeof(temp_buffer)-1,"Hostgroup Information");
216
 
                else if(display_type==DISPLAY_SERVICEGROUP_INFO)
217
 
                        snprintf(temp_buffer,sizeof(temp_buffer)-1,"Servicegroup Information");
218
 
                else if(display_type==DISPLAY_DOWNTIME)
219
 
                        snprintf(temp_buffer,sizeof(temp_buffer)-1,"All Host and Service Scheduled Downtime");
220
 
                else if(display_type==DISPLAY_SCHEDULING_QUEUE)
221
 
                        snprintf(temp_buffer,sizeof(temp_buffer)-1,"Check Scheduling Queue");
 
209
                if(display_type == DISPLAY_HOST_INFO)
 
210
                        snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Host Information");
 
211
                else if(display_type == DISPLAY_SERVICE_INFO)
 
212
                        snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Service Information");
 
213
                else if(display_type == DISPLAY_COMMENTS)
 
214
                        snprintf(temp_buffer, sizeof(temp_buffer) - 1, "All Host and Service Comments");
 
215
                else if(display_type == DISPLAY_PERFORMANCE)
 
216
                        snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Performance Information");
 
217
                else if(display_type == DISPLAY_HOSTGROUP_INFO)
 
218
                        snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Hostgroup Information");
 
219
                else if(display_type == DISPLAY_SERVICEGROUP_INFO)
 
220
                        snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Servicegroup Information");
 
221
                else if(display_type == DISPLAY_DOWNTIME)
 
222
                        snprintf(temp_buffer, sizeof(temp_buffer) - 1, "All Host and Service Scheduled Downtime");
 
223
                else if(display_type == DISPLAY_SCHEDULING_QUEUE)
 
224
                        snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Check Scheduling Queue");
222
225
                else
223
 
                        snprintf(temp_buffer,sizeof(temp_buffer)-1,"Nagios Process Information");
224
 
                temp_buffer[sizeof(temp_buffer)-1]='\x0';
225
 
                display_info_table(temp_buffer,TRUE,&current_authdata);
 
226
                        snprintf(temp_buffer, sizeof(temp_buffer) - 1, "Nagios Process Information");
 
227
                temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
 
228
                display_info_table(temp_buffer, TRUE, &current_authdata);
226
229
 
227
230
                /* find the host */
228
 
                if(display_type==DISPLAY_HOST_INFO || display_type==DISPLAY_SERVICE_INFO){
229
 
 
230
 
                        temp_host=find_host(host_name);
231
 
                        grab_host_macros(temp_host);
232
 
 
233
 
                        if(display_type==DISPLAY_SERVICE_INFO){
234
 
                                temp_service=find_service(host_name,service_desc);
235
 
                                grab_service_macros(temp_service);
 
231
                if(display_type == DISPLAY_HOST_INFO || display_type == DISPLAY_SERVICE_INFO) {
 
232
 
 
233
                        temp_host = find_host(host_name);
 
234
                        grab_host_macros_r(mac, temp_host);
 
235
 
 
236
                        if(display_type == DISPLAY_SERVICE_INFO) {
 
237
                                temp_service = find_service(host_name, service_desc);
 
238
                                grab_service_macros_r(mac, temp_service);
236
239
                                }
237
240
 
238
241
                        /* write some Javascript helper functions */
239
 
                        if(temp_host!=NULL){
 
242
                        if(temp_host != NULL) {
240
243
                                printf("<SCRIPT LANGUAGE=\"JavaScript\">\n<!--\n");
241
244
                                printf("function nagios_get_host_name()\n{\n");
242
 
                                printf("return \"%s\";\n",temp_host->name);
 
245
                                printf("return \"%s\";\n", temp_host->name);
243
246
                                printf("}\n");
244
247
                                printf("function nagios_get_host_address()\n{\n");
245
 
                                printf("return \"%s\";\n",temp_host->address);
 
248
                                printf("return \"%s\";\n", temp_host->address);
246
249
                                printf("}\n");
247
 
                                if(temp_service!=NULL){
 
250
                                if(temp_service != NULL) {
248
251
                                        printf("function nagios_get_service_description()\n{\n");
249
 
                                        printf("return \"%s\";\n",temp_service->description);
 
252
                                        printf("return \"%s\";\n", temp_service->description);
250
253
                                        printf("}\n");
251
 
                                        }
 
254
                                        }
252
255
                                printf("//-->\n</SCRIPT>\n");
253
 
                                }
254
 
                        }
 
256
                                }
 
257
                        }
255
258
 
256
259
                /* find the hostgroup */
257
 
                else if(display_type==DISPLAY_HOSTGROUP_INFO){
258
 
                        temp_hostgroup=find_hostgroup(hostgroup_name);
259
 
                        grab_hostgroup_macros(temp_hostgroup);
 
260
                else if(display_type == DISPLAY_HOSTGROUP_INFO) {
 
261
                        temp_hostgroup = find_hostgroup(hostgroup_name);
 
262
                        grab_hostgroup_macros_r(mac, temp_hostgroup);
260
263
                        }
261
264
 
262
265
                /* find the servicegroup */
263
 
                else if(display_type==DISPLAY_SERVICEGROUP_INFO){
264
 
                        temp_servicegroup=find_servicegroup(servicegroup_name);
265
 
                        grab_servicegroup_macros(temp_servicegroup);
 
266
                else if(display_type == DISPLAY_SERVICEGROUP_INFO) {
 
267
                        temp_servicegroup = find_servicegroup(servicegroup_name);
 
268
                        grab_servicegroup_macros_r(mac, temp_servicegroup);
266
269
                        }
267
270
 
268
 
                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)){
 
271
                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)) {
269
272
                        printf("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 CLASS='linkBox'>\n");
270
273
                        printf("<TR><TD CLASS='linkBox'>\n");
271
 
                        if(display_type==DISPLAY_SERVICE_INFO)
272
 
                                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));
273
 
                        if(display_type==DISPLAY_SERVICE_INFO || display_type==DISPLAY_HOST_INFO)
274
 
                                printf("<A HREF='%s?host=%s'>View Status Detail For This Host</A><BR>\n",STATUS_CGI,url_encode(host_name));
275
 
                        if(display_type==DISPLAY_HOST_INFO){
276
 
                                printf("<A HREF='%s?host=%s'>View Alert History For This Host</A><BR>\n",HISTORY_CGI,url_encode(host_name));
277
 
#ifdef USE_TRENDS
278
 
                                printf("<A HREF='%s?host=%s'>View Trends For This Host</A><BR>\n",TRENDS_CGI,url_encode(host_name));
279
 
#endif
280
 
#ifdef USE_HISTOGRAM
281
 
                                printf("<A HREF='%s?host=%s'>View Alert Histogram For This Host</A><BR>\n",HISTOGRAM_CGI,url_encode(host_name));
282
 
#endif
283
 
                                printf("<A HREF='%s?host=%s&show_log_entries'>View Availability Report For This Host</A><BR>\n",AVAIL_CGI,url_encode(host_name));
284
 
                                printf("<A HREF='%s?host=%s'>View Notifications For This Host</A>\n",NOTIFICATIONS_CGI,url_encode(host_name));
285
 
                                }
286
 
                        else if(display_type==DISPLAY_SERVICE_INFO){
287
 
                                printf("<A HREF='%s?host=%s&",HISTORY_CGI,url_encode(host_name));
288
 
                                printf("service=%s'>View Alert History For This Service</A><BR>\n",url_encode(service_desc));
289
 
#ifdef USE_TRENDS
290
 
                                printf("<A HREF='%s?host=%s&",TRENDS_CGI,url_encode(host_name));
291
 
                                printf("service=%s'>View Trends For This Service</A><BR>\n",url_encode(service_desc));
292
 
#endif
293
 
#ifdef USE_HISTOGRAM
294
 
                                printf("<A HREF='%s?host=%s&",HISTOGRAM_CGI,url_encode(host_name));
295
 
                                printf("service=%s'>View Alert Histogram For This Service</A><BR>\n",url_encode(service_desc));
296
 
#endif
297
 
                                printf("<A HREF='%s?host=%s&",AVAIL_CGI,url_encode(host_name));
298
 
                                printf("service=%s&show_log_entries'>View Availability Report For This Service</A><BR>\n",url_encode(service_desc));
299
 
                                printf("<A HREF='%s?host=%s&",NOTIFICATIONS_CGI,url_encode(host_name));
300
 
                                printf("service=%s'>View Notifications For This Service</A>\n",url_encode(service_desc));
301
 
                                }
302
 
                        else if(display_type==DISPLAY_HOSTGROUP_INFO){
303
 
                                printf("<A HREF='%s?hostgroup=%s&style=detail'>View Status Detail For This Hostgroup</A><BR>\n",STATUS_CGI,url_encode(hostgroup_name));
304
 
                                printf("<A HREF='%s?hostgroup=%s&style=overview'>View Status Overview For This Hostgroup</A><BR>\n",STATUS_CGI,url_encode(hostgroup_name));
305
 
                                printf("<A HREF='%s?hostgroup=%s&style=grid'>View Status Grid For This Hostgroup</A><BR>\n",STATUS_CGI,url_encode(hostgroup_name));
306
 
                                printf("<A HREF='%s?hostgroup=%s'>View Availability For This Hostgroup</A><BR>\n",AVAIL_CGI,url_encode(hostgroup_name));
307
 
                                }
308
 
                        else if(display_type==DISPLAY_SERVICEGROUP_INFO){
309
 
                                printf("<A HREF='%s?servicegroup=%s&style=detail'>View Status Detail For This Servicegroup</A><BR>\n",STATUS_CGI,url_encode(servicegroup_name));
310
 
                                printf("<A HREF='%s?servicegroup=%s&style=overview'>View Status Overview For This Servicegroup</A><BR>\n",STATUS_CGI,url_encode(servicegroup_name));
311
 
                                printf("<A HREF='%s?servicegroup=%s&style=grid'>View Status Grid For This Servicegroup</A><BR>\n",STATUS_CGI,url_encode(servicegroup_name));
312
 
                                printf("<A HREF='%s?servicegroup=%s'>View Availability For This Servicegroup</A><BR>\n",AVAIL_CGI,url_encode(servicegroup_name));
313
 
                                }
 
274
                        if(display_type == DISPLAY_SERVICE_INFO)
 
275
                                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));
 
276
                        if(display_type == DISPLAY_SERVICE_INFO || display_type == DISPLAY_HOST_INFO)
 
277
                                printf("<A HREF='%s?host=%s'>View Status Detail For This Host</A><BR>\n", STATUS_CGI, url_encode(host_name));
 
278
                        if(display_type == DISPLAY_HOST_INFO) {
 
279
                                printf("<A HREF='%s?host=%s'>View Alert History For This Host</A><BR>\n", HISTORY_CGI, url_encode(host_name));
 
280
#ifdef USE_TRENDS
 
281
                                printf("<A HREF='%s?host=%s'>View Trends For This Host</A><BR>\n", TRENDS_CGI, url_encode(host_name));
 
282
#endif
 
283
#ifdef USE_HISTOGRAM
 
284
                                printf("<A HREF='%s?host=%s'>View Alert Histogram For This Host</A><BR>\n", HISTOGRAM_CGI, url_encode(host_name));
 
285
#endif
 
286
                                printf("<A HREF='%s?host=%s&show_log_entries'>View Availability Report For This Host</A><BR>\n", AVAIL_CGI, url_encode(host_name));
 
287
                                printf("<A HREF='%s?host=%s'>View Notifications For This Host</A>\n", NOTIFICATIONS_CGI, url_encode(host_name));
 
288
                                }
 
289
                        else if(display_type == DISPLAY_SERVICE_INFO) {
 
290
                                printf("<A HREF='%s?host=%s&", HISTORY_CGI, url_encode(host_name));
 
291
                                printf("service=%s'>View Alert History For This Service</A><BR>\n", url_encode(service_desc));
 
292
#ifdef USE_TRENDS
 
293
                                printf("<A HREF='%s?host=%s&", TRENDS_CGI, url_encode(host_name));
 
294
                                printf("service=%s'>View Trends For This Service</A><BR>\n", url_encode(service_desc));
 
295
#endif
 
296
#ifdef USE_HISTOGRAM
 
297
                                printf("<A HREF='%s?host=%s&", HISTOGRAM_CGI, url_encode(host_name));
 
298
                                printf("service=%s'>View Alert Histogram For This Service</A><BR>\n", url_encode(service_desc));
 
299
#endif
 
300
                                printf("<A HREF='%s?host=%s&", AVAIL_CGI, url_encode(host_name));
 
301
                                printf("service=%s&show_log_entries'>View Availability Report For This Service</A><BR>\n", url_encode(service_desc));
 
302
                                printf("<A HREF='%s?host=%s&", NOTIFICATIONS_CGI, url_encode(host_name));
 
303
                                printf("service=%s'>View Notifications For This Service</A>\n", url_encode(service_desc));
 
304
                                }
 
305
                        else if(display_type == DISPLAY_HOSTGROUP_INFO) {
 
306
                                printf("<A HREF='%s?hostgroup=%s&style=detail'>View Status Detail For This Hostgroup</A><BR>\n", STATUS_CGI, url_encode(hostgroup_name));
 
307
                                printf("<A HREF='%s?hostgroup=%s&style=overview'>View Status Overview For This Hostgroup</A><BR>\n", STATUS_CGI, url_encode(hostgroup_name));
 
308
                                printf("<A HREF='%s?hostgroup=%s&style=grid'>View Status Grid For This Hostgroup</A><BR>\n", STATUS_CGI, url_encode(hostgroup_name));
 
309
                                printf("<A HREF='%s?hostgroup=%s'>View Availability For This Hostgroup</A><BR>\n", AVAIL_CGI, url_encode(hostgroup_name));
 
310
                                }
 
311
                        else if(display_type == DISPLAY_SERVICEGROUP_INFO) {
 
312
                                printf("<A HREF='%s?servicegroup=%s&style=detail'>View Status Detail For This Servicegroup</A><BR>\n", STATUS_CGI, url_encode(servicegroup_name));
 
313
                                printf("<A HREF='%s?servicegroup=%s&style=overview'>View Status Overview For This Servicegroup</A><BR>\n", STATUS_CGI, url_encode(servicegroup_name));
 
314
                                printf("<A HREF='%s?servicegroup=%s&style=grid'>View Status Grid For This Servicegroup</A><BR>\n", STATUS_CGI, url_encode(servicegroup_name));
 
315
                                printf("<A HREF='%s?servicegroup=%s'>View Availability For This Servicegroup</A><BR>\n", AVAIL_CGI, url_encode(servicegroup_name));
 
316
                                }
314
317
                        printf("</TD></TR>\n");
315
318
                        printf("</TABLE>\n");
316
 
                        }
 
319
                        }
317
320
 
318
321
                printf("</td>\n");
319
322
 
320
323
                /* middle column of top row */
321
324
                printf("<td align=center valign=middle width=33%%>\n");
322
325
 
323
 
                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)){
 
326
                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)) {
324
327
 
325
 
                        if(display_type==DISPLAY_HOST_INFO){
 
328
                        if(display_type == DISPLAY_HOST_INFO) {
326
329
                                printf("<DIV CLASS='data'>Host</DIV>\n");
327
 
                                printf("<DIV CLASS='dataTitle'>%s</DIV>\n",temp_host->alias);
328
 
                                printf("<DIV CLASS='dataTitle'>(%s)</DIV><BR>\n",temp_host->name);
 
330
                                printf("<DIV CLASS='dataTitle'>%s</DIV>\n", temp_host->alias);
 
331
                                printf("<DIV CLASS='dataTitle'>(%s)</DIV><BR>\n", temp_host->name);
329
332
 
330
 
                                if (temp_host->parent_hosts != NULL) {
 
333
                                if(temp_host->parent_hosts != NULL) {
331
334
                                        /* print all parent hosts */
332
335
                                        printf("<DIV CLASS='data'>Parents:</DIV>\n");
333
 
                                        for(temp_parenthost=temp_host->parent_hosts;temp_parenthost!=NULL;temp_parenthost=temp_parenthost->next)
334
 
                                                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);
 
336
                                        for(temp_parenthost = temp_host->parent_hosts; temp_parenthost != NULL; temp_parenthost = temp_parenthost->next)
 
337
                                                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);
335
338
                                        printf("<BR>");
336
 
                                }
 
339
                                        }
337
340
 
338
341
                                printf("<DIV CLASS='data'>Member of</DIV><DIV CLASS='dataTitle'>");
339
 
                                for(temp_hostgroup=hostgroup_list;temp_hostgroup!=NULL;temp_hostgroup=temp_hostgroup->next){
340
 
                                        if(is_host_member_of_hostgroup(temp_hostgroup,temp_host)==TRUE){
341
 
                                                if(found==TRUE)
342
 
                                                        printf(", ");   
343
 
                                                printf("<A HREF='%s?hostgroup=%s&style=overview'>%s</A>",STATUS_CGI,url_encode(temp_hostgroup->group_name),temp_hostgroup->group_name);
344
 
                                                found=TRUE;
 
342
                                for(temp_hostgroup = hostgroup_list; temp_hostgroup != NULL; temp_hostgroup = temp_hostgroup->next) {
 
343
                                        if(is_host_member_of_hostgroup(temp_hostgroup, temp_host) == TRUE) {
 
344
                                                if(found == TRUE)
 
345
                                                        printf(", ");
 
346
                                                printf("<A HREF='%s?hostgroup=%s&style=overview'>%s</A>", STATUS_CGI, url_encode(temp_hostgroup->group_name), temp_hostgroup->group_name);
 
347
                                                found = TRUE;
345
348
                                                }
346
349
                                        }
347
 
                        
348
 
                                if(found==FALSE)
 
350
 
 
351
                                if(found == FALSE)
349
352
                                        printf("No hostgroups");
350
353
                                printf("</DIV><BR>\n");
351
 
                                printf("<DIV CLASS='data'>%s</DIV>\n",temp_host->address);
352
 
                                }
353
 
                        if(display_type==DISPLAY_SERVICE_INFO){
354
 
                                printf("<DIV CLASS='data'>Service</DIV><DIV CLASS='dataTitle'>%s</DIV><DIV CLASS='data'>On Host</DIV>\n",service_desc);
355
 
                                printf("<DIV CLASS='dataTitle'>%s</DIV>\n",temp_host->alias);
356
 
                                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->name);
357
 
                                printf("<DIV CLASS='data'>Member of</DIV><DIV CLASS='dataTitle'>");
358
 
                                for(temp_servicegroup=servicegroup_list;temp_servicegroup!=NULL;temp_servicegroup=temp_servicegroup->next){
359
 
                                        if(is_service_member_of_servicegroup(temp_servicegroup,temp_service)==TRUE){
360
 
                                                if(found==TRUE)
 
354
                                printf("<DIV CLASS='data'>%s</DIV>\n", temp_host->address);
 
355
                                }
 
356
                        if(display_type == DISPLAY_SERVICE_INFO) {
 
357
                                printf("<DIV CLASS='data'>Service</DIV><DIV CLASS='dataTitle'>%s</DIV><DIV CLASS='data'>On Host</DIV>\n", service_desc);
 
358
                                printf("<DIV CLASS='dataTitle'>%s</DIV>\n", temp_host->alias);
 
359
                                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->name);
 
360
                                printf("<DIV CLASS='data'>Member of</DIV><DIV CLASS='dataTitle'>");
 
361
                                for(temp_servicegroup = servicegroup_list; temp_servicegroup != NULL; temp_servicegroup = temp_servicegroup->next) {
 
362
                                        if(is_service_member_of_servicegroup(temp_servicegroup, temp_service) == TRUE) {
 
363
                                                if(found == TRUE)
361
364
                                                        printf(", ");
362
 
                                                printf("<A HREF='%s?servicegroup=%s&style=overview'>%s</A>",STATUS_CGI,url_encode(temp_servicegroup->group_name),temp_servicegroup->group_name);
363
 
                                                found=TRUE;
364
 
                                                }
365
 
                                        }
 
365
                                                printf("<A HREF='%s?servicegroup=%s&style=overview'>%s</A>", STATUS_CGI, url_encode(temp_servicegroup->group_name), temp_servicegroup->group_name);
 
366
                                                found = TRUE;
 
367
                                                }
 
368
                                        }
366
369
 
367
 
                                if(found==FALSE)
 
370
                                if(found == FALSE)
368
371
                                        printf("No servicegroups.");
369
 
                                printf("</DIV><BR>\n");
 
372
                                printf("</DIV><BR>\n");
370
373
 
371
 
                                printf("<DIV CLASS='data'>%s</DIV>\n",temp_host->address);
 
374
                                printf("<DIV CLASS='data'>%s</DIV>\n", temp_host->address);
372
375
                                }
373
 
                        if(display_type==DISPLAY_HOSTGROUP_INFO){
 
376
                        if(display_type == DISPLAY_HOSTGROUP_INFO) {
374
377
                                printf("<DIV CLASS='data'>Hostgroup</DIV>\n");
375
 
                                printf("<DIV CLASS='dataTitle'>%s</DIV>\n",temp_hostgroup->alias);
376
 
                                printf("<DIV CLASS='dataTitle'>(%s)</DIV>\n",temp_hostgroup->group_name);
377
 
                                if(temp_hostgroup->notes!=NULL){
378
 
                                        process_macros(temp_hostgroup->notes,&processed_string,0);
379
 
                                        printf("<p>%s</p>",processed_string);
 
378
                                printf("<DIV CLASS='dataTitle'>%s</DIV>\n", temp_hostgroup->alias);
 
379
                                printf("<DIV CLASS='dataTitle'>(%s)</DIV>\n", temp_hostgroup->group_name);
 
380
                                if(temp_hostgroup->notes != NULL) {
 
381
                                        process_macros_r(mac, temp_hostgroup->notes, &processed_string, 0);
 
382
                                        printf("<p>%s</p>", processed_string);
380
383
                                        free(processed_string);
381
384
                                        }
382
 
                                }
383
 
                        if(display_type==DISPLAY_SERVICEGROUP_INFO){
 
385
                                }
 
386
                        if(display_type == DISPLAY_SERVICEGROUP_INFO) {
384
387
                                printf("<DIV CLASS='data'>Servicegroup</DIV>\n");
385
 
                                printf("<DIV CLASS='dataTitle'>%s</DIV>\n",temp_servicegroup->alias);
386
 
                                printf("<DIV CLASS='dataTitle'>(%s)</DIV>\n",temp_servicegroup->group_name);
387
 
                                if(temp_servicegroup->notes!=NULL){
388
 
                                        process_macros(temp_servicegroup->notes,&processed_string,0);
389
 
                                        printf("<p>%s</p>",processed_string);
390
 
                                        free(processed_string);
391
 
                                        }
392
 
                                }
393
 
 
394
 
                        if(display_type==DISPLAY_SERVICE_INFO){
395
 
                                if(temp_service->icon_image!=NULL){
396
 
                                        printf("<img src='%s",url_logo_images_path);
397
 
                                        process_macros(temp_service->icon_image,&processed_string,0);
398
 
                                        printf("%s",processed_string);
399
 
                                        free(processed_string);
400
 
                                        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);
401
 
                                        }
402
 
                                if(temp_service->icon_image_alt!=NULL)
403
 
                                        printf("<font size=-1><i>( %s )</i></font>\n",temp_service->icon_image_alt);
404
 
                                if(temp_service->notes!=NULL){
405
 
                                        process_macros(temp_service->notes,&processed_string,0);
406
 
                                        printf("<p>%s</p>\n",processed_string);
407
 
                                        free(processed_string);
408
 
                                        }
409
 
                                }
410
 
 
411
 
                        if(display_type==DISPLAY_HOST_INFO){
412
 
                                if(temp_host->icon_image!=NULL){
413
 
                                        printf("<img src='%s",url_logo_images_path);
414
 
                                        process_macros(temp_host->icon_image,&processed_string,0);
415
 
                                        printf("%s",processed_string);
416
 
                                        free(processed_string);
417
 
                                        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);
418
 
                                        }
419
 
                                if(temp_host->icon_image_alt!=NULL)
420
 
                                        printf("<font size=-1><i>( %s )</i><font>\n",temp_host->icon_image_alt);
421
 
                                if(temp_host->notes!=NULL){
422
 
                                        process_macros(temp_host->notes,&processed_string,0);
423
 
                                        printf("<p>%s</p>\n",processed_string);
424
 
                                        free(processed_string);
425
 
                                        }
426
 
                                }
427
 
                        }
 
388
                                printf("<DIV CLASS='dataTitle'>%s</DIV>\n", temp_servicegroup->alias);
 
389
                                printf("<DIV CLASS='dataTitle'>(%s)</DIV>\n", temp_servicegroup->group_name);
 
390
                                if(temp_servicegroup->notes != NULL) {
 
391
                                        process_macros_r(mac, temp_servicegroup->notes, &processed_string, 0);
 
392
                                        printf("<p>%s</p>", processed_string);
 
393
                                        free(processed_string);
 
394
                                        }
 
395
                                }
 
396
 
 
397
                        if(display_type == DISPLAY_SERVICE_INFO) {
 
398
                                if(temp_service->icon_image != NULL) {
 
399
                                        printf("<img src='%s", url_logo_images_path);
 
400
                                        process_macros_r(mac, temp_service->icon_image, &processed_string, 0);
 
401
                                        printf("%s", processed_string);
 
402
                                        free(processed_string);
 
403
                                        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);
 
404
                                        }
 
405
                                if(temp_service->icon_image_alt != NULL)
 
406
                                        printf("<font size=-1><i>( %s )</i></font>\n", temp_service->icon_image_alt);
 
407
                                if(temp_service->notes != NULL) {
 
408
                                        process_macros_r(mac, temp_service->notes, &processed_string, 0);
 
409
                                        printf("<p>%s</p>\n", processed_string);
 
410
                                        free(processed_string);
 
411
                                        }
 
412
                                }
 
413
 
 
414
                        if(display_type == DISPLAY_HOST_INFO) {
 
415
                                if(temp_host->icon_image != NULL) {
 
416
                                        printf("<img src='%s", url_logo_images_path);
 
417
                                        process_macros_r(mac, temp_host->icon_image, &processed_string, 0);
 
418
                                        printf("%s", processed_string);
 
419
                                        free(processed_string);
 
420
                                        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);
 
421
                                        }
 
422
                                if(temp_host->icon_image_alt != NULL)
 
423
                                        printf("<font size=-1><i>( %s )</i><font>\n", temp_host->icon_image_alt);
 
424
                                if(temp_host->notes != NULL) {
 
425
                                        process_macros_r(mac, temp_host->notes, &processed_string, 0);
 
426
                                        printf("<p>%s</p>\n", processed_string);
 
427
                                        free(processed_string);
 
428
                                        }
 
429
                                }
 
430
                        }
428
431
 
429
432
                printf("</td>\n");
430
433
 
431
434
                /* right column of top row */
432
435
                printf("<td align=right valign=bottom width=33%%>\n");
433
436
 
434
 
                if(display_type==DISPLAY_HOST_INFO && temp_host!=NULL){
 
437
                if(display_type == DISPLAY_HOST_INFO && temp_host != NULL) {
435
438
                        printf("<TABLE BORDER='0'>\n");
436
 
                        if(temp_host->action_url!=NULL && strcmp(temp_host->action_url,"")){
 
439
                        if(temp_host->action_url != NULL && strcmp(temp_host->action_url, "")) {
437
440
                                printf("<TR><TD ALIGN='right'>\n");
438
441
                                printf("<A HREF='");
439
 
                                process_macros(temp_host->action_url,&processed_string,0);
440
 
                                printf("%s",processed_string);
 
442
                                process_macros_r(mac, temp_host->action_url, &processed_string, 0);
 
443
                                printf("%s", processed_string);
441
444
                                free(processed_string);
442
 
                                printf("' TARGET='%s'><img src='%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,ACTION_ICON);
 
445
                                printf("' TARGET='%s'><img src='%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, ACTION_ICON);
443
446
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
444
447
                                printf("</TD></TR>\n");
445
 
                                }
446
 
                        if(temp_host->notes_url!=NULL && strcmp(temp_host->notes_url,"")){
 
448
                                }
 
449
                        if(temp_host->notes_url != NULL && strcmp(temp_host->notes_url, "")) {
447
450
                                printf("<TR><TD ALIGN='right'>\n");
448
451
                                printf("<A HREF='");
449
 
                                process_macros(temp_host->notes_url,&processed_string,0);
450
 
                                printf("%s",processed_string);
 
452
                                process_macros_r(mac, temp_host->notes_url, &processed_string, 0);
 
453
                                printf("%s", processed_string);
451
454
                                free(processed_string);
452
455
                                /*print_extra_host_url(temp_host->name,temp_host->notes_url);*/
453
 
                                printf("' TARGET='%s'><img src='%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,NOTES_ICON);
 
456
                                printf("' TARGET='%s'><img src='%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, NOTES_ICON);
454
457
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
455
458
                                printf("</TD></TR>\n");
456
 
                                }
 
459
                                }
457
460
                        printf("</TABLE>\n");
458
 
                        }
 
461
                        }
459
462
 
460
 
                else if(display_type==DISPLAY_SERVICE_INFO && temp_service!=NULL){
 
463
                else if(display_type == DISPLAY_SERVICE_INFO && temp_service != NULL) {
461
464
                        printf("<TABLE BORDER='0'><TR><TD ALIGN='right'>\n");
462
 
                        if(temp_service->action_url!=NULL && strcmp(temp_service->action_url,"")){
 
465
                        if(temp_service->action_url != NULL && strcmp(temp_service->action_url, "")) {
463
466
                                printf("<A HREF='");
464
 
                                process_macros(temp_service->action_url,&processed_string,0);
465
 
                                printf("%s",processed_string);
 
467
                                process_macros_r(mac, temp_service->action_url, &processed_string, 0);
 
468
                                printf("%s", processed_string);
466
469
                                free(processed_string);
467
 
                                printf("' TARGET='%s'><img src='%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,ACTION_ICON);
 
470
                                printf("' TARGET='%s'><img src='%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, ACTION_ICON);
468
471
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
469
 
                                }
470
 
                        if(temp_service->notes_url!=NULL && strcmp(temp_service->notes_url,"")){
 
472
                                }
 
473
                        if(temp_service->notes_url != NULL && strcmp(temp_service->notes_url, "")) {
471
474
                                printf("<A HREF='");
472
 
                                process_macros(temp_service->notes_url,&processed_string,0);
473
 
                                printf("%s",processed_string);
 
475
                                process_macros_r(mac, temp_service->notes_url, &processed_string, 0);
 
476
                                printf("%s", processed_string);
474
477
                                free(processed_string);
475
 
                                printf("' TARGET='%s'><img src='%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,NOTES_ICON);
 
478
                                printf("' TARGET='%s'><img src='%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, NOTES_ICON);
476
479
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
477
 
                                }
 
480
                                }
478
481
                        printf("</TD></TR></TABLE>\n");
479
 
                        }
480
 
 
481
 
                if(display_type==DISPLAY_HOSTGROUP_INFO && temp_hostgroup!=NULL){
482
 
                        printf("<TABLE BORDER='0'>\n");
483
 
                        if(temp_hostgroup->action_url!=NULL && strcmp(temp_hostgroup->action_url,"")){
484
 
                                printf("<TR><TD ALIGN='right'>\n");
485
 
                                printf("<A HREF='");
486
 
                                print_extra_hostgroup_url(temp_hostgroup->group_name,temp_hostgroup->action_url);
487
 
                                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);
488
 
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
489
 
                                printf("</TD></TR>\n");
490
 
                                }
491
 
                        if(temp_hostgroup->notes_url!=NULL && strcmp(temp_hostgroup->notes_url,"")){
492
 
                                printf("<TR><TD ALIGN='right'>\n");
493
 
                                printf("<A HREF='");
494
 
                                print_extra_hostgroup_url(temp_hostgroup->group_name,temp_hostgroup->notes_url);
495
 
                                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);
496
 
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
497
 
                                printf("</TD></TR>\n");
498
 
                                }
499
 
                        printf("</TABLE>\n");
500
 
                        }
501
 
 
502
 
                else if(display_type==DISPLAY_SERVICEGROUP_INFO && temp_servicegroup!=NULL){
503
 
                        printf("<TABLE BORDER='0'>\n");
504
 
                        if(temp_servicegroup->action_url!=NULL && strcmp(temp_servicegroup->action_url,"")){
505
 
                                printf("<A HREF='");
506
 
                                print_extra_servicegroup_url(temp_servicegroup->group_name,temp_servicegroup->action_url);
507
 
                                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);
508
 
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
509
 
                                }
510
 
                        if(temp_servicegroup->notes_url!=NULL && strcmp(temp_servicegroup->notes_url,"")){
511
 
                                printf("<A HREF='");
512
 
                                print_extra_servicegroup_url(temp_servicegroup->group_name,temp_servicegroup->notes_url);
513
 
                                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);
514
 
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
515
 
                                }
516
 
                        printf("</TABLE>\n");
517
 
                        }
 
482
                        }
 
483
 
 
484
                if(display_type == DISPLAY_HOSTGROUP_INFO && temp_hostgroup != NULL) {
 
485
                        printf("<TABLE BORDER='0'>\n");
 
486
                        if(temp_hostgroup->action_url != NULL && strcmp(temp_hostgroup->action_url, "")) {
 
487
                                printf("<TR><TD ALIGN='right'>\n");
 
488
                                printf("<A HREF='");
 
489
                                print_extra_hostgroup_url(temp_hostgroup->group_name, temp_hostgroup->action_url);
 
490
                                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);
 
491
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
 
492
                                printf("</TD></TR>\n");
 
493
                                }
 
494
                        if(temp_hostgroup->notes_url != NULL && strcmp(temp_hostgroup->notes_url, "")) {
 
495
                                printf("<TR><TD ALIGN='right'>\n");
 
496
                                printf("<A HREF='");
 
497
                                print_extra_hostgroup_url(temp_hostgroup->group_name, temp_hostgroup->notes_url);
 
498
                                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);
 
499
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
 
500
                                printf("</TD></TR>\n");
 
501
                                }
 
502
                        printf("</TABLE>\n");
 
503
                        }
 
504
 
 
505
                else if(display_type == DISPLAY_SERVICEGROUP_INFO && temp_servicegroup != NULL) {
 
506
                        printf("<TABLE BORDER='0'>\n");
 
507
                        if(temp_servicegroup->action_url != NULL && strcmp(temp_servicegroup->action_url, "")) {
 
508
                                printf("<A HREF='");
 
509
                                print_extra_servicegroup_url(temp_servicegroup->group_name, temp_servicegroup->action_url);
 
510
                                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);
 
511
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Actions</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
 
512
                                }
 
513
                        if(temp_servicegroup->notes_url != NULL && strcmp(temp_servicegroup->notes_url, "")) {
 
514
                                printf("<A HREF='");
 
515
                                print_extra_servicegroup_url(temp_servicegroup->group_name, temp_servicegroup->notes_url);
 
516
                                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);
 
517
                                printf("<BR CLEAR=ALL><FONT SIZE=-1><I>Extra Notes</I></FONT><BR CLEAR=ALL><BR CLEAR=ALL>\n");
 
518
                                }
 
519
                        printf("</TABLE>\n");
 
520
                        }
518
521
 
519
522
                /* display context-sensitive help */
520
 
                if(display_type==DISPLAY_HOST_INFO)
 
523
                if(display_type == DISPLAY_HOST_INFO)
521
524
                        display_context_help(CONTEXTHELP_EXT_HOST);
522
 
                else if(display_type==DISPLAY_SERVICE_INFO)
 
525
                else if(display_type == DISPLAY_SERVICE_INFO)
523
526
                        display_context_help(CONTEXTHELP_EXT_SERVICE);
524
 
                else if(display_type==DISPLAY_HOSTGROUP_INFO)
 
527
                else if(display_type == DISPLAY_HOSTGROUP_INFO)
525
528
                        display_context_help(CONTEXTHELP_EXT_HOSTGROUP);
526
 
                else if(display_type==DISPLAY_SERVICEGROUP_INFO)
 
529
                else if(display_type == DISPLAY_SERVICEGROUP_INFO)
527
530
                        display_context_help(CONTEXTHELP_EXT_SERVICEGROUP);
528
 
                else if(display_type==DISPLAY_PROCESS_INFO)
 
531
                else if(display_type == DISPLAY_PROCESS_INFO)
529
532
                        display_context_help(CONTEXTHELP_EXT_PROCESS);
530
 
                else if(display_type==DISPLAY_PERFORMANCE)
 
533
                else if(display_type == DISPLAY_PERFORMANCE)
531
534
                        display_context_help(CONTEXTHELP_EXT_PERFORMANCE);
532
 
                else if(display_type==DISPLAY_COMMENTS)
 
535
                else if(display_type == DISPLAY_COMMENTS)
533
536
                        display_context_help(CONTEXTHELP_EXT_COMMENTS);
534
 
                else if(display_type==DISPLAY_DOWNTIME)
 
537
                else if(display_type == DISPLAY_DOWNTIME)
535
538
                        display_context_help(CONTEXTHELP_EXT_DOWNTIME);
536
 
                else if(display_type==DISPLAY_SCHEDULING_QUEUE)
 
539
                else if(display_type == DISPLAY_SCHEDULING_QUEUE)
537
540
                        display_context_help(CONTEXTHELP_EXT_QUEUE);
538
541
 
539
542
                printf("</td>\n");
542
545
                printf("</tr>\n");
543
546
                printf("</table>\n");
544
547
 
545
 
                }
 
548
                }
546
549
 
547
550
        printf("<BR>\n");
548
551
 
549
 
        if(display_type==DISPLAY_HOST_INFO)
 
552
        if(display_type == DISPLAY_HOST_INFO)
550
553
                show_host_info();
551
 
        else if(display_type==DISPLAY_SERVICE_INFO)
 
554
        else if(display_type == DISPLAY_SERVICE_INFO)
552
555
                show_service_info();
553
 
        else if(display_type==DISPLAY_COMMENTS)
 
556
        else if(display_type == DISPLAY_COMMENTS)
554
557
                show_all_comments();
555
 
        else if(display_type==DISPLAY_PERFORMANCE)
 
558
        else if(display_type == DISPLAY_PERFORMANCE)
556
559
                show_performance_data();
557
 
        else if(display_type==DISPLAY_HOSTGROUP_INFO)
 
560
        else if(display_type == DISPLAY_HOSTGROUP_INFO)
558
561
                show_hostgroup_info();
559
 
        else if(display_type==DISPLAY_SERVICEGROUP_INFO)
 
562
        else if(display_type == DISPLAY_SERVICEGROUP_INFO)
560
563
                show_servicegroup_info();
561
 
        else if(display_type==DISPLAY_DOWNTIME)
 
564
        else if(display_type == DISPLAY_DOWNTIME)
562
565
                show_all_downtime();
563
 
        else if(display_type==DISPLAY_SCHEDULING_QUEUE)
 
566
        else if(display_type == DISPLAY_SCHEDULING_QUEUE)
564
567
                show_scheduling_queue();
565
568
        else
566
569
                show_process_info();
573
576
        free_downtime_data();
574
577
 
575
578
        return OK;
576
 
        }
577
 
 
578
 
 
579
 
 
580
 
void document_header(int use_stylesheet){
 
579
        }
 
580
 
 
581
 
 
582
 
 
583
void document_header(int use_stylesheet) {
581
584
        char date_time[MAX_DATETIME_LENGTH];
582
585
        time_t current_time;
583
586
        time_t expire_time;
584
587
 
585
588
        printf("Cache-Control: no-store\r\n");
586
589
        printf("Pragma: no-cache\r\n");
587
 
        printf("Refresh: %d\r\n",refresh_rate);
 
590
        printf("Refresh: %d\r\n", refresh_rate);
588
591
 
589
592
        time(&current_time);
590
 
        get_time_string(&current_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME);
591
 
        printf("Last-Modified: %s\r\n",date_time);
 
593
        get_time_string(&current_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
 
594
        printf("Last-Modified: %s\r\n", date_time);
592
595
 
593
 
        expire_time=(time_t)0L;
594
 
        get_time_string(&expire_time,date_time,(int)sizeof(date_time),HTTP_DATE_TIME);
595
 
        printf("Expires: %s\r\n",date_time);
 
596
        expire_time = (time_t)0L;
 
597
        get_time_string(&expire_time, date_time, (int)sizeof(date_time), HTTP_DATE_TIME);
 
598
        printf("Expires: %s\r\n", date_time);
596
599
 
597
600
        printf("Content-type: text/html\r\n\r\n");
598
601
 
599
 
        if(embedded==TRUE)
 
602
        if(embedded == TRUE)
600
603
                return;
601
604
 
602
605
        printf("<html>\n");
603
606
        printf("<head>\n");
604
 
        printf("<link rel=\"shortcut icon\" href=\"%sfavicon.ico\" type=\"image/ico\">\n",url_images_path);
 
607
        printf("<link rel=\"shortcut icon\" href=\"%sfavicon.ico\" type=\"image/ico\">\n", url_images_path);
605
608
        printf("<title>\n");
606
609
        printf("Extended Information\n");
607
610
        printf("</title>\n");
608
611
 
609
 
        if(use_stylesheet==TRUE){
610
 
                printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>",url_stylesheets_path,COMMON_CSS);
611
 
                printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>",url_stylesheets_path,EXTINFO_CSS);
612
 
                }
 
612
        if(use_stylesheet == TRUE) {
 
613
                printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>", url_stylesheets_path, COMMON_CSS);
 
614
                printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>", url_stylesheets_path, EXTINFO_CSS);
 
615
                }
613
616
        printf("</head>\n");
614
617
 
615
618
        printf("<body CLASS='extinfo'>\n");
616
619
 
617
620
        /* include user SSI header */
618
 
        include_ssi_files(EXTINFO_CGI,SSI_HEADER);
 
621
        include_ssi_files(EXTINFO_CGI, SSI_HEADER);
619
622
 
620
623
        return;
621
 
        }
622
 
 
623
 
 
624
 
void document_footer(void){
625
 
 
626
 
        if(embedded==TRUE)
 
624
        }
 
625
 
 
626
 
 
627
void document_footer(void) {
 
628
 
 
629
        if(embedded == TRUE)
627
630
                return;
628
631
 
629
632
        /* include user SSI footer */
630
 
        include_ssi_files(EXTINFO_CGI,SSI_FOOTER);
 
633
        include_ssi_files(EXTINFO_CGI, SSI_FOOTER);
631
634
 
632
635
        printf("</body>\n");
633
636
        printf("</html>\n");
634
637
 
635
638
        return;
636
 
        }
637
 
 
638
 
 
639
 
int process_cgivars(void){
 
639
        }
 
640
 
 
641
 
 
642
int process_cgivars(void) {
640
643
        char **variables;
641
 
        int error=FALSE;
 
644
        int error = FALSE;
642
645
        int temp_type;
643
646
        int x;
644
647
 
645
 
        variables=getcgivars();
 
648
        variables = getcgivars();
646
649
 
647
 
        for(x=0;variables[x]!=NULL;x++){
 
650
        for(x = 0; variables[x] != NULL; x++) {
648
651
 
649
652
                /* do some basic length checking on the variable identifier to prevent buffer overflows */
650
 
                if(strlen(variables[x])>=MAX_INPUT_BUFFER-1){
 
653
                if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
651
654
                        x++;
652
655
                        continue;
653
 
                        }
 
656
                        }
654
657
 
655
658
                /* we found the display type */
656
 
                else if(!strcmp(variables[x],"type")){
 
659
                else if(!strcmp(variables[x], "type")) {
657
660
                        x++;
658
 
                        if(variables[x]==NULL){
659
 
                                error=TRUE;
 
661
                        if(variables[x] == NULL) {
 
662
                                error = TRUE;
660
663
                                break;
661
664
                                }
662
 
                        temp_type=atoi(variables[x]);
663
 
                        if(temp_type==DISPLAY_HOST_INFO)
664
 
                                display_type=DISPLAY_HOST_INFO;
665
 
                        else if(temp_type==DISPLAY_SERVICE_INFO)
666
 
                                display_type=DISPLAY_SERVICE_INFO;
667
 
                        else if(temp_type==DISPLAY_COMMENTS)
668
 
                                display_type=DISPLAY_COMMENTS;
669
 
                        else if(temp_type==DISPLAY_PERFORMANCE)
670
 
                                display_type=DISPLAY_PERFORMANCE;
671
 
                        else if(temp_type==DISPLAY_HOSTGROUP_INFO)
672
 
                                display_type=DISPLAY_HOSTGROUP_INFO;
673
 
                        else if(temp_type==DISPLAY_SERVICEGROUP_INFO)
674
 
                                display_type=DISPLAY_SERVICEGROUP_INFO;
675
 
                        else if(temp_type==DISPLAY_DOWNTIME)
676
 
                                display_type=DISPLAY_DOWNTIME;
677
 
                        else if(temp_type==DISPLAY_SCHEDULING_QUEUE)
678
 
                                display_type=DISPLAY_SCHEDULING_QUEUE;
 
665
                        temp_type = atoi(variables[x]);
 
666
                        if(temp_type == DISPLAY_HOST_INFO)
 
667
                                display_type = DISPLAY_HOST_INFO;
 
668
                        else if(temp_type == DISPLAY_SERVICE_INFO)
 
669
                                display_type = DISPLAY_SERVICE_INFO;
 
670
                        else if(temp_type == DISPLAY_COMMENTS)
 
671
                                display_type = DISPLAY_COMMENTS;
 
672
                        else if(temp_type == DISPLAY_PERFORMANCE)
 
673
                                display_type = DISPLAY_PERFORMANCE;
 
674
                        else if(temp_type == DISPLAY_HOSTGROUP_INFO)
 
675
                                display_type = DISPLAY_HOSTGROUP_INFO;
 
676
                        else if(temp_type == DISPLAY_SERVICEGROUP_INFO)
 
677
                                display_type = DISPLAY_SERVICEGROUP_INFO;
 
678
                        else if(temp_type == DISPLAY_DOWNTIME)
 
679
                                display_type = DISPLAY_DOWNTIME;
 
680
                        else if(temp_type == DISPLAY_SCHEDULING_QUEUE)
 
681
                                display_type = DISPLAY_SCHEDULING_QUEUE;
679
682
                        else
680
 
                                display_type=DISPLAY_PROCESS_INFO;
 
683
                                display_type = DISPLAY_PROCESS_INFO;
681
684
                        }
682
685
 
683
686
                /* we found the host name */
684
 
                else if(!strcmp(variables[x],"host")){
 
687
                else if(!strcmp(variables[x], "host")) {
685
688
                        x++;
686
 
                        if(variables[x]==NULL){
687
 
                                error=TRUE;
 
689
                        if(variables[x] == NULL) {
 
690
                                error = TRUE;
688
691
                                break;
689
 
                                }
 
692
                                }
690
693
 
691
 
                        host_name=strdup(variables[x]);
692
 
                        if(host_name==NULL)
693
 
                                host_name="";
 
694
                        host_name = strdup(variables[x]);
 
695
                        if(host_name == NULL)
 
696
                                host_name = "";
694
697
                        strip_html_brackets(host_name);
695
698
                        }
696
699
 
697
700
                /* we found the hostgroup name */
698
 
                else if(!strcmp(variables[x],"hostgroup")){
 
701
                else if(!strcmp(variables[x], "hostgroup")) {
699
702
                        x++;
700
 
                        if(variables[x]==NULL){
701
 
                                error=TRUE;
 
703
                        if(variables[x] == NULL) {
 
704
                                error = TRUE;
702
705
                                break;
703
 
                                }
 
706
                                }
704
707
 
705
 
                        hostgroup_name=strdup(variables[x]);
706
 
                        if(hostgroup_name==NULL)
707
 
                                hostgroup_name="";
 
708
                        hostgroup_name = strdup(variables[x]);
 
709
                        if(hostgroup_name == NULL)
 
710
                                hostgroup_name = "";
708
711
                        strip_html_brackets(hostgroup_name);
709
712
                        }
710
713
 
711
714
                /* we found the service name */
712
 
                else if(!strcmp(variables[x],"service")){
 
715
                else if(!strcmp(variables[x], "service")) {
713
716
                        x++;
714
 
                        if(variables[x]==NULL){
715
 
                                error=TRUE;
 
717
                        if(variables[x] == NULL) {
 
718
                                error = TRUE;
716
719
                                break;
717
 
                                }
 
720
                                }
718
721
 
719
 
                        service_desc=strdup(variables[x]);
720
 
                        if(service_desc==NULL)
721
 
                                service_desc="";
 
722
                        service_desc = strdup(variables[x]);
 
723
                        if(service_desc == NULL)
 
724
                                service_desc = "";
722
725
                        strip_html_brackets(service_desc);
723
726
                        }
724
727
 
725
728
                /* we found the servicegroup name */
726
 
                else if(!strcmp(variables[x],"servicegroup")){
 
729
                else if(!strcmp(variables[x], "servicegroup")) {
727
730
                        x++;
728
 
                        if(variables[x]==NULL){
729
 
                                error=TRUE;
 
731
                        if(variables[x] == NULL) {
 
732
                                error = TRUE;
730
733
                                break;
731
 
                                }
 
734
                                }
732
735
 
733
 
                        servicegroup_name=strdup(variables[x]);
734
 
                        if(servicegroup_name==NULL)
735
 
                                servicegroup_name="";
 
736
                        servicegroup_name = strdup(variables[x]);
 
737
                        if(servicegroup_name == NULL)
 
738
                                servicegroup_name = "";
736
739
                        strip_html_brackets(servicegroup_name);
737
740
                        }
738
741
 
739
742
                /* we found the sort type argument */
740
 
                else if(!strcmp(variables[x],"sorttype")){
 
743
                else if(!strcmp(variables[x], "sorttype")) {
741
744
                        x++;
742
 
                        if(variables[x]==NULL){
743
 
                                error=TRUE;
 
745
                        if(variables[x] == NULL) {
 
746
                                error = TRUE;
744
747
                                break;
745
 
                                }
 
748
                                }
746
749
 
747
 
                        sort_type=atoi(variables[x]);
748
 
                        }
 
750
                        sort_type = atoi(variables[x]);
 
751
                        }
749
752
 
750
753
                /* we found the sort option argument */
751
 
                else if(!strcmp(variables[x],"sortoption")){
 
754
                else if(!strcmp(variables[x], "sortoption")) {
752
755
                        x++;
753
 
                        if(variables[x]==NULL){
754
 
                                error=TRUE;
 
756
                        if(variables[x] == NULL) {
 
757
                                error = TRUE;
755
758
                                break;
756
 
                                }
 
759
                                }
757
760
 
758
 
                        sort_option=atoi(variables[x]);
759
 
                        }
 
761
                        sort_option = atoi(variables[x]);
 
762
                        }
760
763
 
761
764
                /* we found the embed option */
762
 
                else if(!strcmp(variables[x],"embedded"))
763
 
                        embedded=TRUE;
 
765
                else if(!strcmp(variables[x], "embedded"))
 
766
                        embedded = TRUE;
764
767
 
765
768
                /* we found the noheader option */
766
 
                else if(!strcmp(variables[x],"noheader"))
767
 
                        display_header=FALSE;
768
 
                }
 
769
                else if(!strcmp(variables[x], "noheader"))
 
770
                        display_header = FALSE;
 
771
                }
769
772
 
770
773
        /* free memory allocated to the CGI variables */
771
774
        free_cgivars(variables);
772
775
 
773
776
        return error;
774
 
        }
775
 
 
776
 
 
777
 
 
778
 
void show_process_info(void){
 
777
        }
 
778
 
 
779
 
 
780
 
 
781
void show_process_info(void) {
779
782
        char date_time[MAX_DATETIME_LENGTH];
780
783
        time_t current_time;
781
784
        unsigned long run_time;
782
785
        char run_time_string[24];
783
 
        int days=0;
784
 
        int hours=0;
785
 
        int minutes=0;
786
 
        int seconds=0;
 
786
        int days = 0;
 
787
        int hours = 0;
 
788
        int minutes = 0;
 
789
        int seconds = 0;
787
790
 
788
791
        /* make sure the user has rights to view system information */
789
 
        if(is_authorized_for_system_information(&current_authdata)==FALSE){
 
792
        if(is_authorized_for_system_information(&current_authdata) == FALSE) {
790
793
 
791
794
                printf("<P><DIV CLASS='errorMessage'>It appears as though you do not have permission to view process information...</DIV></P>\n");
792
795
                printf("<P><DIV CLASS='errorDescription'>If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI<br>");
793
796
                printf("and check the authorization options in your CGI configuration file.</DIV></P>\n");
794
797
 
795
798
                return;
796
 
                }
 
799
                }
797
800
 
798
801
        printf("<BR />\n");
799
802
        printf("<DIV ALIGN=CENTER>\n");
808
811
        printf("<TABLE BORDER=0>\n");
809
812
 
810
813
        /* program version */
811
 
        printf("<TR><TD CLASS='dataVar'>Program Version:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",PROGRAM_VERSION);
 
814
        printf("<TR><TD CLASS='dataVar'>Program Version:</TD><TD CLASS='dataVal'>%s</TD></TR>\n", PROGRAM_VERSION);
812
815
 
813
816
        /* program start time */
814
 
        get_time_string(&program_start,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
815
 
        printf("<TR><TD CLASS='dataVar'>Program Start Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",date_time);
 
817
        get_time_string(&program_start, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
818
        printf("<TR><TD CLASS='dataVar'>Program Start Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n", date_time);
816
819
 
817
820
        /* total running time */
818
821
        time(&current_time);
819
 
        run_time=(unsigned long)(current_time-program_start);
820
 
        get_time_breakdown(run_time,&days,&hours,&minutes,&seconds);
821
 
        sprintf(run_time_string,"%dd %dh %dm %ds",days,hours,minutes,seconds);
822
 
        printf("<TR><TD CLASS='dataVar'>Total Running Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",run_time_string);
 
822
        run_time = (unsigned long)(current_time - program_start);
 
823
        get_time_breakdown(run_time, &days, &hours, &minutes, &seconds);
 
824
        sprintf(run_time_string, "%dd %dh %dm %ds", days, hours, minutes, seconds);
 
825
        printf("<TR><TD CLASS='dataVar'>Total Running Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n", run_time_string);
823
826
 
824
827
        /* last external check */
825
 
        get_time_string(&last_command_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
826
 
        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":date_time);
 
828
        get_time_string(&last_command_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
829
        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" : date_time);
827
830
 
828
831
        /* last log file rotation */
829
 
        get_time_string(&last_log_rotation,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
830
 
        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":date_time);
 
832
        get_time_string(&last_log_rotation, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
833
        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" : date_time);
831
834
 
832
835
        /* PID */
833
 
        printf("<TR><TD CLASS='dataVar'>Nagios PID</TD><TD CLASS='dataval'>%d</TD></TR>\n",nagios_pid);
 
836
        printf("<TR><TD CLASS='dataVar'>Nagios PID</TD><TD CLASS='dataVal'>%d</TD></TR>\n", nagios_pid);
834
837
 
835
838
        /* notifications enabled */
836
 
        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");
 
839
        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");
837
840
 
838
841
        /* service check execution enabled */
839
 
        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");
 
842
        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");
840
843
 
841
844
        /* passive service check acceptance */
842
 
        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");
 
845
        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");
843
846
 
844
847
        /* host check execution enabled */
845
 
        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");
 
848
        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");
846
849
 
847
850
        /* passive host check acceptance */
848
 
        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");
 
851
        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");
849
852
 
850
853
        /* event handlers enabled */
851
 
        printf("<TR><TD CLASS='dataVar'>Event Handlers Enabled?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(enable_event_handlers==TRUE)?"Yes":"No");
 
854
        printf("<TR><TD CLASS='dataVar'>Event Handlers Enabled?</TD><TD CLASS='dataVal'>%s</TD></TR>\n", (enable_event_handlers == TRUE) ? "Yes" : "No");
852
855
 
853
856
        /* obsessing over services */
854
 
        printf("<TR><TD CLASS='dataVar'>Obsessing Over Services?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(obsess_over_services==TRUE)?"Yes":"No");
 
857
        printf("<TR><TD CLASS='dataVar'>Obsessing Over Services?</TD><TD CLASS='dataVal'>%s</TD></TR>\n", (obsess_over_services == TRUE) ? "Yes" : "No");
855
858
 
856
859
        /* obsessing over hosts */
857
 
        printf("<TR><TD CLASS='dataVar'>Obsessing Over Hosts?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(obsess_over_hosts==TRUE)?"Yes":"No");
 
860
        printf("<TR><TD CLASS='dataVar'>Obsessing Over Hosts?</TD><TD CLASS='dataVal'>%s</TD></TR>\n", (obsess_over_hosts == TRUE) ? "Yes" : "No");
858
861
 
859
862
        /* flap detection enabled */
860
 
        printf("<TR><TD CLASS='dataVar'>Flap Detection Enabled?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(enable_flap_detection==TRUE)?"Yes":"No");
 
863
        printf("<TR><TD CLASS='dataVar'>Flap Detection Enabled?</TD><TD CLASS='dataVal'>%s</TD></TR>\n", (enable_flap_detection == TRUE) ? "Yes" : "No");
861
864
 
862
865
#ifdef PREDICT_FAILURES
863
866
        /* failure prediction enabled */
864
 
        printf("<TR><TD CLASS='dataVar'>Failure Prediction Enabled?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(enable_failure_prediction==TRUE)?"Yes":"No");
 
867
        printf("<TR><TD CLASS='dataVar'>Failure Prediction Enabled?</TD><TD CLASS='dataVal'>%s</TD></TR>\n", (enable_failure_prediction == TRUE) ? "Yes" : "No");
865
868
#endif
866
869
 
867
870
        /* process performance data */
868
 
        printf("<TR><TD CLASS='dataVar'>Performance Data Being Processed?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(process_performance_data==TRUE)?"Yes":"No");
 
871
        printf("<TR><TD CLASS='dataVar'>Performance Data Being Processed?</TD><TD CLASS='dataVal'>%s</TD></TR>\n", (process_performance_data == TRUE) ? "Yes" : "No");
869
872
 
870
873
#ifdef USE_OLDCRUD
871
874
        /* daemon mode */
872
 
        printf("<TR><TD CLASS='dataVar'>Running As A Daemon?</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(daemon_mode==TRUE)?"Yes":"No");
 
875
        printf("<TR><TD CLASS='dataVar'>Running As A Daemon?</TD><TD CLASS='dataVal'>%s</TD></TR>\n", (daemon_mode == TRUE) ? "Yes" : "No");
873
876
#endif
874
877
 
875
878
        printf("</TABLE>\n");
884
887
        printf("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 CLASS='command'>\n");
885
888
        printf("<TR><TD>\n");
886
889
 
887
 
        if(nagios_process_state==STATE_OK){
 
890
        if(nagios_process_state == STATE_OK) {
888
891
                printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 CLASS='command'>\n");
889
892
 
890
893
#ifndef DUMMY_INSTALL
891
 
                printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Shutdown the Nagios Process' TITLE='Shutdown the Nagios Process'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Shutdown the Nagios process</a></td></tr>\n",url_images_path,STOP_ICON,COMMAND_CGI,CMD_SHUTDOWN_PROCESS);
892
 
                printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Restart the Nagios Process' TITLE='Restart the Nagios Process'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Restart the Nagios process</a></td></tr>\n",url_images_path,RESTART_ICON,COMMAND_CGI,CMD_RESTART_PROCESS);
 
894
                printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Shutdown the Nagios Process' TITLE='Shutdown the Nagios Process'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Shutdown the Nagios process</a></td></tr>\n", url_images_path, STOP_ICON, COMMAND_CGI, CMD_SHUTDOWN_PROCESS);
 
895
                printf("<TR CLASS='command'><TD><img src='%s%s' border=0 ALT='Restart the Nagios Process' TITLE='Restart the Nagios Process'></td><td CLASS='command'><a href='%s?cmd_typ=%d'>Restart the Nagios process</a></td></tr>\n", url_images_path, RESTART_ICON, COMMAND_CGI, CMD_RESTART_PROCESS);
893
896
#endif
894
897
 
895
 
                if(enable_notifications==TRUE)
896
 
                        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,COMMAND_CGI,CMD_DISABLE_NOTIFICATIONS);
897
 
                else
898
 
                        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,COMMAND_CGI,CMD_ENABLE_NOTIFICATIONS);
899
 
 
900
 
                if(execute_service_checks==TRUE)
901
 
                        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,COMMAND_CGI,CMD_STOP_EXECUTING_SVC_CHECKS);
902
 
                else
903
 
                        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,COMMAND_CGI,CMD_START_EXECUTING_SVC_CHECKS);
904
 
 
905
 
                if(accept_passive_service_checks==TRUE)
906
 
                        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,COMMAND_CGI,CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS);
907
 
                else
908
 
                        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,COMMAND_CGI,CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS);
909
 
 
910
 
                if(execute_host_checks==TRUE)
911
 
                        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,COMMAND_CGI,CMD_STOP_EXECUTING_HOST_CHECKS);
912
 
                else
913
 
                        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,COMMAND_CGI,CMD_START_EXECUTING_HOST_CHECKS);
914
 
 
915
 
                if(accept_passive_host_checks==TRUE)
916
 
                        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,COMMAND_CGI,CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS);
917
 
                else
918
 
                        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,COMMAND_CGI,CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS);
919
 
 
920
 
                if(enable_event_handlers==TRUE)
921
 
                        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,COMMAND_CGI,CMD_DISABLE_EVENT_HANDLERS);
922
 
                else
923
 
                        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,COMMAND_CGI,CMD_ENABLE_EVENT_HANDLERS);
924
 
 
925
 
                if(obsess_over_services==TRUE)
926
 
                        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,COMMAND_CGI,CMD_STOP_OBSESSING_OVER_SVC_CHECKS);
927
 
                else
928
 
                        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,COMMAND_CGI,CMD_START_OBSESSING_OVER_SVC_CHECKS);
929
 
 
930
 
                if(obsess_over_hosts==TRUE)
931
 
                        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,COMMAND_CGI,CMD_STOP_OBSESSING_OVER_HOST_CHECKS);
932
 
                else
933
 
                        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,COMMAND_CGI,CMD_START_OBSESSING_OVER_HOST_CHECKS);
934
 
 
935
 
                if(enable_flap_detection==TRUE)
936
 
                        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,COMMAND_CGI,CMD_DISABLE_FLAP_DETECTION);
937
 
                else
938
 
                        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,COMMAND_CGI,CMD_ENABLE_FLAP_DETECTION);
 
898
                if(enable_notifications == TRUE)
 
899
                        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, COMMAND_CGI, CMD_DISABLE_NOTIFICATIONS);
 
900
                else
 
901
                        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, COMMAND_CGI, CMD_ENABLE_NOTIFICATIONS);
 
902
 
 
903
                if(execute_service_checks == TRUE)
 
904
                        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, COMMAND_CGI, CMD_STOP_EXECUTING_SVC_CHECKS);
 
905
                else
 
906
                        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, COMMAND_CGI, CMD_START_EXECUTING_SVC_CHECKS);
 
907
 
 
908
                if(accept_passive_service_checks == TRUE)
 
909
                        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, COMMAND_CGI, CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS);
 
910
                else
 
911
                        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, COMMAND_CGI, CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS);
 
912
 
 
913
                if(execute_host_checks == TRUE)
 
914
                        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, COMMAND_CGI, CMD_STOP_EXECUTING_HOST_CHECKS);
 
915
                else
 
916
                        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, COMMAND_CGI, CMD_START_EXECUTING_HOST_CHECKS);
 
917
 
 
918
                if(accept_passive_host_checks == TRUE)
 
919
                        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, COMMAND_CGI, CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS);
 
920
                else
 
921
                        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, COMMAND_CGI, CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS);
 
922
 
 
923
                if(enable_event_handlers == TRUE)
 
924
                        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, COMMAND_CGI, CMD_DISABLE_EVENT_HANDLERS);
 
925
                else
 
926
                        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, COMMAND_CGI, CMD_ENABLE_EVENT_HANDLERS);
 
927
 
 
928
                if(obsess_over_services == TRUE)
 
929
                        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, COMMAND_CGI, CMD_STOP_OBSESSING_OVER_SVC_CHECKS);
 
930
                else
 
931
                        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, COMMAND_CGI, CMD_START_OBSESSING_OVER_SVC_CHECKS);
 
932
 
 
933
                if(obsess_over_hosts == TRUE)
 
934
                        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, COMMAND_CGI, CMD_STOP_OBSESSING_OVER_HOST_CHECKS);
 
935
                else
 
936
                        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, COMMAND_CGI, CMD_START_OBSESSING_OVER_HOST_CHECKS);
 
937
 
 
938
                if(enable_flap_detection == TRUE)
 
939
                        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, COMMAND_CGI, CMD_DISABLE_FLAP_DETECTION);
 
940
                else
 
941
                        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, COMMAND_CGI, CMD_ENABLE_FLAP_DETECTION);
939
942
 
940
943
#ifdef PREDICT_FAILURES
941
 
                if(enable_failure_prediction==TRUE)
942
 
                        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,COMMAND_CGI,CMD_DISABLE_FAILURE_PREDICTION);
 
944
                if(enable_failure_prediction == TRUE)
 
945
                        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, COMMAND_CGI, CMD_DISABLE_FAILURE_PREDICTION);
943
946
                else
944
 
                        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,COMMAND_CGI,CMD_ENABLE_FAILURE_PREDICTION);
 
947
                        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, COMMAND_CGI, CMD_ENABLE_FAILURE_PREDICTION);
945
948
#endif
946
 
                if(process_performance_data==TRUE)
947
 
                        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,COMMAND_CGI,CMD_DISABLE_PERFORMANCE_DATA);
 
949
                if(process_performance_data == TRUE)
 
950
                        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, COMMAND_CGI, CMD_DISABLE_PERFORMANCE_DATA);
948
951
                else
949
 
                        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,COMMAND_CGI,CMD_ENABLE_PERFORMANCE_DATA);
 
952
                        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, COMMAND_CGI, CMD_ENABLE_PERFORMANCE_DATA);
950
953
 
951
954
                printf("</TABLE>\n");
952
 
                }
953
 
        else{
 
955
                }
 
956
        else {
954
957
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>It appears as though Nagios is not running, so commands are temporarily unavailable...\n");
955
 
                if(!strcmp(nagios_check_command,"")){
 
958
                if(!strcmp(nagios_check_command, "")) {
956
959
                        printf("<BR><BR>\n");
957
960
                        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");
958
961
                        printf("Read the documentation for more information on checking the status of the Nagios process in the CGIs.\n");
959
 
                        }
 
962
                        }
960
963
                printf("</DIV>\n");
961
 
                }
 
964
                }
962
965
 
963
966
        printf("</TD></TR>\n");
964
967
        printf("</TABLE>\n");
965
968
 
966
969
        printf("</TD></TR></TABLE>\n");
967
970
        printf("</DIV>\n");
968
 
 
969
 
#ifdef REMOVED_081203
970
 
        printf("<P>");
971
 
        printf("<DIV ALIGN=CENTER>\n");
972
 
 
973
 
        printf("<DIV CLASS='dataTitle'>Process Status Information</DIV>\n");
974
 
 
975
 
        printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 CLASS='data'>\n");
976
 
        printf("<TR><TD class='stateInfoTable2'>\n");
977
 
        printf("<TABLE BORDER=0>\n");
978
 
 
979
 
        if(nagios_process_state==STATE_OK){
980
 
                strcpy(state_string,"OK");
981
 
                state_class="processOK";
982
 
                }
983
 
        else if(nagios_process_state==STATE_WARNING){
984
 
                strcpy(state_string,"WARNING");
985
 
                state_class="processWARNING";
986
 
                }
987
 
        else if(nagios_process_state==STATE_CRITICAL){
988
 
                strcpy(state_string,"CRITICAL");
989
 
                state_class="processCRITICAL";
990
 
                }
991
 
        else{
992
 
                strcpy(state_string,"UNKNOWN");
993
 
                state_class="processUNKNOWN";
994
 
                }
995
 
 
996
 
        /* process state */
997
 
        printf("<TR><TD CLASS='dataVar'>Process Status:</TD><TD CLASS='dataVal'><DIV CLASS='%s'>&nbsp;&nbsp;%s&nbsp;&nbsp;</DIV></TD></TR>\n",state_class,state_string);
998
 
 
999
 
        /* process check command result */
1000
 
        printf("<TR><TD CLASS='dataVar'>Check Command Output:&nbsp;</TD><TD CLASS='dataVal'>%s&nbsp;</TD></TR>\n",nagios_process_info);
1001
 
 
1002
 
        printf("</TABLE>\n");
1003
 
        printf("</TD></TR>\n");
1004
 
        printf("</TABLE>\n");
1005
 
 
1006
 
        printf("</DIV>\n");
1007
 
        printf("</P>\n");
1008
 
#endif
1009
 
 
1010
 
        return;
1011
971
        }
1012
972
 
1013
973
 
1014
 
void show_host_info(void){
 
974
void show_host_info(void) {
1015
975
        hoststatus *temp_hoststatus;
1016
976
        host *temp_host;
1017
977
        char date_time[MAX_DATETIME_LENGTH];
1018
978
        char state_duration[48];
1019
979
        char status_age[48];
1020
980
        char state_string[MAX_INPUT_BUFFER];
1021
 
        char *bg_class="";
1022
 
        char *buf=NULL;
 
981
        char *bg_class = "";
 
982
        char *buf = NULL;
1023
983
        int days;
1024
984
        int hours;
1025
985
        int minutes;
1026
986
        int seconds;
1027
987
        time_t current_time;
1028
988
        time_t t;
1029
 
        int duration_error=FALSE;
 
989
        int duration_error = FALSE;
1030
990
 
1031
991
 
1032
992
        /* get host info */
1033
 
        temp_host=find_host(host_name);
 
993
        temp_host = find_host(host_name);
1034
994
 
1035
995
        /* make sure the user has rights to view host information */
1036
 
        if(is_authorized_for_host(temp_host,&current_authdata)==FALSE){
 
996
        if(is_authorized_for_host(temp_host, &current_authdata) == FALSE) {
1037
997
 
1038
998
                printf("<P><DIV CLASS='errorMessage'>It appears as though you do not have permission to view information for this host...</DIV></P>\n");
1039
999
                printf("<P><DIV CLASS='errorDescription'>If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI<br>");
1040
1000
                printf("and check the authorization options in your CGI configuration file.</DIV></P>\n");
1041
1001
 
1042
1002
                return;
1043
 
                }
 
1003
                }
1044
1004
 
1045
1005
        /* get host status info */
1046
 
        temp_hoststatus=find_hoststatus(host_name);
 
1006
        temp_hoststatus = find_hoststatus(host_name);
1047
1007
 
1048
1008
        /* make sure host information exists */
1049
 
        if(temp_host==NULL){
 
1009
        if(temp_host == NULL) {
1050
1010
                printf("<P><DIV CLASS='errorMessage'>Error: Host Not Found!</DIV></P>>");
1051
1011
                return;
1052
1012
                }
1053
 
        if(temp_hoststatus==NULL){
 
1013
        if(temp_hoststatus == NULL) {
1054
1014
                printf("<P><DIV CLASS='errorMessage'>Error: Host Status Information Not Found!</DIV></P");
1055
1015
                return;
1056
1016
                }
1061
1021
        printf("<TR>\n");
1062
1022
 
1063
1023
        printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel'>\n");
1064
 
        
 
1024
 
1065
1025
        printf("<DIV CLASS='dataTitle'>Host State Information</DIV>\n");
1066
1026
 
1067
 
        if(temp_hoststatus->has_been_checked==FALSE)
 
1027
        if(temp_hoststatus->has_been_checked == FALSE)
1068
1028
                printf("<P><DIV ALIGN=CENTER>This host has not yet been checked, so status information is not available.</DIV></P>\n");
1069
1029
 
1070
 
        else{
 
1030
        else {
1071
1031
 
1072
1032
                printf("<TABLE BORDER=0>\n");
1073
1033
                printf("<TR><TD>\n");
1076
1036
                printf("<TR><TD class='stateInfoTable1'>\n");
1077
1037
                printf("<TABLE BORDER=0>\n");
1078
1038
 
1079
 
                current_time=time(NULL);
1080
 
                t=0;
1081
 
                duration_error=FALSE;
1082
 
                if(temp_hoststatus->last_state_change==(time_t)0){
1083
 
                        if(program_start>current_time)
1084
 
                                duration_error=TRUE;
1085
 
                        else
1086
 
                                t=current_time-program_start;
1087
 
                        }
1088
 
                else{
1089
 
                        if(temp_hoststatus->last_state_change>current_time)
1090
 
                                duration_error=TRUE;
1091
 
                        else
1092
 
                                t=current_time-temp_hoststatus->last_state_change;
1093
 
                        }
1094
 
                get_time_breakdown((unsigned long)t,&days,&hours,&minutes,&seconds);
1095
 
                if(duration_error==TRUE)
1096
 
                        snprintf(state_duration,sizeof(state_duration)-1,"???");
 
1039
                current_time = time(NULL);
 
1040
                t = 0;
 
1041
                duration_error = FALSE;
 
1042
                if(temp_hoststatus->last_state_change == (time_t)0) {
 
1043
                        if(program_start > current_time)
 
1044
                                duration_error = TRUE;
 
1045
                        else
 
1046
                                t = current_time - program_start;
 
1047
                        }
 
1048
                else {
 
1049
                        if(temp_hoststatus->last_state_change > current_time)
 
1050
                                duration_error = TRUE;
 
1051
                        else
 
1052
                                t = current_time - temp_hoststatus->last_state_change;
 
1053
                        }
 
1054
                get_time_breakdown((unsigned long)t, &days, &hours, &minutes, &seconds);
 
1055
                if(duration_error == TRUE)
 
1056
                        snprintf(state_duration, sizeof(state_duration) - 1, "???");
1097
1057
                else
1098
 
                        snprintf(state_duration,sizeof(state_duration)-1,"%2dd %2dh %2dm %2ds%s",days,hours,minutes,seconds,(temp_hoststatus->last_state_change==(time_t)0)?"+":"");
1099
 
                state_duration[sizeof(state_duration)-1]='\x0';
1100
 
 
1101
 
                if(temp_hoststatus->status==HOST_UP){
1102
 
                        strcpy(state_string,"UP");
1103
 
                        bg_class="hostUP";
1104
 
                        }
1105
 
                else if(temp_hoststatus->status==HOST_DOWN){
1106
 
                        strcpy(state_string,"DOWN");
1107
 
                        bg_class="hostDOWN";
1108
 
                        }
1109
 
                else if(temp_hoststatus->status==HOST_UNREACHABLE){
1110
 
                        strcpy(state_string,"UNREACHABLE");
1111
 
                        bg_class="hostUNREACHABLE";
1112
 
                        }
1113
 
 
1114
 
                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)":"");
1115
 
 
1116
 
                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));
1117
 
                if(enable_splunk_integration==TRUE){
 
1058
                        snprintf(state_duration, sizeof(state_duration) - 1, "%2dd %2dh %2dm %2ds%s", days, hours, minutes, seconds, (temp_hoststatus->last_state_change == (time_t)0) ? "+" : "");
 
1059
                state_duration[sizeof(state_duration) - 1] = '\x0';
 
1060
 
 
1061
                if(temp_hoststatus->status == HOST_UP) {
 
1062
                        strcpy(state_string, "UP");
 
1063
                        bg_class = "hostUP";
 
1064
                        }
 
1065
                else if(temp_hoststatus->status == HOST_DOWN) {
 
1066
                        strcpy(state_string, "DOWN");
 
1067
                        bg_class = "hostDOWN";
 
1068
                        }
 
1069
                else if(temp_hoststatus->status == HOST_UNREACHABLE) {
 
1070
                        strcpy(state_string, "UNREACHABLE");
 
1071
                        bg_class = "hostUNREACHABLE";
 
1072
                        }
 
1073
 
 
1074
                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)" : "");
 
1075
 
 
1076
                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));
 
1077
                if(enable_splunk_integration == TRUE) {
1118
1078
                        printf("&nbsp;&nbsp;");
1119
 
                        asprintf(&buf,"%s %s",temp_host->name,temp_hoststatus->plugin_output);
1120
 
                        display_splunk_generic_url(buf,1);
 
1079
                        asprintf(&buf, "%s %s", temp_host->name, temp_hoststatus->plugin_output);
 
1080
                        display_splunk_generic_url(buf, 1);
1121
1081
                        free(buf);
1122
1082
                        }
1123
 
                if(temp_hoststatus->long_plugin_output!=NULL)
1124
 
                        printf("<BR>%s",html_encode(temp_hoststatus->long_plugin_output,TRUE));
 
1083
                if(temp_hoststatus->long_plugin_output != NULL)
 
1084
                        printf("<BR>%s", html_encode(temp_hoststatus->long_plugin_output, TRUE));
1125
1085
                printf("</TD></TR>\n");
1126
1086
 
1127
 
                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));
1128
 
 
1129
 
                printf("<TR><TD CLASS='dataVar'>Current Attempt:</TD><TD CLASS='dataVal'>%d/%d",temp_hoststatus->current_attempt,temp_hoststatus->max_attempts);
1130
 
                printf("&nbsp;&nbsp;(%s state)</TD></TR>\n",(temp_hoststatus->state_type==HARD_STATE)?"HARD":"SOFT");
1131
 
 
1132
 
                get_time_string(&temp_hoststatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1133
 
                printf("<TR><TD CLASS='dataVar'>Last Check Time:</td><td CLASS='dataVal'>%s</td></tr>\n",date_time);
1134
 
 
1135
 
                printf("<TR><TD CLASS='dataVar'>Check Type:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(temp_hoststatus->check_type==HOST_CHECK_ACTIVE)?"ACTIVE":"PASSIVE");
 
1087
                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));
 
1088
 
 
1089
                printf("<TR><TD CLASS='dataVar'>Current Attempt:</TD><TD CLASS='dataVal'>%d/%d", temp_hoststatus->current_attempt, temp_hoststatus->max_attempts);
 
1090
                printf("&nbsp;&nbsp;(%s state)</TD></TR>\n", (temp_hoststatus->state_type == HARD_STATE) ? "HARD" : "SOFT");
 
1091
 
 
1092
                get_time_string(&temp_hoststatus->last_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1093
                printf("<TR><TD CLASS='dataVar'>Last Check Time:</td><td CLASS='dataVal'>%s</td></tr>\n", date_time);
 
1094
 
 
1095
                printf("<TR><TD CLASS='dataVar'>Check Type:</TD><TD CLASS='dataVal'>%s</TD></TR>\n", (temp_hoststatus->check_type == HOST_CHECK_ACTIVE) ? "ACTIVE" : "PASSIVE");
1136
1096
 
1137
1097
                printf("<TR><TD CLASS='dataVar' NOWRAP>Check Latency / Duration:</TD><TD CLASS='dataVal'>");
1138
 
                if(temp_hoststatus->check_type==HOST_CHECK_ACTIVE)
1139
 
                        printf("%.3f",temp_hoststatus->latency);
 
1098
                if(temp_hoststatus->check_type == HOST_CHECK_ACTIVE)
 
1099
                        printf("%.3f", temp_hoststatus->latency);
1140
1100
                else
1141
1101
                        printf("N/A");
1142
 
                printf("&nbsp;/&nbsp;%.3f seconds",temp_hoststatus->execution_time);
 
1102
                printf("&nbsp;/&nbsp;%.3f seconds", temp_hoststatus->execution_time);
1143
1103
                printf("</TD></TR>\n");
1144
1104
 
1145
 
                get_time_string(&temp_hoststatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1146
 
                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");
1147
 
 
1148
 
                get_time_string(&temp_hoststatus->last_state_change,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1149
 
                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);
1150
 
 
1151
 
                get_time_string(&temp_hoststatus->last_notification,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1152
 
                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);
 
1105
                get_time_string(&temp_hoststatus->next_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1106
                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");
 
1107
 
 
1108
                get_time_string(&temp_hoststatus->last_state_change, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1109
                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);
 
1110
 
 
1111
                get_time_string(&temp_hoststatus->last_notification, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1112
                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);
1153
1113
 
1154
1114
                printf("<TR><TD CLASS='dataVar'>Is This Host Flapping?</td><td CLASS='dataVal'>");
1155
 
                if(temp_hoststatus->flap_detection_enabled==FALSE || enable_flap_detection==FALSE)
 
1115
                if(temp_hoststatus->flap_detection_enabled == FALSE || enable_flap_detection == FALSE)
1156
1116
                        printf("N/A");
1157
1117
                else
1158
 
                        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);
 
1118
                        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);
1159
1119
                printf("</td></tr>\n");
1160
1120
 
1161
 
                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");
1162
 
 
1163
 
                t=0;
1164
 
                duration_error=FALSE;
1165
 
                if(temp_hoststatus->last_check>current_time)
1166
 
                        duration_error=TRUE;
1167
 
                else
1168
 
                        /*t=current_time-temp_hoststatus->last_check;*/
1169
 
                        t=current_time-temp_hoststatus->last_update;
1170
 
                get_time_breakdown((unsigned long)t,&days,&hours,&minutes,&seconds);
1171
 
                if(duration_error==TRUE)
1172
 
                        snprintf(status_age,sizeof(status_age)-1,"???");
1173
 
                else if(temp_hoststatus->last_check==(time_t)0)
1174
 
                        snprintf(status_age,sizeof(status_age)-1,"N/A");
1175
 
                else
1176
 
                        snprintf(status_age,sizeof(status_age)-1,"%2dd %2dh %2dm %2ds",days,hours,minutes,seconds);
1177
 
                status_age[sizeof(status_age)-1]='\x0';
1178
 
 
1179
 
                get_time_string(&temp_hoststatus->last_update,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1180
 
                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);
 
1121
                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");
 
1122
 
 
1123
                t = 0;
 
1124
                duration_error = FALSE;
 
1125
                if(temp_hoststatus->last_check > current_time)
 
1126
                        duration_error = TRUE;
 
1127
                else
 
1128
                        /*t=current_time-temp_hoststatus->last_check;*/
 
1129
                        t = current_time - temp_hoststatus->last_update;
 
1130
                get_time_breakdown((unsigned long)t, &days, &hours, &minutes, &seconds);
 
1131
                if(duration_error == TRUE)
 
1132
                        snprintf(status_age, sizeof(status_age) - 1, "???");
 
1133
                else if(temp_hoststatus->last_check == (time_t)0)
 
1134
                        snprintf(status_age, sizeof(status_age) - 1, "N/A");
 
1135
                else
 
1136
                        snprintf(status_age, sizeof(status_age) - 1, "%2dd %2dh %2dm %2ds", days, hours, minutes, seconds);
 
1137
                status_age[sizeof(status_age) - 1] = '\x0';
 
1138
 
 
1139
                get_time_string(&temp_hoststatus->last_update, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1140
                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);
1181
1141
 
1182
1142
                printf("</TABLE>\n");
1183
1143
                printf("</TD></TR>\n");
1190
1150
                printf("<TR><TD class='stateInfoTable2'>\n");
1191
1151
                printf("<TABLE BORDER=0>\n");
1192
1152
 
1193
 
                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");
1194
 
 
1195
 
                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");
1196
 
 
1197
 
                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");
1198
 
 
1199
 
                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");
1200
 
 
1201
 
                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");
1202
 
 
1203
 
                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");
1204
 
 
1205
 
                printf("</TABLE>\n");
1206
 
                printf("</TD></TR>\n");
1207
 
                printf("</TABLE>\n");
1208
 
 
1209
 
                printf("</TD></TR>\n");
1210
 
                printf("</TABLE>\n");
1211
 
                }
 
1153
                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");
 
1154
 
 
1155
                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");
 
1156
 
 
1157
                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");
 
1158
 
 
1159
                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");
 
1160
 
 
1161
                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");
 
1162
 
 
1163
                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");
 
1164
 
 
1165
                printf("</TABLE>\n");
 
1166
                printf("</TD></TR>\n");
 
1167
                printf("</TABLE>\n");
 
1168
 
 
1169
                printf("</TD></TR>\n");
 
1170
                printf("</TABLE>\n");
 
1171
                }
1212
1172
 
1213
1173
        printf("</TD>\n");
1214
1174
 
1221
1181
 
1222
1182
        printf("<TABLE BORDER='1' CELLPADDING=0 CELLSPACING=0><TR><TD>\n");
1223
1183
 
1224
 
        if(nagios_process_state==STATE_OK && is_authorized_for_read_only(&current_authdata)==FALSE){
 
1184
        if(nagios_process_state == STATE_OK && is_authorized_for_read_only(&current_authdata) == FALSE) {
1225
1185
 
1226
1186
                printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
1227
1187
#ifdef USE_STATUSMAP
1228
 
                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));
 
1188
                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));
1229
1189
#endif
1230
 
                if(temp_hoststatus->checks_enabled==TRUE){
1231
 
                        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,COMMAND_CGI,CMD_DISABLE_HOST_CHECK,url_encode(host_name));
1232
 
                        }
1233
 
                else
1234
 
                        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,COMMAND_CGI,CMD_ENABLE_HOST_CHECK,url_encode(host_name));
1235
 
                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,COMMAND_CGI,CMD_SCHEDULE_HOST_CHECK,url_encode(host_name),(temp_hoststatus->checks_enabled==TRUE)?"&force_check":"");
1236
 
 
1237
 
                if(temp_hoststatus->accept_passive_host_checks==TRUE){
1238
 
                        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,COMMAND_CGI,CMD_PROCESS_HOST_CHECK_RESULT,url_encode(host_name));
1239
 
                        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,COMMAND_CGI,CMD_DISABLE_PASSIVE_HOST_CHECKS,url_encode(host_name));
1240
 
                        }
1241
 
                else
1242
 
                        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,COMMAND_CGI,CMD_ENABLE_PASSIVE_HOST_CHECKS,url_encode(host_name));
1243
 
 
1244
 
                if(temp_hoststatus->obsess_over_host==TRUE)
1245
 
                        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,COMMAND_CGI,CMD_STOP_OBSESSING_OVER_HOST,url_encode(host_name));
1246
 
                else
1247
 
                        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,COMMAND_CGI,CMD_START_OBSESSING_OVER_HOST,url_encode(host_name));
1248
 
 
1249
 
                if(temp_hoststatus->status==HOST_DOWN || temp_hoststatus->status==HOST_UNREACHABLE){
1250
 
                        if(temp_hoststatus->problem_has_been_acknowledged==FALSE)
1251
 
                                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,COMMAND_CGI,CMD_ACKNOWLEDGE_HOST_PROBLEM,url_encode(host_name));
 
1190
                if(temp_hoststatus->checks_enabled == TRUE) {
 
1191
                        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, COMMAND_CGI, CMD_DISABLE_HOST_CHECK, url_encode(host_name));
 
1192
                        }
 
1193
                else
 
1194
                        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, COMMAND_CGI, CMD_ENABLE_HOST_CHECK, url_encode(host_name));
 
1195
                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, COMMAND_CGI, CMD_SCHEDULE_HOST_CHECK, url_encode(host_name), (temp_hoststatus->checks_enabled == TRUE) ? "&force_check" : "");
 
1196
 
 
1197
                if(temp_hoststatus->accept_passive_host_checks == TRUE) {
 
1198
                        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, COMMAND_CGI, CMD_PROCESS_HOST_CHECK_RESULT, url_encode(host_name));
 
1199
                        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, COMMAND_CGI, CMD_DISABLE_PASSIVE_HOST_CHECKS, url_encode(host_name));
 
1200
                        }
 
1201
                else
 
1202
                        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, COMMAND_CGI, CMD_ENABLE_PASSIVE_HOST_CHECKS, url_encode(host_name));
 
1203
 
 
1204
                if(temp_hoststatus->obsess_over_host == TRUE)
 
1205
                        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, COMMAND_CGI, CMD_STOP_OBSESSING_OVER_HOST, url_encode(host_name));
 
1206
                else
 
1207
                        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, COMMAND_CGI, CMD_START_OBSESSING_OVER_HOST, url_encode(host_name));
 
1208
 
 
1209
                if(temp_hoststatus->status == HOST_DOWN || temp_hoststatus->status == HOST_UNREACHABLE) {
 
1210
                        if(temp_hoststatus->problem_has_been_acknowledged == FALSE)
 
1211
                                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, COMMAND_CGI, CMD_ACKNOWLEDGE_HOST_PROBLEM, url_encode(host_name));
1252
1212
                        else
1253
 
                                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,COMMAND_CGI,CMD_REMOVE_HOST_ACKNOWLEDGEMENT,url_encode(host_name));
1254
 
                        }
1255
 
 
1256
 
                if(temp_hoststatus->notifications_enabled==TRUE)
1257
 
                        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,COMMAND_CGI,CMD_DISABLE_HOST_NOTIFICATIONS,url_encode(host_name));
1258
 
                else
1259
 
                        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,COMMAND_CGI,CMD_ENABLE_HOST_NOTIFICATIONS,url_encode(host_name));
1260
 
 
1261
 
                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,COMMAND_CGI,CMD_SEND_CUSTOM_HOST_NOTIFICATION,url_encode(host_name));
1262
 
 
1263
 
                if(temp_hoststatus->status!=HOST_UP)
1264
 
                        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,COMMAND_CGI,CMD_DELAY_HOST_NOTIFICATION,url_encode(host_name));
1265
 
 
1266
 
                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,COMMAND_CGI,CMD_SCHEDULE_HOST_DOWNTIME,url_encode(host_name));
1267
 
                
1268
 
                printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For All Services On This Host' TITLE='Schedule Downtime For All Services On This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Schedule downtime for all services on this host</a></td></tr>\n",url_images_path,DOWNTIME_ICON,COMMAND_CGI,CMD_SCHEDULE_HOST_SVC_DOWNTIME,url_encode(host_name));
1269
 
 
1270
 
                /*
1271
 
                printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Cancel Scheduled Downtime For This Host' TITLE='Cancel Scheduled Downtime For This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Cancel scheduled downtime for this host</a></td></tr>\n",url_images_path,SCHEDULED_DOWNTIME_ICON,COMMAND_CGI,CMD_CANCEL_HOST_DOWNTIME,url_encode(host_name));
1272
 
                */
1273
 
 
1274
 
                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,COMMAND_CGI,CMD_DISABLE_HOST_SVC_NOTIFICATIONS,url_encode(host_name));
1275
 
 
1276
 
                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,COMMAND_CGI,CMD_ENABLE_HOST_SVC_NOTIFICATIONS,url_encode(host_name));
1277
 
 
1278
 
                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,COMMAND_CGI,CMD_SCHEDULE_HOST_SVC_CHECKS,url_encode(host_name));
1279
 
 
1280
 
                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,COMMAND_CGI,CMD_DISABLE_HOST_SVC_CHECKS,url_encode(host_name));
1281
 
 
1282
 
                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,COMMAND_CGI,CMD_ENABLE_HOST_SVC_CHECKS,url_encode(host_name));
1283
 
 
1284
 
                if(temp_hoststatus->event_handler_enabled==TRUE)
1285
 
                        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,COMMAND_CGI,CMD_DISABLE_HOST_EVENT_HANDLER,url_encode(host_name));
1286
 
                else
1287
 
                        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,COMMAND_CGI,CMD_ENABLE_HOST_EVENT_HANDLER,url_encode(host_name));
1288
 
                if(temp_hoststatus->flap_detection_enabled==TRUE)
1289
 
                        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,COMMAND_CGI,CMD_DISABLE_HOST_FLAP_DETECTION,url_encode(host_name));
1290
 
                else
1291
 
                        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,COMMAND_CGI,CMD_ENABLE_HOST_FLAP_DETECTION,url_encode(host_name));
 
1213
                                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, COMMAND_CGI, CMD_REMOVE_HOST_ACKNOWLEDGEMENT, url_encode(host_name));
 
1214
                        }
 
1215
 
 
1216
                if(temp_hoststatus->notifications_enabled == TRUE)
 
1217
                        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, COMMAND_CGI, CMD_DISABLE_HOST_NOTIFICATIONS, url_encode(host_name));
 
1218
                else
 
1219
                        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, COMMAND_CGI, CMD_ENABLE_HOST_NOTIFICATIONS, url_encode(host_name));
 
1220
 
 
1221
                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, COMMAND_CGI, CMD_SEND_CUSTOM_HOST_NOTIFICATION, url_encode(host_name));
 
1222
 
 
1223
                if(temp_hoststatus->status != HOST_UP)
 
1224
                        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, COMMAND_CGI, CMD_DELAY_HOST_NOTIFICATION, url_encode(host_name));
 
1225
 
 
1226
                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, COMMAND_CGI, CMD_SCHEDULE_HOST_DOWNTIME, url_encode(host_name));
 
1227
 
 
1228
                printf("<tr CLASS='command'><td><img src='%s%s' border=0 ALT='Schedule Downtime For All Services On This Host' TITLE='Schedule Downtime For All Services On This Host'></td><td CLASS='command'><a href='%s?cmd_typ=%d&host=%s'>Schedule downtime for all services on this host</a></td></tr>\n", url_images_path, DOWNTIME_ICON, COMMAND_CGI, CMD_SCHEDULE_HOST_SVC_DOWNTIME, url_encode(host_name));
 
1229
 
 
1230
                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, COMMAND_CGI, CMD_DISABLE_HOST_SVC_NOTIFICATIONS, url_encode(host_name));
 
1231
 
 
1232
                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, COMMAND_CGI, CMD_ENABLE_HOST_SVC_NOTIFICATIONS, url_encode(host_name));
 
1233
 
 
1234
                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, COMMAND_CGI, CMD_SCHEDULE_HOST_SVC_CHECKS, url_encode(host_name));
 
1235
 
 
1236
                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, COMMAND_CGI, CMD_DISABLE_HOST_SVC_CHECKS, url_encode(host_name));
 
1237
 
 
1238
                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, COMMAND_CGI, CMD_ENABLE_HOST_SVC_CHECKS, url_encode(host_name));
 
1239
 
 
1240
                if(temp_hoststatus->event_handler_enabled == TRUE)
 
1241
                        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, COMMAND_CGI, CMD_DISABLE_HOST_EVENT_HANDLER, url_encode(host_name));
 
1242
                else
 
1243
                        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, COMMAND_CGI, CMD_ENABLE_HOST_EVENT_HANDLER, url_encode(host_name));
 
1244
                if(temp_hoststatus->flap_detection_enabled == TRUE)
 
1245
                        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, COMMAND_CGI, CMD_DISABLE_HOST_FLAP_DETECTION, url_encode(host_name));
 
1246
                else
 
1247
                        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, COMMAND_CGI, CMD_ENABLE_HOST_FLAP_DETECTION, url_encode(host_name));
1292
1248
 
1293
1249
                printf("</TABLE>\n");
1294
1250
                }
1295
 
        else if (is_authorized_for_read_only(&current_authdata)==TRUE){
1296
 
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to execute commands.<br>\n");
 
1251
        else if(is_authorized_for_read_only(&current_authdata) == TRUE) {
 
1252
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to execute commands.<br>\n");
1297
1253
                }
1298
 
        else{
 
1254
        else {
1299
1255
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>It appears as though Nagios is not running, so commands are temporarily unavailable...<br>\n");
1300
 
                printf("Click <a href='%s?type=%d'>here</a> to view Nagios process information</DIV>\n",EXTINFO_CGI,DISPLAY_PROCESS_INFO);
1301
 
                }
 
1256
                printf("Click <a href='%s?type=%d'>here</a> to view Nagios process information</DIV>\n", EXTINFO_CGI, DISPLAY_PROCESS_INFO);
 
1257
                }
1302
1258
        printf("</TD></TR></TABLE>\n");
1303
1259
 
1304
1260
        printf("</TD>\n");
1310
1266
 
1311
1267
        printf("<TD COLSPAN=2 ALIGN=CENTER VALIGN=TOP CLASS='commentPanel'>\n");
1312
1268
 
1313
 
        if(is_authorized_for_read_only(&current_authdata)==FALSE){
 
1269
        if(is_authorized_for_read_only(&current_authdata) == FALSE) {
1314
1270
                /* display comments */
1315
1271
                display_comments(HOST_COMMENT);
1316
1272
                }
1324
1280
        }
1325
1281
 
1326
1282
 
1327
 
void show_service_info(void){
 
1283
void show_service_info(void) {
1328
1284
        service *temp_service;
1329
1285
        char date_time[MAX_DATETIME_LENGTH];
1330
1286
        char status_age[48];
1331
1287
        char state_duration[48];
1332
1288
        servicestatus *temp_svcstatus;
1333
1289
        char state_string[MAX_INPUT_BUFFER];
1334
 
        char *bg_class="";
1335
 
        char *buf=NULL;
 
1290
        char *bg_class = "";
 
1291
        char *buf = NULL;
1336
1292
        int days;
1337
1293
        int hours;
1338
1294
        int minutes;
1339
1295
        int seconds;
1340
1296
        time_t t;
1341
1297
        time_t current_time;
1342
 
        int duration_error=FALSE;
 
1298
        int duration_error = FALSE;
1343
1299
 
1344
1300
        /* find the service */
1345
 
        temp_service=find_service(host_name,service_desc);
 
1301
        temp_service = find_service(host_name, service_desc);
1346
1302
 
1347
1303
        /* make sure the user has rights to view service information */
1348
 
        if(is_authorized_for_service(temp_service,&current_authdata)==FALSE){
 
1304
        if(is_authorized_for_service(temp_service, &current_authdata) == FALSE) {
1349
1305
 
1350
1306
                printf("<P><DIV CLASS='errorMessage'>It appears as though you do not have permission to view information for this service...</DIV></P>\n");
1351
1307
                printf("<P><DIV CLASS='errorDescription'>If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI<br>");
1352
1308
                printf("and check the authorization options in your CGI configuration file.</DIV></P>\n");
1353
1309
 
1354
1310
                return;
1355
 
                }
 
1311
                }
1356
1312
 
1357
1313
        /* get service status info */
1358
 
        temp_svcstatus=find_servicestatus(host_name,service_desc);
 
1314
        temp_svcstatus = find_servicestatus(host_name, service_desc);
1359
1315
 
1360
1316
        /* make sure service information exists */
1361
 
        if(temp_service==NULL){
 
1317
        if(temp_service == NULL) {
1362
1318
                printf("<P><DIV CLASS='errorMessage'>Error: Service Not Found!</DIV></P>");
1363
1319
                return;
1364
1320
                }
1365
 
        if(temp_svcstatus==NULL){
 
1321
        if(temp_svcstatus == NULL) {
1366
1322
                printf("<P><DIV CLASS='errorMessage'>Error: Service Status Not Found!</DIV></P>");
1367
1323
                return;
1368
1324
                }
1373
1329
        printf("<TR>\n");
1374
1330
 
1375
1331
        printf("<TD ALIGN=CENTER VALIGN=TOP CLASS='stateInfoPanel'>\n");
1376
 
        
 
1332
 
1377
1333
        printf("<DIV CLASS='dataTitle'>Service State Information</DIV>\n");
1378
1334
 
1379
 
        if(temp_svcstatus->has_been_checked==FALSE)
 
1335
        if(temp_svcstatus->has_been_checked == FALSE)
1380
1336
                printf("<P><DIV ALIGN=CENTER>This service has not yet been checked, so status information is not available.</DIV></P>\n");
1381
1337
 
1382
 
        else{
 
1338
        else {
1383
1339
 
1384
1340
                printf("<TABLE BORDER=0>\n");
1385
1341
 
1390
1346
                printf("<TABLE BORDER=0>\n");
1391
1347
 
1392
1348
 
1393
 
                current_time=time(NULL);
1394
 
                t=0;
1395
 
                duration_error=FALSE;
1396
 
                if(temp_svcstatus->last_state_change==(time_t)0){
1397
 
                        if(program_start>current_time)
1398
 
                                duration_error=TRUE;
1399
 
                        else
1400
 
                                t=current_time-program_start;
1401
 
                        }
1402
 
                else{
1403
 
                        if(temp_svcstatus->last_state_change>current_time)
1404
 
                                duration_error=TRUE;
1405
 
                        else
1406
 
                                t=current_time-temp_svcstatus->last_state_change;
1407
 
                        }
1408
 
                get_time_breakdown((unsigned long)t,&days,&hours,&minutes,&seconds);
1409
 
                if(duration_error==TRUE)
1410
 
                        snprintf(state_duration,sizeof(state_duration)-1,"???");
 
1349
                current_time = time(NULL);
 
1350
                t = 0;
 
1351
                duration_error = FALSE;
 
1352
                if(temp_svcstatus->last_state_change == (time_t)0) {
 
1353
                        if(program_start > current_time)
 
1354
                                duration_error = TRUE;
 
1355
                        else
 
1356
                                t = current_time - program_start;
 
1357
                        }
 
1358
                else {
 
1359
                        if(temp_svcstatus->last_state_change > current_time)
 
1360
                                duration_error = TRUE;
 
1361
                        else
 
1362
                                t = current_time - temp_svcstatus->last_state_change;
 
1363
                        }
 
1364
                get_time_breakdown((unsigned long)t, &days, &hours, &minutes, &seconds);
 
1365
                if(duration_error == TRUE)
 
1366
                        snprintf(state_duration, sizeof(state_duration) - 1, "???");
1411
1367
                else
1412
 
                        snprintf(state_duration,sizeof(state_duration)-1,"%2dd %2dh %2dm %2ds%s",days,hours,minutes,seconds,(temp_svcstatus->last_state_change==(time_t)0)?"+":"");
1413
 
                state_duration[sizeof(state_duration)-1]='\x0';
1414
 
 
1415
 
                if(temp_svcstatus->status==SERVICE_OK){
1416
 
                        strcpy(state_string,"OK");
1417
 
                        bg_class="serviceOK";
1418
 
                        }
1419
 
                else if(temp_svcstatus->status==SERVICE_WARNING){
1420
 
                        strcpy(state_string,"WARNING");
1421
 
                        bg_class="serviceWARNING";
1422
 
                        }
1423
 
                else if(temp_svcstatus->status==SERVICE_CRITICAL){
1424
 
                        strcpy(state_string,"CRITICAL");
1425
 
                        bg_class="serviceCRITICAL";
1426
 
                        }
1427
 
                else{
1428
 
                        strcpy(state_string,"UNKNOWN");
1429
 
                        bg_class="serviceUNKNOWN";
1430
 
                        }
1431
 
                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)":"");
1432
 
 
1433
 
                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));
1434
 
                if(enable_splunk_integration==TRUE){
 
1368
                        snprintf(state_duration, sizeof(state_duration) - 1, "%2dd %2dh %2dm %2ds%s", days, hours, minutes, seconds, (temp_svcstatus->last_state_change == (time_t)0) ? "+" : "");
 
1369
                state_duration[sizeof(state_duration) - 1] = '\x0';
 
1370
 
 
1371
                if(temp_svcstatus->status == SERVICE_OK) {
 
1372
                        strcpy(state_string, "OK");
 
1373
                        bg_class = "serviceOK";
 
1374
                        }
 
1375
                else if(temp_svcstatus->status == SERVICE_WARNING) {
 
1376
                        strcpy(state_string, "WARNING");
 
1377
                        bg_class = "serviceWARNING";
 
1378
                        }
 
1379
                else if(temp_svcstatus->status == SERVICE_CRITICAL) {
 
1380
                        strcpy(state_string, "CRITICAL");
 
1381
                        bg_class = "serviceCRITICAL";
 
1382
                        }
 
1383
                else {
 
1384
                        strcpy(state_string, "UNKNOWN");
 
1385
                        bg_class = "serviceUNKNOWN";
 
1386
                        }
 
1387
                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)" : "");
 
1388
 
 
1389
                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));
 
1390
                if(enable_splunk_integration == TRUE) {
1435
1391
                        printf("&nbsp;&nbsp;");
1436
 
                        asprintf(&buf,"%s %s %s",temp_service->host_name,temp_service->description,temp_svcstatus->plugin_output);
1437
 
                        display_splunk_generic_url(buf,1);
 
1392
                        asprintf(&buf, "%s %s %s", temp_service->host_name, temp_service->description, temp_svcstatus->plugin_output);
 
1393
                        display_splunk_generic_url(buf, 1);
1438
1394
                        free(buf);
1439
1395
                        }
1440
 
                if(temp_svcstatus->long_plugin_output!=NULL)
1441
 
                        printf("<BR>%s",html_encode(temp_svcstatus->long_plugin_output,TRUE));
 
1396
                if(temp_svcstatus->long_plugin_output != NULL)
 
1397
                        printf("<BR>%s", html_encode(temp_svcstatus->long_plugin_output, TRUE));
1442
1398
                printf("</TD></TR>\n");
1443
1399
 
1444
 
                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));
1445
 
 
1446
 
                printf("<TR><TD CLASS='dataVar'>Current Attempt:</TD><TD CLASS='dataVal'>%d/%d",temp_svcstatus->current_attempt,temp_svcstatus->max_attempts);
1447
 
                printf("&nbsp;&nbsp;(%s state)</TD></TR>\n",(temp_svcstatus->state_type==HARD_STATE)?"HARD":"SOFT");
1448
 
 
1449
 
                get_time_string(&temp_svcstatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1450
 
                printf("<TR><TD CLASS='dataVar'>Last Check Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",date_time);
1451
 
 
1452
 
                printf("<TR><TD CLASS='dataVar'>Check Type:</TD><TD CLASS='dataVal'>%s</TD></TR>\n",(temp_svcstatus->check_type==SERVICE_CHECK_ACTIVE)?"ACTIVE":"PASSIVE");
 
1400
                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));
 
1401
 
 
1402
                printf("<TR><TD CLASS='dataVar'>Current Attempt:</TD><TD CLASS='dataVal'>%d/%d", temp_svcstatus->current_attempt, temp_svcstatus->max_attempts);
 
1403
                printf("&nbsp;&nbsp;(%s state)</TD></TR>\n", (temp_svcstatus->state_type == HARD_STATE) ? "HARD" : "SOFT");
 
1404
 
 
1405
                get_time_string(&temp_svcstatus->last_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1406
                printf("<TR><TD CLASS='dataVar'>Last Check Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n", date_time);
 
1407
 
 
1408
                printf("<TR><TD CLASS='dataVar'>Check Type:</TD><TD CLASS='dataVal'>%s</TD></TR>\n", (temp_svcstatus->check_type == SERVICE_CHECK_ACTIVE) ? "ACTIVE" : "PASSIVE");
1453
1409
 
1454
1410
                printf("<TR><TD CLASS='dataVar' NOWRAP>Check Latency / Duration:</TD><TD CLASS='dataVal'>");
1455
 
                if(temp_svcstatus->check_type==SERVICE_CHECK_ACTIVE)
1456
 
                        printf("%.3f",temp_svcstatus->latency);
 
1411
                if(temp_svcstatus->check_type == SERVICE_CHECK_ACTIVE)
 
1412
                        printf("%.3f", temp_svcstatus->latency);
1457
1413
                else
1458
1414
                        printf("N/A");
1459
 
                printf("&nbsp;/&nbsp;%.3f seconds",temp_svcstatus->execution_time);
 
1415
                printf("&nbsp;/&nbsp;%.3f seconds", temp_svcstatus->execution_time);
1460
1416
                printf("</TD></TR>\n");
1461
1417
 
1462
 
                get_time_string(&temp_svcstatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1463
 
                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");
1464
 
 
1465
 
                get_time_string(&temp_svcstatus->last_state_change,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1466
 
                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);
1467
 
 
1468
 
                get_time_string(&temp_svcstatus->last_notification,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1469
 
                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);
 
1418
                get_time_string(&temp_svcstatus->next_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1419
                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");
 
1420
 
 
1421
                get_time_string(&temp_svcstatus->last_state_change, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1422
                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);
 
1423
 
 
1424
                get_time_string(&temp_svcstatus->last_notification, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1425
                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);
1470
1426
 
1471
1427
                printf("<TR><TD CLASS='dataVar'>Is This Service Flapping?</TD><TD CLASS='dataVal'>");
1472
 
                if(temp_svcstatus->flap_detection_enabled==FALSE || enable_flap_detection==FALSE)
 
1428
                if(temp_svcstatus->flap_detection_enabled == FALSE || enable_flap_detection == FALSE)
1473
1429
                        printf("N/A");
1474
1430
                else
1475
 
                        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);
 
1431
                        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);
1476
1432
                printf("</TD></TR>\n");
1477
1433
 
1478
 
                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");
 
1434
                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");
1479
1435
 
1480
 
                t=0;
1481
 
                duration_error=FALSE;
1482
 
                if(temp_svcstatus->last_check>current_time)
1483
 
                        duration_error=TRUE;
 
1436
                t = 0;
 
1437
                duration_error = FALSE;
 
1438
                if(temp_svcstatus->last_check > current_time)
 
1439
                        duration_error = TRUE;
1484
1440
                else
1485
1441
                        /*t=current_time-temp_svcstatus->last_check;*/
1486
 
                        t=current_time-temp_svcstatus->last_update;
1487
 
                get_time_breakdown((unsigned long)t,&days,&hours,&minutes,&seconds);
1488
 
                if(duration_error==TRUE)
1489
 
                        snprintf(status_age,sizeof(status_age)-1,"???");
1490
 
                else if(temp_svcstatus->last_check==(time_t)0)
1491
 
                        snprintf(status_age,sizeof(status_age)-1,"N/A");
 
1442
                        t = current_time - temp_svcstatus->last_update;
 
1443
                get_time_breakdown((unsigned long)t, &days, &hours, &minutes, &seconds);
 
1444
                if(duration_error == TRUE)
 
1445
                        snprintf(status_age, sizeof(status_age) - 1, "???");
 
1446
                else if(temp_svcstatus->last_check == (time_t)0)
 
1447
                        snprintf(status_age, sizeof(status_age) - 1, "N/A");
1492
1448
                else
1493
 
                        snprintf(status_age,sizeof(status_age)-1,"%2dd %2dh %2dm %2ds",days,hours,minutes,seconds);
1494
 
                status_age[sizeof(status_age)-1]='\x0';
 
1449
                        snprintf(status_age, sizeof(status_age) - 1, "%2dd %2dh %2dm %2ds", days, hours, minutes, seconds);
 
1450
                status_age[sizeof(status_age) - 1] = '\x0';
1495
1451
 
1496
 
                get_time_string(&temp_svcstatus->last_update,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1497
 
                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);
 
1452
                get_time_string(&temp_svcstatus->last_update, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1453
                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);
1498
1454
 
1499
1455
 
1500
1456
                printf("</TABLE>\n");
1509
1465
                printf("<TR><TD class='stateInfoTable2'>\n");
1510
1466
                printf("<TABLE BORDER=0>\n");
1511
1467
 
1512
 
                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");
1513
 
 
1514
 
                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");
1515
 
 
1516
 
                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");
1517
 
 
1518
 
                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");
1519
 
 
1520
 
                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");
1521
 
 
1522
 
                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");
1523
 
 
1524
 
 
1525
 
                printf("</TABLE>\n");
1526
 
                printf("</TD></TR>\n");
1527
 
                printf("</TABLE>\n");
1528
 
 
1529
 
                printf("</TD></TR>\n");
1530
 
 
1531
 
                printf("</TABLE>\n");
1532
 
                }
1533
 
        
 
1468
                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");
 
1469
 
 
1470
                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");
 
1471
 
 
1472
                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");
 
1473
 
 
1474
                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");
 
1475
 
 
1476
                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");
 
1477
 
 
1478
                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");
 
1479
 
 
1480
 
 
1481
                printf("</TABLE>\n");
 
1482
                printf("</TD></TR>\n");
 
1483
                printf("</TABLE>\n");
 
1484
 
 
1485
                printf("</TD></TR>\n");
 
1486
 
 
1487
                printf("</TABLE>\n");
 
1488
                }
 
1489
 
1534
1490
 
1535
1491
        printf("</TD>\n");
1536
1492
 
1544
1500
        printf("<TABLE BORDER='1' CELLSPACING=0 CELLPADDING=0>\n");
1545
1501
        printf("<TR><TD>\n");
1546
1502
 
1547
 
        if(nagios_process_state==STATE_OK &&  is_authorized_for_read_only(&current_authdata)==FALSE){
 
1503
        if(nagios_process_state == STATE_OK &&  is_authorized_for_read_only(&current_authdata) == FALSE) {
1548
1504
                printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
1549
1505
 
1550
 
                if(temp_svcstatus->checks_enabled){
1551
 
 
1552
 
                        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,COMMAND_CGI,CMD_DISABLE_SVC_CHECK,url_encode(host_name));
1553
 
                        printf("&service=%s'>Disable active checks of this service</a></td></tr>\n",url_encode(service_desc));
1554
 
                        }
1555
 
                else{
1556
 
                        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,COMMAND_CGI,CMD_ENABLE_SVC_CHECK,url_encode(host_name));
1557
 
                        printf("&service=%s'>Enable active checks of this service</a></td></tr>\n",url_encode(service_desc));
1558
 
                        }
1559
 
                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,COMMAND_CGI,CMD_SCHEDULE_SVC_CHECK,url_encode(host_name));
1560
 
                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":"");
1561
 
 
1562
 
                if(temp_svcstatus->accept_passive_service_checks==TRUE){
1563
 
                        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,COMMAND_CGI,CMD_PROCESS_SERVICE_CHECK_RESULT,url_encode(host_name));
1564
 
                        printf("&service=%s'>Submit passive check result for this service</a></td></tr>\n",url_encode(service_desc));
1565
 
 
1566
 
                        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,COMMAND_CGI,CMD_DISABLE_PASSIVE_SVC_CHECKS,url_encode(host_name));
1567
 
                        printf("&service=%s'>Stop accepting passive checks for this service</a></td></tr>\n",url_encode(service_desc));
1568
 
                        }
1569
 
                else{
1570
 
                        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,COMMAND_CGI,CMD_ENABLE_PASSIVE_SVC_CHECKS,url_encode(host_name));
1571
 
                        printf("&service=%s'>Start accepting passive checks for this service</a></td></tr>\n",url_encode(service_desc));
1572
 
                        }
1573
 
 
1574
 
                if(temp_svcstatus->obsess_over_service==TRUE){
1575
 
                        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,COMMAND_CGI,CMD_STOP_OBSESSING_OVER_SVC,url_encode(host_name));
1576
 
                        printf("&service=%s'>Stop obsessing over this service</a></td></tr>\n",url_encode(service_desc));
1577
 
                        }
1578
 
                else{
1579
 
                        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,COMMAND_CGI,CMD_START_OBSESSING_OVER_SVC,url_encode(host_name));
1580
 
                        printf("&service=%s'>Start obsessing over this service</a></td></tr>\n",url_encode(service_desc));
1581
 
                        }
1582
 
 
1583
 
                if((temp_svcstatus->status==SERVICE_WARNING || temp_svcstatus->status==SERVICE_UNKNOWN || temp_svcstatus->status==SERVICE_CRITICAL) && temp_svcstatus->state_type==HARD_STATE){
1584
 
                        if(temp_svcstatus->problem_has_been_acknowledged==FALSE){
1585
 
                                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,COMMAND_CGI,CMD_ACKNOWLEDGE_SVC_PROBLEM,url_encode(host_name));
1586
 
                                printf("&service=%s'>Acknowledge this service problem</a></td></tr>\n",url_encode(service_desc));
1587
 
                                }
1588
 
                        else{
1589
 
                                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,COMMAND_CGI,CMD_REMOVE_SVC_ACKNOWLEDGEMENT,url_encode(host_name));
1590
 
                                printf("&service=%s'>Remove problem acknowledgement</a></td></tr>\n",url_encode(service_desc));
1591
 
                                }
1592
 
                        }
1593
 
                if(temp_svcstatus->notifications_enabled==TRUE){
1594
 
                        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,COMMAND_CGI,CMD_DISABLE_SVC_NOTIFICATIONS,url_encode(host_name));
1595
 
                        printf("&service=%s'>Disable notifications for this service</a></td></tr>\n",url_encode(service_desc));
1596
 
                        if(temp_svcstatus->status!=SERVICE_OK){
1597
 
                                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,COMMAND_CGI,CMD_DELAY_SVC_NOTIFICATION,url_encode(host_name));
1598
 
                                printf("&service=%s'>Delay next service notification</a></td></tr>\n",url_encode(service_desc));
1599
 
                                }
1600
 
                        }
1601
 
                else{
1602
 
                        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,COMMAND_CGI,CMD_ENABLE_SVC_NOTIFICATIONS,url_encode(host_name));
1603
 
                        printf("&service=%s'>Enable notifications for this service</a></td></tr>\n",url_encode(service_desc));
1604
 
                        }
1605
 
 
1606
 
                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,COMMAND_CGI,CMD_SEND_CUSTOM_SVC_NOTIFICATION,url_encode(host_name));
1607
 
                printf("&service=%s'>Send custom service notification</a></td></tr>\n",url_encode(service_desc));
1608
 
 
1609
 
                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,COMMAND_CGI,CMD_SCHEDULE_SVC_DOWNTIME,url_encode(host_name));
1610
 
                printf("&service=%s'>Schedule downtime for this service</a></td></tr>\n",url_encode(service_desc));
 
1506
                if(temp_svcstatus->checks_enabled) {
 
1507
 
 
1508
                        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, COMMAND_CGI, CMD_DISABLE_SVC_CHECK, url_encode(host_name));
 
1509
                        printf("&service=%s'>Disable active checks of this service</a></td></tr>\n", url_encode(service_desc));
 
1510
                        }
 
1511
                else {
 
1512
                        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, COMMAND_CGI, CMD_ENABLE_SVC_CHECK, url_encode(host_name));
 
1513
                        printf("&service=%s'>Enable active checks of this service</a></td></tr>\n", url_encode(service_desc));
 
1514
                        }
 
1515
                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, COMMAND_CGI, CMD_SCHEDULE_SVC_CHECK, url_encode(host_name));
 
1516
                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" : "");
 
1517
 
 
1518
                if(temp_svcstatus->accept_passive_service_checks == TRUE) {
 
1519
                        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, COMMAND_CGI, CMD_PROCESS_SERVICE_CHECK_RESULT, url_encode(host_name));
 
1520
                        printf("&service=%s'>Submit passive check result for this service</a></td></tr>\n", url_encode(service_desc));
 
1521
 
 
1522
                        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, COMMAND_CGI, CMD_DISABLE_PASSIVE_SVC_CHECKS, url_encode(host_name));
 
1523
                        printf("&service=%s'>Stop accepting passive checks for this service</a></td></tr>\n", url_encode(service_desc));
 
1524
                        }
 
1525
                else {
 
1526
                        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, COMMAND_CGI, CMD_ENABLE_PASSIVE_SVC_CHECKS, url_encode(host_name));
 
1527
                        printf("&service=%s'>Start accepting passive checks for this service</a></td></tr>\n", url_encode(service_desc));
 
1528
                        }
 
1529
 
 
1530
                if(temp_svcstatus->obsess_over_service == TRUE) {
 
1531
                        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, COMMAND_CGI, CMD_STOP_OBSESSING_OVER_SVC, url_encode(host_name));
 
1532
                        printf("&service=%s'>Stop obsessing over this service</a></td></tr>\n", url_encode(service_desc));
 
1533
                        }
 
1534
                else {
 
1535
                        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, COMMAND_CGI, CMD_START_OBSESSING_OVER_SVC, url_encode(host_name));
 
1536
                        printf("&service=%s'>Start obsessing over this service</a></td></tr>\n", url_encode(service_desc));
 
1537
                        }
 
1538
 
 
1539
                if((temp_svcstatus->status == SERVICE_WARNING || temp_svcstatus->status == SERVICE_UNKNOWN || temp_svcstatus->status == SERVICE_CRITICAL) && temp_svcstatus->state_type == HARD_STATE) {
 
1540
                        if(temp_svcstatus->problem_has_been_acknowledged == FALSE) {
 
1541
                                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, COMMAND_CGI, CMD_ACKNOWLEDGE_SVC_PROBLEM, url_encode(host_name));
 
1542
                                printf("&service=%s'>Acknowledge this service problem</a></td></tr>\n", url_encode(service_desc));
 
1543
                                }
 
1544
                        else {
 
1545
                                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, COMMAND_CGI, CMD_REMOVE_SVC_ACKNOWLEDGEMENT, url_encode(host_name));
 
1546
                                printf("&service=%s'>Remove problem acknowledgement</a></td></tr>\n", url_encode(service_desc));
 
1547
                                }
 
1548
                        }
 
1549
                if(temp_svcstatus->notifications_enabled == TRUE) {
 
1550
                        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, COMMAND_CGI, CMD_DISABLE_SVC_NOTIFICATIONS, url_encode(host_name));
 
1551
                        printf("&service=%s'>Disable notifications for this service</a></td></tr>\n", url_encode(service_desc));
 
1552
                        if(temp_svcstatus->status != SERVICE_OK) {
 
1553
                                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, COMMAND_CGI, CMD_DELAY_SVC_NOTIFICATION, url_encode(host_name));
 
1554
                                printf("&service=%s'>Delay next service notification</a></td></tr>\n", url_encode(service_desc));
 
1555
                                }
 
1556
                        }
 
1557
                else {
 
1558
                        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, COMMAND_CGI, CMD_ENABLE_SVC_NOTIFICATIONS, url_encode(host_name));
 
1559
                        printf("&service=%s'>Enable notifications for this service</a></td></tr>\n", url_encode(service_desc));
 
1560
                        }
 
1561
 
 
1562
                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, COMMAND_CGI, CMD_SEND_CUSTOM_SVC_NOTIFICATION, url_encode(host_name));
 
1563
                printf("&service=%s'>Send custom service notification</a></td></tr>\n", url_encode(service_desc));
 
1564
 
 
1565
                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, COMMAND_CGI, CMD_SCHEDULE_SVC_DOWNTIME, url_encode(host_name));
 
1566
                printf("&service=%s'>Schedule downtime for this service</a></td></tr>\n", url_encode(service_desc));
1611
1567
 
1612
1568
                /*
1613
1569
                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,COMMAND_CGI,CMD_CANCEL_SVC_DOWNTIME,url_encode(host_name));
1614
1570
                printf("&service=%s'>Cancel scheduled downtime for this service</a></td></tr>\n",url_encode(service_desc));
1615
1571
                */
1616
1572
 
1617
 
                if(temp_svcstatus->event_handler_enabled==TRUE){
1618
 
                        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,COMMAND_CGI,CMD_DISABLE_SVC_EVENT_HANDLER,url_encode(host_name));
1619
 
                        printf("&service=%s'>Disable event handler for this service</a></td></tr>\n",url_encode(service_desc));
1620
 
                        }
1621
 
                else{
1622
 
                        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,COMMAND_CGI,CMD_ENABLE_SVC_EVENT_HANDLER,url_encode(host_name));
1623
 
                        printf("&service=%s'>Enable event handler for this service</a></td></tr>\n",url_encode(service_desc));
1624
 
                        }
 
1573
                if(temp_svcstatus->event_handler_enabled == TRUE) {
 
1574
                        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, COMMAND_CGI, CMD_DISABLE_SVC_EVENT_HANDLER, url_encode(host_name));
 
1575
                        printf("&service=%s'>Disable event handler for this service</a></td></tr>\n", url_encode(service_desc));
 
1576
                        }
 
1577
                else {
 
1578
                        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, COMMAND_CGI, CMD_ENABLE_SVC_EVENT_HANDLER, url_encode(host_name));
 
1579
                        printf("&service=%s'>Enable event handler for this service</a></td></tr>\n", url_encode(service_desc));
 
1580
                        }
1625
1581
 
1626
 
                if(temp_svcstatus->flap_detection_enabled==TRUE){
1627
 
                        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,COMMAND_CGI,CMD_DISABLE_SVC_FLAP_DETECTION,url_encode(host_name));
1628
 
                        printf("&service=%s'>Disable flap detection for this service</a></td></tr>\n",url_encode(service_desc));
1629
 
                        }
1630
 
                else{
1631
 
                        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,COMMAND_CGI,CMD_ENABLE_SVC_FLAP_DETECTION,url_encode(host_name));
1632
 
                        printf("&service=%s'>Enable flap detection for this service</a></td></tr>\n",url_encode(service_desc));
1633
 
                        }
 
1582
                if(temp_svcstatus->flap_detection_enabled == TRUE) {
 
1583
                        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, COMMAND_CGI, CMD_DISABLE_SVC_FLAP_DETECTION, url_encode(host_name));
 
1584
                        printf("&service=%s'>Disable flap detection for this service</a></td></tr>\n", url_encode(service_desc));
 
1585
                        }
 
1586
                else {
 
1587
                        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, COMMAND_CGI, CMD_ENABLE_SVC_FLAP_DETECTION, url_encode(host_name));
 
1588
                        printf("&service=%s'>Enable flap detection for this service</a></td></tr>\n", url_encode(service_desc));
 
1589
                        }
1634
1590
 
1635
1591
                printf("</table>\n");
1636
1592
                }
1637
 
        else if (is_authorized_for_read_only(&current_authdata)==TRUE){
1638
 
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to execute commands.<br>\n");
1639
 
                }
1640
 
        else{
 
1593
        else if(is_authorized_for_read_only(&current_authdata) == TRUE) {
 
1594
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to execute commands.<br>\n");
 
1595
                }
 
1596
        else {
1641
1597
                printf("<DIV CLASS='infoMessage'>It appears as though Nagios is not running, so commands are temporarily unavailable...<br>\n");
1642
 
                printf("Click <a href='%s?type=%d'>here</a> to view Nagios process information</DIV>\n",EXTINFO_CGI,DISPLAY_PROCESS_INFO);
1643
 
                }
 
1598
                printf("Click <a href='%s?type=%d'>here</a> to view Nagios process information</DIV>\n", EXTINFO_CGI, DISPLAY_PROCESS_INFO);
 
1599
                }
1644
1600
 
1645
1601
        printf("</td></tr>\n");
1646
1602
        printf("</table>\n");
1655
1611
        printf("<TR>\n");
1656
1612
        printf("<TD COLSPAN=2 ALIGN=CENTER VALIGN=TOP CLASS='commentPanel'>\n");
1657
1613
 
1658
 
        if (is_authorized_for_read_only(&current_authdata)==FALSE) {
 
1614
        if(is_authorized_for_read_only(&current_authdata) == FALSE) {
1659
1615
                /* display comments */
1660
1616
                display_comments(SERVICE_COMMENT);
1661
1617
                }
1671
1627
 
1672
1628
 
1673
1629
 
1674
 
void show_hostgroup_info(void){
 
1630
void show_hostgroup_info(void) {
1675
1631
        hostgroup *temp_hostgroup;
1676
1632
 
1677
1633
 
1678
1634
        /* get hostgroup info */
1679
 
        temp_hostgroup=find_hostgroup(hostgroup_name);
 
1635
        temp_hostgroup = find_hostgroup(hostgroup_name);
1680
1636
 
1681
1637
        /* make sure the user has rights to view hostgroup information */
1682
 
        if(is_authorized_for_hostgroup(temp_hostgroup,&current_authdata)==FALSE){
 
1638
        if(is_authorized_for_hostgroup(temp_hostgroup, &current_authdata) == FALSE) {
1683
1639
 
1684
1640
                printf("<P><DIV CLASS='errorMessage'>It appears as though you do not have permission to view information for this hostgroup...</DIV></P>\n");
1685
1641
                printf("<P><DIV CLASS='errorDescription'>If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI<br>");
1686
1642
                printf("and check the authorization options in your CGI configuration file.</DIV></P>\n");
1687
1643
 
1688
1644
                return;
1689
 
                }
 
1645
                }
1690
1646
 
1691
1647
        /* make sure hostgroup information exists */
1692
 
        if(temp_hostgroup==NULL){
 
1648
        if(temp_hostgroup == NULL) {
1693
1649
                printf("<P><DIV CLASS='errorMessage'>Error: Hostgroup Not Found!</DIV></P>");
1694
1650
                return;
1695
1651
                }
1708
1664
 
1709
1665
        printf("<DIV CLASS='dataTitle'>Hostgroup Commands</DIV>\n");
1710
1666
 
1711
 
        if(nagios_process_state==STATE_OK && is_authorized_for_read_only(&current_authdata)==FALSE){
 
1667
        if(nagios_process_state == STATE_OK && is_authorized_for_read_only(&current_authdata) == FALSE) {
1712
1668
 
1713
1669
                printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
1714
1670
                printf("<TR><TD>\n");
1715
1671
 
1716
1672
                printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
1717
1673
 
1718
 
                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,COMMAND_CGI,CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME,url_encode(hostgroup_name));
1719
 
 
1720
 
                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,COMMAND_CGI,CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME,url_encode(hostgroup_name));
1721
 
 
1722
 
                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,COMMAND_CGI,CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS,url_encode(hostgroup_name));
1723
 
 
1724
 
                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,COMMAND_CGI,CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS,url_encode(hostgroup_name));
1725
 
 
1726
 
                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,COMMAND_CGI,CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS,url_encode(hostgroup_name));
1727
 
 
1728
 
                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,COMMAND_CGI,CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS,url_encode(hostgroup_name));
1729
 
 
1730
 
                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,COMMAND_CGI,CMD_ENABLE_HOSTGROUP_SVC_CHECKS,url_encode(hostgroup_name));
1731
 
 
1732
 
                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,COMMAND_CGI,CMD_DISABLE_HOSTGROUP_SVC_CHECKS,url_encode(hostgroup_name));
 
1674
                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, COMMAND_CGI, CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME, url_encode(hostgroup_name));
 
1675
 
 
1676
                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, COMMAND_CGI, CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME, url_encode(hostgroup_name));
 
1677
 
 
1678
                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, COMMAND_CGI, CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS, url_encode(hostgroup_name));
 
1679
 
 
1680
                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, COMMAND_CGI, CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS, url_encode(hostgroup_name));
 
1681
 
 
1682
                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, COMMAND_CGI, CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS, url_encode(hostgroup_name));
 
1683
 
 
1684
                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, COMMAND_CGI, CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS, url_encode(hostgroup_name));
 
1685
 
 
1686
                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, COMMAND_CGI, CMD_ENABLE_HOSTGROUP_SVC_CHECKS, url_encode(hostgroup_name));
 
1687
 
 
1688
                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, COMMAND_CGI, CMD_DISABLE_HOSTGROUP_SVC_CHECKS, url_encode(hostgroup_name));
1733
1689
 
1734
1690
                printf("</table>\n");
1735
1691
 
1736
1692
                printf("</TD></TR>\n");
1737
1693
                printf("</TABLE>\n");
1738
1694
                }
1739
 
        else if (is_authorized_for_read_only(&current_authdata)==TRUE){
1740
 
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to execute commands.<br>\n");
1741
 
                }
1742
 
        else{
 
1695
        else if(is_authorized_for_read_only(&current_authdata) == TRUE) {
 
1696
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to execute commands.<br>\n");
 
1697
                }
 
1698
        else {
1743
1699
                printf("<DIV CLASS='infoMessage'>It appears as though Nagios is not running, so commands are temporarily unavailable...<br>\n");
1744
 
                printf("Click <a href='%s?type=%d'>here</a> to view Nagios process information</DIV>\n",EXTINFO_CGI,DISPLAY_PROCESS_INFO);
1745
 
                }
 
1700
                printf("Click <a href='%s?type=%d'>here</a> to view Nagios process information</DIV>\n", EXTINFO_CGI, DISPLAY_PROCESS_INFO);
 
1701
                }
1746
1702
 
1747
1703
        printf("</TD></TR>\n");
1748
1704
        printf("<TR>\n");
1767
1723
 
1768
1724
 
1769
1725
 
1770
 
void show_servicegroup_info(){
 
1726
void show_servicegroup_info() {
1771
1727
        servicegroup *temp_servicegroup;
1772
1728
 
1773
1729
 
1774
1730
        /* get servicegroup info */
1775
 
        temp_servicegroup=find_servicegroup(servicegroup_name);
 
1731
        temp_servicegroup = find_servicegroup(servicegroup_name);
1776
1732
 
1777
1733
        /* make sure the user has rights to view servicegroup information */
1778
 
        if(is_authorized_for_servicegroup(temp_servicegroup,&current_authdata)==FALSE){
 
1734
        if(is_authorized_for_servicegroup(temp_servicegroup, &current_authdata) == FALSE) {
1779
1735
 
1780
1736
                printf("<P><DIV CLASS='errorMessage'>It appears as though you do not have permission to view information for this servicegroup...</DIV></P>\n");
1781
1737
                printf("<P><DIV CLASS='errorDescription'>If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI<br>");
1782
1738
                printf("and check the authorization options in your CGI configuration file.</DIV></P>\n");
1783
1739
 
1784
1740
                return;
1785
 
                }
 
1741
                }
1786
1742
 
1787
1743
        /* make sure servicegroup information exists */
1788
 
        if(temp_servicegroup==NULL){
 
1744
        if(temp_servicegroup == NULL) {
1789
1745
                printf("<P><DIV CLASS='errorMessage'>Error: Servicegroup Not Found!</DIV></P>");
1790
1746
                return;
1791
1747
                }
1804
1760
 
1805
1761
        printf("<DIV CLASS='dataTitle'>Servicegroup Commands</DIV>\n");
1806
1762
 
1807
 
        if(nagios_process_state==STATE_OK){
 
1763
        if(nagios_process_state == STATE_OK) {
1808
1764
 
1809
1765
                printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
1810
1766
                printf("<TR><TD>\n");
1811
1767
 
1812
1768
                printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS='command'>\n");
1813
1769
 
1814
 
                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,COMMAND_CGI,CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME,url_encode(servicegroup_name));
1815
 
 
1816
 
                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,COMMAND_CGI,CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME,url_encode(servicegroup_name));
1817
 
 
1818
 
                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,COMMAND_CGI,CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS,url_encode(servicegroup_name));
1819
 
 
1820
 
                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,COMMAND_CGI,CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS,url_encode(servicegroup_name));
1821
 
 
1822
 
                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,COMMAND_CGI,CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS,url_encode(servicegroup_name));
1823
 
 
1824
 
                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,COMMAND_CGI,CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS,url_encode(servicegroup_name));
1825
 
 
1826
 
                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,COMMAND_CGI,CMD_ENABLE_SERVICEGROUP_SVC_CHECKS,url_encode(servicegroup_name));
1827
 
 
1828
 
                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,COMMAND_CGI,CMD_DISABLE_SERVICEGROUP_SVC_CHECKS,url_encode(servicegroup_name));
 
1770
                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, COMMAND_CGI, CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME, url_encode(servicegroup_name));
 
1771
 
 
1772
                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, COMMAND_CGI, CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME, url_encode(servicegroup_name));
 
1773
 
 
1774
                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, COMMAND_CGI, CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS, url_encode(servicegroup_name));
 
1775
 
 
1776
                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, COMMAND_CGI, CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS, url_encode(servicegroup_name));
 
1777
 
 
1778
                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, COMMAND_CGI, CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS, url_encode(servicegroup_name));
 
1779
 
 
1780
                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, COMMAND_CGI, CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS, url_encode(servicegroup_name));
 
1781
 
 
1782
                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, COMMAND_CGI, CMD_ENABLE_SERVICEGROUP_SVC_CHECKS, url_encode(servicegroup_name));
 
1783
 
 
1784
                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, COMMAND_CGI, CMD_DISABLE_SERVICEGROUP_SVC_CHECKS, url_encode(servicegroup_name));
1829
1785
 
1830
1786
                printf("</table>\n");
1831
1787
 
1832
1788
                printf("</TD></TR>\n");
1833
1789
                printf("</TABLE>\n");
1834
 
                }
1835
 
        else{
 
1790
                }
 
1791
        else {
1836
1792
                printf("<DIV CLASS='infoMessage'>It appears as though Nagios is not running, so commands are temporarily unavailable...<br>\n");
1837
 
                printf("Click <a href='%s?type=%d'>here</a> to view Nagios process information</DIV>\n",EXTINFO_CGI,DISPLAY_PROCESS_INFO);
1838
 
                }
 
1793
                printf("Click <a href='%s?type=%d'>here</a> to view Nagios process information</DIV>\n", EXTINFO_CGI, DISPLAY_PROCESS_INFO);
 
1794
                }
1839
1795
 
1840
1796
        printf("</TD></TR>\n");
1841
1797
        printf("<TR>\n");
1854
1810
 
1855
1811
 
1856
1812
        return;
1857
 
        }
 
1813
        }
1858
1814
 
1859
1815
 
1860
1816
 
1861
1817
/* shows all service and host comments */
1862
 
void show_all_comments(void){
1863
 
        int total_comments=0;
1864
 
        char *bg_class="";
1865
 
        int odd=0;
 
1818
void show_all_comments(void) {
 
1819
        int total_comments = 0;
 
1820
        char *bg_class = "";
 
1821
        int odd = 0;
1866
1822
        char date_time[MAX_DATETIME_LENGTH];
1867
1823
        comment *temp_comment;
1868
1824
        host *temp_host;
1871
1827
        char expire_time[MAX_DATETIME_LENGTH];
1872
1828
 
1873
1829
 
1874
 
        if(is_authorized_for_read_only(&current_authdata)==TRUE){
1875
 
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to view comments.<br>\n");
 
1830
        if(is_authorized_for_read_only(&current_authdata) == TRUE) {
 
1831
                printf("<DIV ALIGN=CENTER CLASS='infoMessage'>Your account does not have permissions to view comments.<br>\n");
1876
1832
                return;
1877
1833
                }
1878
1834
 
1884
1840
        printf("<A NAME=HOSTCOMMENTS></A>\n");
1885
1841
        printf("<DIV CLASS='commentTitle'>Host Comments</DIV>\n");
1886
1842
 
1887
 
        printf("<div CLASS='comment'><img src='%s%s' border=0>&nbsp;",url_images_path,COMMENT_ICON);
1888
 
        printf("<a href='%s?cmd_typ=%d'>",COMMAND_CGI,CMD_ADD_HOST_COMMENT);
 
1843
        printf("<div CLASS='comment'><img src='%s%s' border=0>&nbsp;", url_images_path, COMMENT_ICON);
 
1844
        printf("<a href='%s?cmd_typ=%d'>", COMMAND_CGI, CMD_ADD_HOST_COMMENT);
1889
1845
        printf("Add a new host comment</a></div>\n");
1890
1846
 
1891
1847
        printf("<BR />\n");
1894
1850
        printf("<TR CLASS='comment'><TH CLASS='comment'>Host Name</TH><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'>Actions</TH></TR>\n");
1895
1851
 
1896
1852
        /* display all the host comments */
1897
 
        for(temp_comment=comment_list,total_comments=0;temp_comment!=NULL;temp_comment=temp_comment->next){
 
1853
        for(temp_comment = comment_list, total_comments = 0; temp_comment != NULL; temp_comment = temp_comment->next) {
1898
1854
 
1899
 
                if(temp_comment->comment_type!=HOST_COMMENT)
 
1855
                if(temp_comment->comment_type != HOST_COMMENT)
1900
1856
                        continue;
1901
1857
 
1902
 
                temp_host=find_host(temp_comment->host_name);
 
1858
                temp_host = find_host(temp_comment->host_name);
1903
1859
 
1904
1860
                /* make sure the user has rights to view host information */
1905
 
                if(is_authorized_for_host(temp_host,&current_authdata)==FALSE)
 
1861
                if(is_authorized_for_host(temp_host, &current_authdata) == FALSE)
1906
1862
                        continue;
1907
1863
 
1908
1864
                total_comments++;
1909
1865
 
1910
 
                if(odd){
1911
 
                        odd=0;
1912
 
                        bg_class="commentOdd";
1913
 
                        }
1914
 
                else{
1915
 
                        odd=1;
1916
 
                        bg_class="commentEven";
1917
 
                        }
1918
 
 
1919
 
                switch(temp_comment->entry_type){
1920
 
                case USER_COMMENT:
1921
 
                        comment_type="User";
1922
 
                        break;
1923
 
                case DOWNTIME_COMMENT:
1924
 
                        comment_type="Scheduled Downtime";
1925
 
                        break;
1926
 
                case FLAPPING_COMMENT:
1927
 
                        comment_type="Flap Detection";
1928
 
                        break;
1929
 
                case ACKNOWLEDGEMENT_COMMENT:
1930
 
                        comment_type="Acknowledgement";
1931
 
                        break;
1932
 
                default:
1933
 
                        comment_type="?";
1934
 
                        }
1935
 
 
1936
 
                get_time_string(&temp_comment->entry_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1937
 
                get_time_string(&temp_comment->expire_time,expire_time,(int)sizeof(date_time),SHORT_DATE_TIME);
1938
 
                printf("<tr CLASS='%s'>",bg_class);
1939
 
                printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s'>%s</A></td>",bg_class,EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_comment->host_name),temp_comment->host_name);
1940
 
                printf("<td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%ld</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td>",bg_class,date_time,bg_class,temp_comment->author,bg_class,temp_comment->comment_data,bg_class,temp_comment->comment_id,bg_class,(temp_comment->persistent)?"Yes":"No",bg_class,comment_type,bg_class,(temp_comment->expires==TRUE)?expire_time:"N/A");
1941
 
                printf("<td><a href='%s?cmd_typ=%d&com_id=%lu'><img src='%s%s' border=0 ALT='Delete This Comment' TITLE='Delete This Comment'></td>",COMMAND_CGI,CMD_DEL_HOST_COMMENT,temp_comment->comment_id,url_images_path,DELETE_ICON);
 
1866
                if(odd) {
 
1867
                        odd = 0;
 
1868
                        bg_class = "commentOdd";
 
1869
                        }
 
1870
                else {
 
1871
                        odd = 1;
 
1872
                        bg_class = "commentEven";
 
1873
                        }
 
1874
 
 
1875
                switch(temp_comment->entry_type) {
 
1876
                        case USER_COMMENT:
 
1877
                                comment_type = "User";
 
1878
                                break;
 
1879
                        case DOWNTIME_COMMENT:
 
1880
                                comment_type = "Scheduled Downtime";
 
1881
                                break;
 
1882
                        case FLAPPING_COMMENT:
 
1883
                                comment_type = "Flap Detection";
 
1884
                                break;
 
1885
                        case ACKNOWLEDGEMENT_COMMENT:
 
1886
                                comment_type = "Acknowledgement";
 
1887
                                break;
 
1888
                        default:
 
1889
                                comment_type = "?";
 
1890
                        }
 
1891
 
 
1892
                get_time_string(&temp_comment->entry_time, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1893
                get_time_string(&temp_comment->expire_time, expire_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1894
                printf("<tr CLASS='%s'>", bg_class);
 
1895
                printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s'>%s</A></td>", bg_class, EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_comment->host_name), temp_comment->host_name);
 
1896
                printf("<td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%ld</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td>", bg_class, date_time, bg_class, temp_comment->author, bg_class, temp_comment->comment_data, bg_class, temp_comment->comment_id, bg_class, (temp_comment->persistent) ? "Yes" : "No", bg_class, comment_type, bg_class, (temp_comment->expires == TRUE) ? expire_time : "N/A");
 
1897
                printf("<td><a href='%s?cmd_typ=%d&com_id=%lu'><img src='%s%s' border=0 ALT='Delete This Comment' TITLE='Delete This Comment'></td>", COMMAND_CGI, CMD_DEL_HOST_COMMENT, temp_comment->comment_id, url_images_path, DELETE_ICON);
1942
1898
                printf("</tr>\n");
1943
 
                }
 
1899
                }
1944
1900
 
1945
 
        if(total_comments==0)
 
1901
        if(total_comments == 0)
1946
1902
                printf("<TR CLASS='commentOdd'><TD CLASS='commentOdd' COLSPAN=9>There are no host comments</TD></TR>");
1947
1903
 
1948
1904
        printf("</TABLE>\n");
1954
1910
        printf("<A NAME=SERVICECOMMENTS></A>\n");
1955
1911
        printf("<DIV CLASS='commentTitle'>Service Comments</DIV>\n");
1956
1912
 
1957
 
        printf("<div CLASS='comment'><img src='%s%s' border=0>&nbsp;",url_images_path,COMMENT_ICON);
1958
 
        printf("<a href='%s?cmd_typ=%d'>",COMMAND_CGI,CMD_ADD_SVC_COMMENT);
 
1913
        printf("<div CLASS='comment'><img src='%s%s' border=0>&nbsp;", url_images_path, COMMENT_ICON);
 
1914
        printf("<a href='%s?cmd_typ=%d'>", COMMAND_CGI, CMD_ADD_SVC_COMMENT);
1959
1915
        printf("Add a new service comment</a></div>\n");
1960
1916
 
1961
1917
        printf("<BR />\n");
1964
1920
        printf("<TR CLASS='comment'><TH CLASS='comment'>Host Name</TH><TH CLASS='comment'>Service</TH><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'>Actions</TH></TR>\n");
1965
1921
 
1966
1922
        /* display all the service comments */
1967
 
        for(temp_comment=comment_list,total_comments=0;temp_comment!=NULL;temp_comment=temp_comment->next){
 
1923
        for(temp_comment = comment_list, total_comments = 0; temp_comment != NULL; temp_comment = temp_comment->next) {
1968
1924
 
1969
 
                if(temp_comment->comment_type!=SERVICE_COMMENT)
 
1925
                if(temp_comment->comment_type != SERVICE_COMMENT)
1970
1926
                        continue;
1971
1927
 
1972
 
                temp_service=find_service(temp_comment->host_name,temp_comment->service_description);
 
1928
                temp_service = find_service(temp_comment->host_name, temp_comment->service_description);
1973
1929
 
1974
1930
                /* make sure the user has rights to view service information */
1975
 
                if(is_authorized_for_service(temp_service,&current_authdata)==FALSE)
 
1931
                if(is_authorized_for_service(temp_service, &current_authdata) == FALSE)
1976
1932
                        continue;
1977
1933
 
1978
1934
                total_comments++;
1979
1935
 
1980
 
                if(odd){
1981
 
                        odd=0;
1982
 
                        bg_class="commentOdd";
1983
 
                        }
1984
 
                else{
1985
 
                        odd=1;
1986
 
                        bg_class="commentEven";
1987
 
                        }
1988
 
 
1989
 
                switch(temp_comment->entry_type){
1990
 
                case USER_COMMENT:
1991
 
                        comment_type="User";
1992
 
                        break;
1993
 
                case DOWNTIME_COMMENT:
1994
 
                        comment_type="Scheduled Downtime";
1995
 
                        break;
1996
 
                case FLAPPING_COMMENT:
1997
 
                        comment_type="Flap Detection";
1998
 
                        break;
1999
 
                case ACKNOWLEDGEMENT_COMMENT:
2000
 
                        comment_type="Acknowledgement";
2001
 
                        break;
2002
 
                default:
2003
 
                        comment_type="?";
2004
 
                        }
2005
 
 
2006
 
                get_time_string(&temp_comment->entry_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2007
 
                get_time_string(&temp_comment->expire_time,expire_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2008
 
                printf("<tr CLASS='%s'>",bg_class);
2009
 
                printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s'>%s</A></td>",bg_class,EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_comment->host_name),temp_comment->host_name);
2010
 
                printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s",bg_class,EXTINFO_CGI,DISPLAY_SERVICE_INFO,url_encode(temp_comment->host_name));
2011
 
                printf("&service=%s'>%s</A></td>",url_encode(temp_comment->service_description),temp_comment->service_description);
2012
 
                printf("<td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%ld</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td>",bg_class,date_time,bg_class,temp_comment->author,bg_class,temp_comment->comment_data,bg_class,temp_comment->comment_id,bg_class,(temp_comment->persistent)?"Yes":"No",bg_class,comment_type,bg_class,(temp_comment->expires==TRUE)?expire_time:"N/A");
2013
 
                printf("<td><a href='%s?cmd_typ=%d&com_id=%ld'><img src='%s%s' border=0 ALT='Delete This Comment' TITLE='Delete This Comment'></td>",COMMAND_CGI,CMD_DEL_SVC_COMMENT,temp_comment->comment_id,url_images_path,DELETE_ICON);
 
1936
                if(odd) {
 
1937
                        odd = 0;
 
1938
                        bg_class = "commentOdd";
 
1939
                        }
 
1940
                else {
 
1941
                        odd = 1;
 
1942
                        bg_class = "commentEven";
 
1943
                        }
 
1944
 
 
1945
                switch(temp_comment->entry_type) {
 
1946
                        case USER_COMMENT:
 
1947
                                comment_type = "User";
 
1948
                                break;
 
1949
                        case DOWNTIME_COMMENT:
 
1950
                                comment_type = "Scheduled Downtime";
 
1951
                                break;
 
1952
                        case FLAPPING_COMMENT:
 
1953
                                comment_type = "Flap Detection";
 
1954
                                break;
 
1955
                        case ACKNOWLEDGEMENT_COMMENT:
 
1956
                                comment_type = "Acknowledgement";
 
1957
                                break;
 
1958
                        default:
 
1959
                                comment_type = "?";
 
1960
                        }
 
1961
 
 
1962
                get_time_string(&temp_comment->entry_time, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1963
                get_time_string(&temp_comment->expire_time, expire_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
1964
                printf("<tr CLASS='%s'>", bg_class);
 
1965
                printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s'>%s</A></td>", bg_class, EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_comment->host_name), temp_comment->host_name);
 
1966
                printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s", bg_class, EXTINFO_CGI, DISPLAY_SERVICE_INFO, url_encode(temp_comment->host_name));
 
1967
                printf("&service=%s'>%s</A></td>", url_encode(temp_comment->service_description), temp_comment->service_description);
 
1968
                printf("<td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%ld</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td>", bg_class, date_time, bg_class, temp_comment->author, bg_class, temp_comment->comment_data, bg_class, temp_comment->comment_id, bg_class, (temp_comment->persistent) ? "Yes" : "No", bg_class, comment_type, bg_class, (temp_comment->expires == TRUE) ? expire_time : "N/A");
 
1969
                printf("<td><a href='%s?cmd_typ=%d&com_id=%ld'><img src='%s%s' border=0 ALT='Delete This Comment' TITLE='Delete This Comment'></td>", COMMAND_CGI, CMD_DEL_SVC_COMMENT, temp_comment->comment_id, url_images_path, DELETE_ICON);
2014
1970
                printf("</tr>\n");
2015
 
                }
 
1971
                }
2016
1972
 
2017
 
        if(total_comments==0)
 
1973
        if(total_comments == 0)
2018
1974
                printf("<TR CLASS='commentOdd'><TD CLASS='commentOdd' COLSPAN=10>There are no service comments</TD></TR>");
2019
1975
 
2020
1976
        printf("</TABLE>\n");
2021
1977
        printf("</DIV>\n");
2022
1978
 
2023
1979
        return;
2024
 
        }
2025
 
 
2026
 
 
2027
 
 
2028
 
void show_performance_data(void){
2029
 
        service *temp_service=NULL;
2030
 
        servicestatus *temp_servicestatus=NULL;
2031
 
        host *temp_host=NULL;
2032
 
        hoststatus *temp_hoststatus=NULL;
2033
 
        int total_active_service_checks=0;
2034
 
        int total_passive_service_checks=0;
2035
 
        double min_service_execution_time=0.0;
2036
 
        double max_service_execution_time=0.0;
2037
 
        double total_service_execution_time=0.0;
2038
 
        int have_min_service_execution_time=FALSE;
2039
 
        int have_max_service_execution_time=FALSE;
2040
 
        double min_service_latency=0.0;
2041
 
        double max_service_latency=0.0;
2042
 
        double long total_service_latency=0.0;
2043
 
        int have_min_service_latency=FALSE;
2044
 
        int have_max_service_latency=FALSE;
2045
 
        double min_host_latency=0.0;
2046
 
        double max_host_latency=0.0;
2047
 
        double total_host_latency=0.0;
2048
 
        int have_min_host_latency=FALSE;
2049
 
        int have_max_host_latency=FALSE;
2050
 
        double min_service_percent_change_a=0.0;
2051
 
        double max_service_percent_change_a=0.0;
2052
 
        double total_service_percent_change_a=0.0;
2053
 
        int have_min_service_percent_change_a=FALSE;
2054
 
        int have_max_service_percent_change_a=FALSE;
2055
 
        double min_service_percent_change_b=0.0;
2056
 
        double max_service_percent_change_b=0.0;
2057
 
        double total_service_percent_change_b=0.0;
2058
 
        int have_min_service_percent_change_b=FALSE;
2059
 
        int have_max_service_percent_change_b=FALSE;
2060
 
        int active_service_checks_1min=0;
2061
 
        int active_service_checks_5min=0;
2062
 
        int active_service_checks_15min=0;
2063
 
        int active_service_checks_1hour=0;
2064
 
        int active_service_checks_start=0;
2065
 
        int active_service_checks_ever=0;
2066
 
        int passive_service_checks_1min=0;
2067
 
        int passive_service_checks_5min=0;
2068
 
        int passive_service_checks_15min=0;
2069
 
        int passive_service_checks_1hour=0;
2070
 
        int passive_service_checks_start=0;
2071
 
        int passive_service_checks_ever=0;
2072
 
        int total_active_host_checks=0;
2073
 
        int total_passive_host_checks=0;
2074
 
        double min_host_execution_time=0.0;
2075
 
        double max_host_execution_time=0.0;
2076
 
        double total_host_execution_time=0.0;
2077
 
        int have_min_host_execution_time=FALSE;
2078
 
        int have_max_host_execution_time=FALSE;
2079
 
        double min_host_percent_change_a=0.0;
2080
 
        double max_host_percent_change_a=0.0;
2081
 
        double total_host_percent_change_a=0.0;
2082
 
        int have_min_host_percent_change_a=FALSE;
2083
 
        int have_max_host_percent_change_a=FALSE;
2084
 
        double min_host_percent_change_b=0.0;
2085
 
        double max_host_percent_change_b=0.0;
2086
 
        double total_host_percent_change_b=0.0;
2087
 
        int have_min_host_percent_change_b=FALSE;
2088
 
        int have_max_host_percent_change_b=FALSE;
2089
 
        int active_host_checks_1min=0;
2090
 
        int active_host_checks_5min=0;
2091
 
        int active_host_checks_15min=0;
2092
 
        int active_host_checks_1hour=0;
2093
 
        int active_host_checks_start=0;
2094
 
        int active_host_checks_ever=0;
2095
 
        int passive_host_checks_1min=0;
2096
 
        int passive_host_checks_5min=0;
2097
 
        int passive_host_checks_15min=0;
2098
 
        int passive_host_checks_1hour=0;
2099
 
        int passive_host_checks_start=0;
2100
 
        int passive_host_checks_ever=0;
 
1980
        }
 
1981
 
 
1982
 
 
1983
 
 
1984
void show_performance_data(void) {
 
1985
        service *temp_service = NULL;
 
1986
        servicestatus *temp_servicestatus = NULL;
 
1987
        host *temp_host = NULL;
 
1988
        hoststatus *temp_hoststatus = NULL;
 
1989
        int total_active_service_checks = 0;
 
1990
        int total_passive_service_checks = 0;
 
1991
        double min_service_execution_time = 0.0;
 
1992
        double max_service_execution_time = 0.0;
 
1993
        double total_service_execution_time = 0.0;
 
1994
        int have_min_service_execution_time = FALSE;
 
1995
        int have_max_service_execution_time = FALSE;
 
1996
        double min_service_latency = 0.0;
 
1997
        double max_service_latency = 0.0;
 
1998
        double long total_service_latency = 0.0;
 
1999
        int have_min_service_latency = FALSE;
 
2000
        int have_max_service_latency = FALSE;
 
2001
        double min_host_latency = 0.0;
 
2002
        double max_host_latency = 0.0;
 
2003
        double total_host_latency = 0.0;
 
2004
        int have_min_host_latency = FALSE;
 
2005
        int have_max_host_latency = FALSE;
 
2006
        double min_service_percent_change_a = 0.0;
 
2007
        double max_service_percent_change_a = 0.0;
 
2008
        double total_service_percent_change_a = 0.0;
 
2009
        int have_min_service_percent_change_a = FALSE;
 
2010
        int have_max_service_percent_change_a = FALSE;
 
2011
        double min_service_percent_change_b = 0.0;
 
2012
        double max_service_percent_change_b = 0.0;
 
2013
        double total_service_percent_change_b = 0.0;
 
2014
        int have_min_service_percent_change_b = FALSE;
 
2015
        int have_max_service_percent_change_b = FALSE;
 
2016
        int active_service_checks_1min = 0;
 
2017
        int active_service_checks_5min = 0;
 
2018
        int active_service_checks_15min = 0;
 
2019
        int active_service_checks_1hour = 0;
 
2020
        int active_service_checks_start = 0;
 
2021
        int active_service_checks_ever = 0;
 
2022
        int passive_service_checks_1min = 0;
 
2023
        int passive_service_checks_5min = 0;
 
2024
        int passive_service_checks_15min = 0;
 
2025
        int passive_service_checks_1hour = 0;
 
2026
        int passive_service_checks_start = 0;
 
2027
        int passive_service_checks_ever = 0;
 
2028
        int total_active_host_checks = 0;
 
2029
        int total_passive_host_checks = 0;
 
2030
        double min_host_execution_time = 0.0;
 
2031
        double max_host_execution_time = 0.0;
 
2032
        double total_host_execution_time = 0.0;
 
2033
        int have_min_host_execution_time = FALSE;
 
2034
        int have_max_host_execution_time = FALSE;
 
2035
        double min_host_percent_change_a = 0.0;
 
2036
        double max_host_percent_change_a = 0.0;
 
2037
        double total_host_percent_change_a = 0.0;
 
2038
        int have_min_host_percent_change_a = FALSE;
 
2039
        int have_max_host_percent_change_a = FALSE;
 
2040
        double min_host_percent_change_b = 0.0;
 
2041
        double max_host_percent_change_b = 0.0;
 
2042
        double total_host_percent_change_b = 0.0;
 
2043
        int have_min_host_percent_change_b = FALSE;
 
2044
        int have_max_host_percent_change_b = FALSE;
 
2045
        int active_host_checks_1min = 0;
 
2046
        int active_host_checks_5min = 0;
 
2047
        int active_host_checks_15min = 0;
 
2048
        int active_host_checks_1hour = 0;
 
2049
        int active_host_checks_start = 0;
 
2050
        int active_host_checks_ever = 0;
 
2051
        int passive_host_checks_1min = 0;
 
2052
        int passive_host_checks_5min = 0;
 
2053
        int passive_host_checks_15min = 0;
 
2054
        int passive_host_checks_1hour = 0;
 
2055
        int passive_host_checks_start = 0;
 
2056
        int passive_host_checks_ever = 0;
2101
2057
        time_t current_time;
2102
2058
 
2103
2059
 
2104
2060
        time(&current_time);
2105
2061
 
2106
2062
        /* check all services */
2107
 
        for(temp_servicestatus=servicestatus_list;temp_servicestatus!=NULL;temp_servicestatus=temp_servicestatus->next){
 
2063
        for(temp_servicestatus = servicestatus_list; temp_servicestatus != NULL; temp_servicestatus = temp_servicestatus->next) {
2108
2064
 
2109
2065
                /* find the service */
2110
 
                temp_service=find_service(temp_servicestatus->host_name,temp_servicestatus->description);
2111
 
                
 
2066
                temp_service = find_service(temp_servicestatus->host_name, temp_servicestatus->description);
 
2067
 
2112
2068
                /* make sure the user has rights to view service information */
2113
 
                if(is_authorized_for_service(temp_service,&current_authdata)==FALSE)
 
2069
                if(is_authorized_for_service(temp_service, &current_authdata) == FALSE)
2114
2070
                        continue;
2115
2071
 
2116
2072
                /* is this an active or passive check? */
2117
 
                if(temp_servicestatus->check_type==SERVICE_CHECK_ACTIVE){
 
2073
                if(temp_servicestatus->check_type == SERVICE_CHECK_ACTIVE) {
2118
2074
 
2119
2075
                        total_active_service_checks++;
2120
2076
 
2121
 
                        total_service_execution_time+=temp_servicestatus->execution_time;
2122
 
                        if(have_min_service_execution_time==FALSE || temp_servicestatus->execution_time<min_service_execution_time){
2123
 
                                have_min_service_execution_time=TRUE;
2124
 
                                min_service_execution_time=temp_servicestatus->execution_time;
2125
 
                                }
2126
 
                        if(have_max_service_execution_time==FALSE || temp_servicestatus->execution_time>max_service_execution_time){
2127
 
                                have_max_service_execution_time=TRUE;
2128
 
                                max_service_execution_time=temp_servicestatus->execution_time;
2129
 
                                }
2130
 
 
2131
 
                        total_service_percent_change_a+=temp_servicestatus->percent_state_change;
2132
 
                        if(have_min_service_percent_change_a==FALSE || temp_servicestatus->percent_state_change<min_service_percent_change_a){
2133
 
                                have_min_service_percent_change_a=TRUE;
2134
 
                                min_service_percent_change_a=temp_servicestatus->percent_state_change;
2135
 
                                }
2136
 
                        if(have_max_service_percent_change_a==FALSE || temp_servicestatus->percent_state_change>max_service_percent_change_a){
2137
 
                                have_max_service_percent_change_a=TRUE;
2138
 
                                max_service_percent_change_a=temp_servicestatus->percent_state_change;
2139
 
                                }
2140
 
 
2141
 
                        total_service_latency+=temp_servicestatus->latency;
2142
 
                        if(have_min_service_latency==FALSE || temp_servicestatus->latency<min_service_latency){
2143
 
                                have_min_service_latency=TRUE;
2144
 
                                min_service_latency=temp_servicestatus->latency;
2145
 
                                }
2146
 
                        if(have_max_service_latency==FALSE || temp_servicestatus->latency>max_service_latency){
2147
 
                                have_max_service_latency=TRUE;
2148
 
                                max_service_latency=temp_servicestatus->latency;
2149
 
                                }
2150
 
 
2151
 
                        if(temp_servicestatus->last_check>=(current_time-60))
 
2077
                        total_service_execution_time += temp_servicestatus->execution_time;
 
2078
                        if(have_min_service_execution_time == FALSE || temp_servicestatus->execution_time < min_service_execution_time) {
 
2079
                                have_min_service_execution_time = TRUE;
 
2080
                                min_service_execution_time = temp_servicestatus->execution_time;
 
2081
                                }
 
2082
                        if(have_max_service_execution_time == FALSE || temp_servicestatus->execution_time > max_service_execution_time) {
 
2083
                                have_max_service_execution_time = TRUE;
 
2084
                                max_service_execution_time = temp_servicestatus->execution_time;
 
2085
                                }
 
2086
 
 
2087
                        total_service_percent_change_a += temp_servicestatus->percent_state_change;
 
2088
                        if(have_min_service_percent_change_a == FALSE || temp_servicestatus->percent_state_change < min_service_percent_change_a) {
 
2089
                                have_min_service_percent_change_a = TRUE;
 
2090
                                min_service_percent_change_a = temp_servicestatus->percent_state_change;
 
2091
                                }
 
2092
                        if(have_max_service_percent_change_a == FALSE || temp_servicestatus->percent_state_change > max_service_percent_change_a) {
 
2093
                                have_max_service_percent_change_a = TRUE;
 
2094
                                max_service_percent_change_a = temp_servicestatus->percent_state_change;
 
2095
                                }
 
2096
 
 
2097
                        total_service_latency += temp_servicestatus->latency;
 
2098
                        if(have_min_service_latency == FALSE || temp_servicestatus->latency < min_service_latency) {
 
2099
                                have_min_service_latency = TRUE;
 
2100
                                min_service_latency = temp_servicestatus->latency;
 
2101
                                }
 
2102
                        if(have_max_service_latency == FALSE || temp_servicestatus->latency > max_service_latency) {
 
2103
                                have_max_service_latency = TRUE;
 
2104
                                max_service_latency = temp_servicestatus->latency;
 
2105
                                }
 
2106
 
 
2107
                        if(temp_servicestatus->last_check >= (current_time - 60))
2152
2108
                                active_service_checks_1min++;
2153
 
                        if(temp_servicestatus->last_check>=(current_time-300))
 
2109
                        if(temp_servicestatus->last_check >= (current_time - 300))
2154
2110
                                active_service_checks_5min++;
2155
 
                        if(temp_servicestatus->last_check>=(current_time-900))
 
2111
                        if(temp_servicestatus->last_check >= (current_time - 900))
2156
2112
                                active_service_checks_15min++;
2157
 
                        if(temp_servicestatus->last_check>=(current_time-3600))
 
2113
                        if(temp_servicestatus->last_check >= (current_time - 3600))
2158
2114
                                active_service_checks_1hour++;
2159
 
                        if(temp_servicestatus->last_check>=program_start)
 
2115
                        if(temp_servicestatus->last_check >= program_start)
2160
2116
                                active_service_checks_start++;
2161
 
                        if(temp_servicestatus->last_check!=(time_t)0)
 
2117
                        if(temp_servicestatus->last_check != (time_t)0)
2162
2118
                                active_service_checks_ever++;
2163
 
                        }
 
2119
                        }
2164
2120
 
2165
 
                else{
 
2121
                else {
2166
2122
                        total_passive_service_checks++;
2167
2123
 
2168
 
                        total_service_percent_change_b+=temp_servicestatus->percent_state_change;
2169
 
                        if(have_min_service_percent_change_b==FALSE || temp_servicestatus->percent_state_change<min_service_percent_change_b){
2170
 
                                have_min_service_percent_change_b=TRUE;
2171
 
                                min_service_percent_change_b=temp_servicestatus->percent_state_change;
2172
 
                                }
2173
 
                        if(have_max_service_percent_change_b==FALSE || temp_servicestatus->percent_state_change>max_service_percent_change_b){
2174
 
                                have_max_service_percent_change_b=TRUE;
2175
 
                                max_service_percent_change_b=temp_servicestatus->percent_state_change;
2176
 
                                }
 
2124
                        total_service_percent_change_b += temp_servicestatus->percent_state_change;
 
2125
                        if(have_min_service_percent_change_b == FALSE || temp_servicestatus->percent_state_change < min_service_percent_change_b) {
 
2126
                                have_min_service_percent_change_b = TRUE;
 
2127
                                min_service_percent_change_b = temp_servicestatus->percent_state_change;
 
2128
                                }
 
2129
                        if(have_max_service_percent_change_b == FALSE || temp_servicestatus->percent_state_change > max_service_percent_change_b) {
 
2130
                                have_max_service_percent_change_b = TRUE;
 
2131
                                max_service_percent_change_b = temp_servicestatus->percent_state_change;
 
2132
                                }
2177
2133
 
2178
 
                        if(temp_servicestatus->last_check>=(current_time-60))
 
2134
                        if(temp_servicestatus->last_check >= (current_time - 60))
2179
2135
                                passive_service_checks_1min++;
2180
 
                        if(temp_servicestatus->last_check>=(current_time-300))
 
2136
                        if(temp_servicestatus->last_check >= (current_time - 300))
2181
2137
                                passive_service_checks_5min++;
2182
 
                        if(temp_servicestatus->last_check>=(current_time-900))
 
2138
                        if(temp_servicestatus->last_check >= (current_time - 900))
2183
2139
                                passive_service_checks_15min++;
2184
 
                        if(temp_servicestatus->last_check>=(current_time-3600))
 
2140
                        if(temp_servicestatus->last_check >= (current_time - 3600))
2185
2141
                                passive_service_checks_1hour++;
2186
 
                        if(temp_servicestatus->last_check>=program_start)
 
2142
                        if(temp_servicestatus->last_check >= program_start)
2187
2143
                                passive_service_checks_start++;
2188
 
                        if(temp_servicestatus->last_check!=(time_t)0)
 
2144
                        if(temp_servicestatus->last_check != (time_t)0)
2189
2145
                                passive_service_checks_ever++;
2190
 
                        }
2191
 
                }
 
2146
                        }
 
2147
                }
2192
2148
 
2193
2149
        /* check all hosts */
2194
 
        for(temp_hoststatus=hoststatus_list;temp_hoststatus!=NULL;temp_hoststatus=temp_hoststatus->next){
 
2150
        for(temp_hoststatus = hoststatus_list; temp_hoststatus != NULL; temp_hoststatus = temp_hoststatus->next) {
2195
2151
 
2196
2152
                /* find the host */
2197
 
                temp_host=find_host(temp_hoststatus->host_name);
2198
 
                
 
2153
                temp_host = find_host(temp_hoststatus->host_name);
 
2154
 
2199
2155
                /* make sure the user has rights to view host information */
2200
 
                if(is_authorized_for_host(temp_host,&current_authdata)==FALSE)
 
2156
                if(is_authorized_for_host(temp_host, &current_authdata) == FALSE)
2201
2157
                        continue;
2202
2158
 
2203
2159
                /* is this an active or passive check? */
2204
 
                if(temp_hoststatus->check_type==HOST_CHECK_ACTIVE){
 
2160
                if(temp_hoststatus->check_type == HOST_CHECK_ACTIVE) {
2205
2161
 
2206
2162
                        total_active_host_checks++;
2207
2163
 
2208
 
                        total_host_execution_time+=temp_hoststatus->execution_time;
2209
 
                        if(have_min_host_execution_time==FALSE || temp_hoststatus->execution_time<min_host_execution_time){
2210
 
                                have_min_host_execution_time=TRUE;
2211
 
                                min_host_execution_time=temp_hoststatus->execution_time;
2212
 
                                }
2213
 
                        if(have_max_host_execution_time==FALSE || temp_hoststatus->execution_time>max_host_execution_time){
2214
 
                                have_max_host_execution_time=TRUE;
2215
 
                                max_host_execution_time=temp_hoststatus->execution_time;
2216
 
                                }
2217
 
 
2218
 
                        total_host_percent_change_a+=temp_hoststatus->percent_state_change;
2219
 
                        if(have_min_host_percent_change_a==FALSE || temp_hoststatus->percent_state_change<min_host_percent_change_a){
2220
 
                                have_min_host_percent_change_a=TRUE;
2221
 
                                min_host_percent_change_a=temp_hoststatus->percent_state_change;
2222
 
                                }
2223
 
                        if(have_max_host_percent_change_a==FALSE || temp_hoststatus->percent_state_change>max_host_percent_change_a){
2224
 
                                have_max_host_percent_change_a=TRUE;
2225
 
                                max_host_percent_change_a=temp_hoststatus->percent_state_change;
2226
 
                                }
2227
 
 
2228
 
                        total_host_latency+=temp_hoststatus->latency;
2229
 
                        if(have_min_host_latency==FALSE || temp_hoststatus->latency<min_host_latency){
2230
 
                                have_min_host_latency=TRUE;
2231
 
                                min_host_latency=temp_hoststatus->latency;
2232
 
                                }
2233
 
                        if(have_max_host_latency==FALSE || temp_hoststatus->latency>max_host_latency){
2234
 
                                have_max_host_latency=TRUE;
2235
 
                                max_host_latency=temp_hoststatus->latency;
2236
 
                                }
2237
 
 
2238
 
                        if(temp_hoststatus->last_check>=(current_time-60))
 
2164
                        total_host_execution_time += temp_hoststatus->execution_time;
 
2165
                        if(have_min_host_execution_time == FALSE || temp_hoststatus->execution_time < min_host_execution_time) {
 
2166
                                have_min_host_execution_time = TRUE;
 
2167
                                min_host_execution_time = temp_hoststatus->execution_time;
 
2168
                                }
 
2169
                        if(have_max_host_execution_time == FALSE || temp_hoststatus->execution_time > max_host_execution_time) {
 
2170
                                have_max_host_execution_time = TRUE;
 
2171
                                max_host_execution_time = temp_hoststatus->execution_time;
 
2172
                                }
 
2173
 
 
2174
                        total_host_percent_change_a += temp_hoststatus->percent_state_change;
 
2175
                        if(have_min_host_percent_change_a == FALSE || temp_hoststatus->percent_state_change < min_host_percent_change_a) {
 
2176
                                have_min_host_percent_change_a = TRUE;
 
2177
                                min_host_percent_change_a = temp_hoststatus->percent_state_change;
 
2178
                                }
 
2179
                        if(have_max_host_percent_change_a == FALSE || temp_hoststatus->percent_state_change > max_host_percent_change_a) {
 
2180
                                have_max_host_percent_change_a = TRUE;
 
2181
                                max_host_percent_change_a = temp_hoststatus->percent_state_change;
 
2182
                                }
 
2183
 
 
2184
                        total_host_latency += temp_hoststatus->latency;
 
2185
                        if(have_min_host_latency == FALSE || temp_hoststatus->latency < min_host_latency) {
 
2186
                                have_min_host_latency = TRUE;
 
2187
                                min_host_latency = temp_hoststatus->latency;
 
2188
                                }
 
2189
                        if(have_max_host_latency == FALSE || temp_hoststatus->latency > max_host_latency) {
 
2190
                                have_max_host_latency = TRUE;
 
2191
                                max_host_latency = temp_hoststatus->latency;
 
2192
                                }
 
2193
 
 
2194
                        if(temp_hoststatus->last_check >= (current_time - 60))
2239
2195
                                active_host_checks_1min++;
2240
 
                        if(temp_hoststatus->last_check>=(current_time-300))
 
2196
                        if(temp_hoststatus->last_check >= (current_time - 300))
2241
2197
                                active_host_checks_5min++;
2242
 
                        if(temp_hoststatus->last_check>=(current_time-900))
 
2198
                        if(temp_hoststatus->last_check >= (current_time - 900))
2243
2199
                                active_host_checks_15min++;
2244
 
                        if(temp_hoststatus->last_check>=(current_time-3600))
 
2200
                        if(temp_hoststatus->last_check >= (current_time - 3600))
2245
2201
                                active_host_checks_1hour++;
2246
 
                        if(temp_hoststatus->last_check>=program_start)
 
2202
                        if(temp_hoststatus->last_check >= program_start)
2247
2203
                                active_host_checks_start++;
2248
 
                        if(temp_hoststatus->last_check!=(time_t)0)
 
2204
                        if(temp_hoststatus->last_check != (time_t)0)
2249
2205
                                active_host_checks_ever++;
2250
 
                        }
 
2206
                        }
2251
2207
 
2252
 
                else{
 
2208
                else {
2253
2209
                        total_passive_host_checks++;
2254
2210
 
2255
 
                        total_host_percent_change_b+=temp_hoststatus->percent_state_change;
2256
 
                        if(have_min_host_percent_change_b==FALSE || temp_hoststatus->percent_state_change<min_host_percent_change_b){
2257
 
                                have_min_host_percent_change_b=TRUE;
2258
 
                                min_host_percent_change_b=temp_hoststatus->percent_state_change;
2259
 
                                }
2260
 
                        if(have_max_host_percent_change_b==FALSE || temp_hoststatus->percent_state_change>max_host_percent_change_b){
2261
 
                                have_max_host_percent_change_b=TRUE;
2262
 
                                max_host_percent_change_b=temp_hoststatus->percent_state_change;
2263
 
                                }
 
2211
                        total_host_percent_change_b += temp_hoststatus->percent_state_change;
 
2212
                        if(have_min_host_percent_change_b == FALSE || temp_hoststatus->percent_state_change < min_host_percent_change_b) {
 
2213
                                have_min_host_percent_change_b = TRUE;
 
2214
                                min_host_percent_change_b = temp_hoststatus->percent_state_change;
 
2215
                                }
 
2216
                        if(have_max_host_percent_change_b == FALSE || temp_hoststatus->percent_state_change > max_host_percent_change_b) {
 
2217
                                have_max_host_percent_change_b = TRUE;
 
2218
                                max_host_percent_change_b = temp_hoststatus->percent_state_change;
 
2219
                                }
2264
2220
 
2265
 
                        if(temp_hoststatus->last_check>=(current_time-60))
 
2221
                        if(temp_hoststatus->last_check >= (current_time - 60))
2266
2222
                                passive_host_checks_1min++;
2267
 
                        if(temp_hoststatus->last_check>=(current_time-300))
 
2223
                        if(temp_hoststatus->last_check >= (current_time - 300))
2268
2224
                                passive_host_checks_5min++;
2269
 
                        if(temp_hoststatus->last_check>=(current_time-900))
 
2225
                        if(temp_hoststatus->last_check >= (current_time - 900))
2270
2226
                                passive_host_checks_15min++;
2271
 
                        if(temp_hoststatus->last_check>=(current_time-3600))
 
2227
                        if(temp_hoststatus->last_check >= (current_time - 3600))
2272
2228
                                passive_host_checks_1hour++;
2273
 
                        if(temp_hoststatus->last_check>=program_start)
 
2229
                        if(temp_hoststatus->last_check >= program_start)
2274
2230
                                passive_host_checks_start++;
2275
 
                        if(temp_hoststatus->last_check!=(time_t)0)
 
2231
                        if(temp_hoststatus->last_check != (time_t)0)
2276
2232
                                passive_host_checks_ever++;
2277
 
                        }
2278
 
                }
 
2233
                        }
 
2234
                }
2279
2235
 
2280
2236
 
2281
2237
        printf("<div align=center>\n");
2293
2249
        printf("<td valign=top>\n");
2294
2250
 
2295
2251
        /* fake this so we don't divide by zero for just showing the table */
2296
 
        if(total_active_service_checks==0)
2297
 
                total_active_service_checks=1;
 
2252
        if(total_active_service_checks == 0)
 
2253
                total_active_service_checks = 1;
2298
2254
 
2299
2255
        printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
2300
2256
        printf("<TR><TD class='stateInfoTable1'>\n");
2301
2257
        printf("<TABLE BORDER=0>\n");
2302
2258
 
2303
2259
        printf("<tr class='data'><th class='data'>Time Frame</th><th class='data'>Services Checked</th></tr>\n");
2304
 
        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));
2305
 
        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));
2306
 
        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));
2307
 
        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));
2308
 
        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));
 
2260
        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));
 
2261
        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));
 
2262
        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));
 
2263
        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));
 
2264
        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));
2309
2265
 
2310
2266
        printf("</TABLE>\n");
2311
2267
        printf("</TD></TR>\n");
2319
2275
 
2320
2276
        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");
2321
2277
 
2322
 
        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));
2323
 
 
2324
 
        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));
2325
 
 
2326
 
        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));
 
2278
        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));
 
2279
 
 
2280
        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));
 
2281
 
 
2282
        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));
2327
2283
 
2328
2284
        printf("</TABLE>\n");
2329
2285
        printf("</TD></TR>\n");
2339
2295
        printf("<tr>\n");
2340
2296
        printf("<td valign=middle><div class='perfTypeTitle'>Services Passively Checked:</div></td>\n");
2341
2297
        printf("<td valign=top>\n");
2342
 
        
 
2298
 
2343
2299
 
2344
2300
        /* fake this so we don't divide by zero for just showing the table */
2345
 
        if(total_passive_service_checks==0)
2346
 
                total_passive_service_checks=1;
 
2301
        if(total_passive_service_checks == 0)
 
2302
                total_passive_service_checks = 1;
2347
2303
 
2348
2304
        printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
2349
2305
        printf("<TR><TD class='stateInfoTable1'>\n");
2350
2306
        printf("<TABLE BORDER=0>\n");
2351
2307
 
2352
2308
        printf("<tr class='data'><th class='data'>Time Frame</th><th class='data'>Services Checked</th></tr>\n");
2353
 
        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));
2354
 
        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));
2355
 
        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));
2356
 
        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));
2357
 
        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));
 
2309
        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));
 
2310
        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));
 
2311
        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));
 
2312
        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));
 
2313
        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));
2358
2314
 
2359
2315
        printf("</TABLE>\n");
2360
2316
        printf("</TD></TR>\n");
2367
2323
        printf("<TABLE BORDER=0>\n");
2368
2324
 
2369
2325
        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");
2370
 
        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));
 
2326
        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));
2371
2327
 
2372
2328
        printf("</TABLE>\n");
2373
2329
        printf("</TD></TR>\n");
2384
2340
        printf("<td valign=top>\n");
2385
2341
 
2386
2342
        /* fake this so we don't divide by zero for just showing the table */
2387
 
        if(total_active_host_checks==0)
2388
 
                total_active_host_checks=1;
 
2343
        if(total_active_host_checks == 0)
 
2344
                total_active_host_checks = 1;
2389
2345
 
2390
2346
        printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
2391
2347
        printf("<TR><TD class='stateInfoTable1'>\n");
2392
2348
        printf("<TABLE BORDER=0>\n");
2393
2349
 
2394
2350
        printf("<tr class='data'><th class='data'>Time Frame</th><th class='data'>Hosts Checked</th></tr>\n");
2395
 
        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));
2396
 
        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));
2397
 
        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));
2398
 
        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));
2399
 
        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));
 
2351
        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));
 
2352
        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));
 
2353
        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));
 
2354
        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));
 
2355
        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));
2400
2356
 
2401
2357
        printf("</TABLE>\n");
2402
2358
        printf("</TD></TR>\n");
2410
2366
 
2411
2367
        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");
2412
2368
 
2413
 
        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));
2414
 
 
2415
 
        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));
2416
 
 
2417
 
        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));
 
2369
        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));
 
2370
 
 
2371
        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));
 
2372
 
 
2373
        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));
2418
2374
 
2419
2375
        printf("</TABLE>\n");
2420
2376
        printf("</TD></TR>\n");
2430
2386
        printf("<tr>\n");
2431
2387
        printf("<td valign=middle><div class='perfTypeTitle'>Hosts Passively Checked:</div></td>\n");
2432
2388
        printf("<td valign=top>\n");
2433
 
        
 
2389
 
2434
2390
 
2435
2391
        /* fake this so we don't divide by zero for just showing the table */
2436
 
        if(total_passive_host_checks==0)
2437
 
                total_passive_host_checks=1;
 
2392
        if(total_passive_host_checks == 0)
 
2393
                total_passive_host_checks = 1;
2438
2394
 
2439
2395
        printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
2440
2396
        printf("<TR><TD class='stateInfoTable1'>\n");
2441
2397
        printf("<TABLE BORDER=0>\n");
2442
2398
 
2443
2399
        printf("<tr class='data'><th class='data'>Time Frame</th><th class='data'>Hosts Checked</th></tr>\n");
2444
 
        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));
2445
 
        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));
2446
 
        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));
2447
 
        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));
2448
 
        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));
 
2400
        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));
 
2401
        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));
 
2402
        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));
 
2403
        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));
 
2404
        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));
2449
2405
 
2450
2406
        printf("</TABLE>\n");
2451
2407
        printf("</TD></TR>\n");
2458
2414
        printf("<TABLE BORDER=0>\n");
2459
2415
 
2460
2416
        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");
2461
 
        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));
 
2417
        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));
2462
2418
 
2463
2419
        printf("</TABLE>\n");
2464
2420
        printf("</TD></TR>\n");
2474
2430
        printf("<tr>\n");
2475
2431
        printf("<td valign=center><div class='perfTypeTitle'>Check Statistics:</div></td>\n");
2476
2432
        printf("<td valign=top colspan='2'>\n");
2477
 
        
 
2433
 
2478
2434
 
2479
2435
        printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
2480
2436
        printf("<TR><TD class='stateInfoTable1'>\n");
2481
2437
        printf("<TABLE BORDER=0>\n");
2482
2438
 
2483
2439
        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");
2484
 
        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]);
2485
 
        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]);
2486
 
        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]);
2487
 
        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]);
2488
 
        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]);
2489
 
        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]);
2490
 
 
2491
 
        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]);
2492
 
        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]);
2493
 
        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]);
2494
 
        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]);
2495
 
 
2496
 
        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]);
 
2440
        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]);
 
2441
        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]);
 
2442
        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]);
 
2443
        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]);
 
2444
        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]);
 
2445
        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]);
 
2446
 
 
2447
        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]);
 
2448
        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]);
 
2449
        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]);
 
2450
        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]);
 
2451
 
 
2452
        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]);
2497
2453
 
2498
2454
        printf("</TABLE>\n");
2499
2455
        printf("</TD></TR>\n");
2509
2465
        printf("<tr>\n");
2510
2466
        printf("<td valign=center><div class='perfTypeTitle'>Buffer Usage:</div></td>\n");
2511
2467
        printf("<td valign=top colspan='2'>\n");
2512
 
        
 
2468
 
2513
2469
 
2514
2470
        printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>\n");
2515
2471
        printf("<TR><TD class='stateInfoTable1'>\n");
2516
2472
        printf("<TABLE BORDER=0>\n");
2517
2473
 
2518
2474
        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");
2519
 
        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]);
 
2475
        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]);
2520
2476
 
2521
2477
        printf("</TABLE>\n");
2522
2478
        printf("</TD></TR>\n");
2533
2489
        printf("</div>\n");
2534
2490
 
2535
2491
        return;
2536
 
        }
2537
 
 
2538
 
 
2539
 
 
2540
 
void display_comments(int type){
2541
 
        host *temp_host=NULL;
2542
 
        service *temp_service=NULL;
2543
 
        int total_comments=0;
2544
 
        int display_comment=FALSE;
2545
 
        char *bg_class="";
2546
 
        int odd=1;
 
2492
        }
 
2493
 
 
2494
 
 
2495
 
 
2496
void display_comments(int type) {
 
2497
        host *temp_host = NULL;
 
2498
        service *temp_service = NULL;
 
2499
        int total_comments = 0;
 
2500
        int display_comment = FALSE;
 
2501
        char *bg_class = "";
 
2502
        int odd = 1;
2547
2503
        char date_time[MAX_DATETIME_LENGTH];
2548
2504
        comment *temp_comment;
2549
2505
        char *comment_type;
2551
2507
 
2552
2508
 
2553
2509
        /* find the host or service */
2554
 
        if(type==HOST_COMMENT){
2555
 
                temp_host=find_host(host_name);
2556
 
                if(temp_host==NULL)
2557
 
                        return;
2558
 
                }
2559
 
        else{
2560
 
                temp_service=find_service(host_name,service_desc);
2561
 
                if(temp_service==NULL)
2562
 
                        return;
2563
 
                }
 
2510
        if(type == HOST_COMMENT) {
 
2511
                temp_host = find_host(host_name);
 
2512
                if(temp_host == NULL)
 
2513
                        return;
 
2514
                }
 
2515
        else {
 
2516
                temp_service = find_service(host_name, service_desc);
 
2517
                if(temp_service == NULL)
 
2518
                        return;
 
2519
                }
2564
2520
 
2565
2521
 
2566
2522
        printf("<A NAME=comments></A>\n");
2567
 
        printf("<DIV CLASS='commentTitle'>%s Comments</DIV>\n",(type==HOST_COMMENT)?"Host":"Service");
 
2523
        printf("<DIV CLASS='commentTitle'>%s Comments</DIV>\n", (type == HOST_COMMENT) ? "Host" : "Service");
2568
2524
        printf("<TABLE BORDER=0>\n");
2569
2525
 
2570
2526
        printf("<tr>\n");
2571
 
        printf("<td valign=middle><img src='%s%s' border=0 align=center></td><td CLASS='comment'>",url_images_path,COMMENT_ICON);
2572
 
        if(type==HOST_COMMENT)
2573
 
                printf("<a href='%s?cmd_typ=%d&host=%s' CLASS='comment'>",COMMAND_CGI,CMD_ADD_HOST_COMMENT,url_encode(host_name));
2574
 
        else{
2575
 
                printf("<a href='%s?cmd_typ=%d&host=%s&",COMMAND_CGI,CMD_ADD_SVC_COMMENT,url_encode(host_name));
2576
 
                printf("service=%s' CLASS='comment'>",url_encode(service_desc));
2577
 
                }
 
2527
        printf("<td valign=middle><img src='%s%s' border=0 align=center></td><td CLASS='comment'>", url_images_path, COMMENT_ICON);
 
2528
        if(type == HOST_COMMENT)
 
2529
                printf("<a href='%s?cmd_typ=%d&host=%s' CLASS='comment'>", COMMAND_CGI, CMD_ADD_HOST_COMMENT, url_encode(host_name));
 
2530
        else {
 
2531
                printf("<a href='%s?cmd_typ=%d&host=%s&", COMMAND_CGI, CMD_ADD_SVC_COMMENT, url_encode(host_name));
 
2532
                printf("service=%s' CLASS='comment'>", url_encode(service_desc));
 
2533
                }
2578
2534
        printf("Add a new comment</a></td>\n");
2579
2535
 
2580
 
        printf("<td valign=middle><img src='%s%s' border=0 align=center></td><td CLASS='comment'>",url_images_path,DELETE_ICON);
2581
 
        if(type==HOST_COMMENT)
2582
 
                printf("<a href='%s?cmd_typ=%d&host=%s' CLASS='comment'>",COMMAND_CGI,CMD_DEL_ALL_HOST_COMMENTS,url_encode(host_name));
2583
 
        else{
2584
 
                printf("<a href='%s?cmd_typ=%d&host=%s&",COMMAND_CGI,CMD_DEL_ALL_SVC_COMMENTS,url_encode(host_name));
2585
 
                printf("service=%s' CLASS='comment'>",url_encode(service_desc));
2586
 
                }
 
2536
        printf("<td valign=middle><img src='%s%s' border=0 align=center></td><td CLASS='comment'>", url_images_path, DELETE_ICON);
 
2537
        if(type == HOST_COMMENT)
 
2538
                printf("<a href='%s?cmd_typ=%d&host=%s' CLASS='comment'>", COMMAND_CGI, CMD_DEL_ALL_HOST_COMMENTS, url_encode(host_name));
 
2539
        else {
 
2540
                printf("<a href='%s?cmd_typ=%d&host=%s&", COMMAND_CGI, CMD_DEL_ALL_SVC_COMMENTS, url_encode(host_name));
 
2541
                printf("service=%s' CLASS='comment'>", url_encode(service_desc));
 
2542
                }
2587
2543
        printf("Delete all comments</a></td>\n");
2588
2544
        printf("</tr>\n");
2589
2545
 
2597
2553
 
2598
2554
        /* check all the comments to see if they apply to this host or service */
2599
2555
        /* Comments are displayed in the order they are read from the status.dat file */
2600
 
        for(temp_comment=get_first_comment_by_host(host_name);temp_comment!=NULL;temp_comment=get_next_comment_by_host(host_name,temp_comment)){
2601
 
 
2602
 
                display_comment=FALSE;
2603
 
 
2604
 
                if(type==HOST_COMMENT && temp_comment->comment_type==HOST_COMMENT)
2605
 
                        display_comment=TRUE;
2606
 
 
2607
 
                else if(type==SERVICE_COMMENT && temp_comment->comment_type==SERVICE_COMMENT && !strcmp(temp_comment->service_description,service_desc))
2608
 
                        display_comment=TRUE;
2609
 
 
2610
 
                if(display_comment==TRUE){
2611
 
 
2612
 
                        if(odd){
2613
 
                                odd=0;
2614
 
                                bg_class="commentOdd";
2615
 
                                }
2616
 
                        else{
2617
 
                                odd=1;
2618
 
                                bg_class="commentEven";
2619
 
                                }
2620
 
 
2621
 
                        switch(temp_comment->entry_type){
2622
 
                        case USER_COMMENT:
2623
 
                                comment_type="User";
2624
 
                                break;
2625
 
                        case DOWNTIME_COMMENT:
2626
 
                                comment_type="Scheduled Downtime";
2627
 
                                break;
2628
 
                        case FLAPPING_COMMENT:
2629
 
                                comment_type="Flap Detection";
2630
 
                                break;
2631
 
                        case ACKNOWLEDGEMENT_COMMENT:
2632
 
                                comment_type="Acknowledgement";
2633
 
                                break;
2634
 
                        default:
2635
 
                                comment_type="?";
2636
 
                                }
2637
 
 
2638
 
                        get_time_string(&temp_comment->entry_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2639
 
                        get_time_string(&temp_comment->expire_time,expire_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2640
 
                        printf("<tr CLASS='%s'>",bg_class);
2641
 
                        printf("<td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%lu</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td>",bg_class,date_time,bg_class,temp_comment->author,bg_class,temp_comment->comment_data,bg_class,temp_comment->comment_id,bg_class,(temp_comment->persistent)?"Yes":"No",bg_class,comment_type,bg_class,(temp_comment->expires==TRUE)?expire_time:"N/A");
2642
 
                        printf("<td><a href='%s?cmd_typ=%d&com_id=%lu'><img src='%s%s' border=0 ALT='Delete This Comment' TITLE='Delete This Comment'></td>",COMMAND_CGI,(type==HOST_COMMENT)?CMD_DEL_HOST_COMMENT:CMD_DEL_SVC_COMMENT,temp_comment->comment_id,url_images_path,DELETE_ICON);
 
2556
        for(temp_comment = get_first_comment_by_host(host_name); temp_comment != NULL; temp_comment = get_next_comment_by_host(host_name, temp_comment)) {
 
2557
 
 
2558
                display_comment = FALSE;
 
2559
 
 
2560
                if(type == HOST_COMMENT && temp_comment->comment_type == HOST_COMMENT)
 
2561
                        display_comment = TRUE;
 
2562
 
 
2563
                else if(type == SERVICE_COMMENT && temp_comment->comment_type == SERVICE_COMMENT && !strcmp(temp_comment->service_description, service_desc))
 
2564
                        display_comment = TRUE;
 
2565
 
 
2566
                if(display_comment == TRUE) {
 
2567
 
 
2568
                        if(odd) {
 
2569
                                odd = 0;
 
2570
                                bg_class = "commentOdd";
 
2571
                                }
 
2572
                        else {
 
2573
                                odd = 1;
 
2574
                                bg_class = "commentEven";
 
2575
                                }
 
2576
 
 
2577
                        switch(temp_comment->entry_type) {
 
2578
                                case USER_COMMENT:
 
2579
                                        comment_type = "User";
 
2580
                                        break;
 
2581
                                case DOWNTIME_COMMENT:
 
2582
                                        comment_type = "Scheduled Downtime";
 
2583
                                        break;
 
2584
                                case FLAPPING_COMMENT:
 
2585
                                        comment_type = "Flap Detection";
 
2586
                                        break;
 
2587
                                case ACKNOWLEDGEMENT_COMMENT:
 
2588
                                        comment_type = "Acknowledgement";
 
2589
                                        break;
 
2590
                                default:
 
2591
                                        comment_type = "?";
 
2592
                                }
 
2593
 
 
2594
                        get_time_string(&temp_comment->entry_time, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2595
                        get_time_string(&temp_comment->expire_time, expire_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2596
                        printf("<tr CLASS='%s'>", bg_class);
 
2597
                        printf("<td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%lu</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td><td CLASS='%s'>%s</td>", bg_class, date_time, bg_class, temp_comment->author, bg_class, temp_comment->comment_data, bg_class, temp_comment->comment_id, bg_class, (temp_comment->persistent) ? "Yes" : "No", bg_class, comment_type, bg_class, (temp_comment->expires == TRUE) ? expire_time : "N/A");
 
2598
                        printf("<td><a href='%s?cmd_typ=%d&com_id=%lu'><img src='%s%s' border=0 ALT='Delete This Comment' TITLE='Delete This Comment'></td>", COMMAND_CGI, (type == HOST_COMMENT) ? CMD_DEL_HOST_COMMENT : CMD_DEL_SVC_COMMENT, temp_comment->comment_id, url_images_path, DELETE_ICON);
2643
2599
                        printf("</tr>\n");
2644
2600
 
2645
2601
                        total_comments++;
2646
2602
                        }
2647
 
                }
 
2603
                }
2648
2604
 
2649
2605
        /* see if this host or service has any comments associated with it */
2650
 
        if(total_comments==0)
2651
 
                printf("<TR CLASS='commentOdd'><TD CLASS='commentOdd' COLSPAN='%d'>This %s has no comments associated with it</TD></TR>",(type==HOST_COMMENT)?9:10,(type==HOST_COMMENT)?"host":"service");
 
2606
        if(total_comments == 0)
 
2607
                printf("<TR CLASS='commentOdd'><TD CLASS='commentOdd' COLSPAN='%d'>This %s has no comments associated with it</TD></TR>", (type == HOST_COMMENT) ? 9 : 10, (type == HOST_COMMENT) ? "host" : "service");
2652
2608
 
2653
2609
        printf("</TABLE></DIV>\n");
2654
2610
 
2655
2611
        return;
2656
 
        }
 
2612
        }
2657
2613
 
2658
2614
 
2659
2615
 
2660
2616
 
2661
2617
/* shows all service and host scheduled downtime */
2662
 
void show_all_downtime(void){
2663
 
        int total_downtime=0;
2664
 
        char *bg_class="";
2665
 
        int odd=0;
 
2618
void show_all_downtime(void) {
 
2619
        int total_downtime = 0;
 
2620
        char *bg_class = "";
 
2621
        int odd = 0;
2666
2622
        char date_time[MAX_DATETIME_LENGTH];
2667
2623
        scheduled_downtime *temp_downtime;
2668
2624
        host *temp_host;
2680
2636
        printf("<A NAME=HOSTDOWNTIME></A>\n");
2681
2637
        printf("<DIV CLASS='downtimeTitle'>Scheduled Host Downtime</DIV>\n");
2682
2638
 
2683
 
        printf("<div CLASS='comment'><img src='%s%s' border=0>&nbsp;",url_images_path,DOWNTIME_ICON);
2684
 
        printf("<a href='%s?cmd_typ=%d'>",COMMAND_CGI,CMD_SCHEDULE_HOST_DOWNTIME);
 
2639
        printf("<div CLASS='comment'><img src='%s%s' border=0>&nbsp;", url_images_path, DOWNTIME_ICON);
 
2640
        printf("<a href='%s?cmd_typ=%d'>", COMMAND_CGI, CMD_SCHEDULE_HOST_DOWNTIME);
2685
2641
        printf("Schedule host downtime</a></div>\n");
2686
2642
 
2687
2643
        printf("<BR />\n");
2690
2646
        printf("<TR CLASS='downtime'><TH CLASS='downtime'>Host Name</TH><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='downtime'>Actions</TH></TR>\n");
2691
2647
 
2692
2648
        /* display all the host downtime */
2693
 
        for(temp_downtime=scheduled_downtime_list,total_downtime=0;temp_downtime!=NULL;temp_downtime=temp_downtime->next){
 
2649
        for(temp_downtime = scheduled_downtime_list, total_downtime = 0; temp_downtime != NULL; temp_downtime = temp_downtime->next) {
2694
2650
 
2695
 
                if(temp_downtime->type!=HOST_DOWNTIME)
 
2651
                if(temp_downtime->type != HOST_DOWNTIME)
2696
2652
                        continue;
2697
2653
 
2698
 
                temp_host=find_host(temp_downtime->host_name);
 
2654
                temp_host = find_host(temp_downtime->host_name);
2699
2655
 
2700
2656
                /* make sure the user has rights to view host information */
2701
 
                if(is_authorized_for_host(temp_host,&current_authdata)==FALSE)
 
2657
                if(is_authorized_for_host(temp_host, &current_authdata) == FALSE)
2702
2658
                        continue;
2703
2659
 
2704
2660
                total_downtime++;
2705
2661
 
2706
 
                if(odd){
2707
 
                        odd=0;
2708
 
                        bg_class="downtimeOdd";
2709
 
                        }
2710
 
                else{
2711
 
                        odd=1;
2712
 
                        bg_class="downtimeEven";
2713
 
                        }
 
2662
                if(odd) {
 
2663
                        odd = 0;
 
2664
                        bg_class = "downtimeOdd";
 
2665
                        }
 
2666
                else {
 
2667
                        odd = 1;
 
2668
                        bg_class = "downtimeEven";
 
2669
                        }
2714
2670
 
2715
 
                printf("<tr CLASS='%s'>",bg_class);
2716
 
                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_downtime->host_name);
2717
 
                get_time_string(&temp_downtime->entry_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2718
 
                printf("<td CLASS='%s'>%s</td>",bg_class,date_time);
2719
 
                printf("<td CLASS='%s'>%s</td>",bg_class,(temp_downtime->author==NULL)?"N/A":temp_downtime->author);
2720
 
                printf("<td CLASS='%s'>%s</td>",bg_class,(temp_downtime->comment==NULL)?"N/A":temp_downtime->comment);
2721
 
                get_time_string(&temp_downtime->start_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2722
 
                printf("<td CLASS='%s'>%s</td>",bg_class,date_time);
2723
 
                get_time_string(&temp_downtime->end_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2724
 
                printf("<td CLASS='%s'>%s</td>",bg_class,date_time);
2725
 
                printf("<td CLASS='%s'>%s</td>",bg_class,(temp_downtime->fixed==TRUE)?"Fixed":"Flexible");
2726
 
                get_time_breakdown(temp_downtime->duration,&days,&hours,&minutes,&seconds);
2727
 
                printf("<td CLASS='%s'>%dd %dh %dm %ds</td>",bg_class,days,hours,minutes,seconds);
2728
 
                printf("<td CLASS='%s'>%lu</td>",bg_class,temp_downtime->downtime_id);
2729
 
                printf("<td CLASS='%s'>",bg_class);
2730
 
                if(temp_downtime->triggered_by==0)
 
2671
                printf("<tr CLASS='%s'>", bg_class);
 
2672
                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_downtime->host_name);
 
2673
                get_time_string(&temp_downtime->entry_time, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2674
                printf("<td CLASS='%s'>%s</td>", bg_class, date_time);
 
2675
                printf("<td CLASS='%s'>%s</td>", bg_class, (temp_downtime->author == NULL) ? "N/A" : temp_downtime->author);
 
2676
                printf("<td CLASS='%s'>%s</td>", bg_class, (temp_downtime->comment == NULL) ? "N/A" : temp_downtime->comment);
 
2677
                get_time_string(&temp_downtime->start_time, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2678
                printf("<td CLASS='%s'>%s</td>", bg_class, date_time);
 
2679
                get_time_string(&temp_downtime->end_time, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2680
                printf("<td CLASS='%s'>%s</td>", bg_class, date_time);
 
2681
                printf("<td CLASS='%s'>%s</td>", bg_class, (temp_downtime->fixed == TRUE) ? "Fixed" : "Flexible");
 
2682
                get_time_breakdown(temp_downtime->duration, &days, &hours, &minutes, &seconds);
 
2683
                printf("<td CLASS='%s'>%dd %dh %dm %ds</td>", bg_class, days, hours, minutes, seconds);
 
2684
                printf("<td CLASS='%s'>%lu</td>", bg_class, temp_downtime->downtime_id);
 
2685
                printf("<td CLASS='%s'>", bg_class);
 
2686
                if(temp_downtime->triggered_by == 0)
2731
2687
                        printf("N/A");
2732
2688
                else
2733
 
                        printf("%lu",temp_downtime->triggered_by);
 
2689
                        printf("%lu", temp_downtime->triggered_by);
2734
2690
                printf("</td>\n");
2735
 
                printf("<td><a href='%s?cmd_typ=%d&down_id=%lu'><img src='%s%s' border=0 ALT='Delete/Cancel This Scheduled Downtime Entry' TITLE='Delete/Cancel This Scheduled Downtime Entry'></td>",COMMAND_CGI,CMD_DEL_HOST_DOWNTIME,temp_downtime->downtime_id,url_images_path,DELETE_ICON);
 
2691
                printf("<td><a href='%s?cmd_typ=%d&down_id=%lu'><img src='%s%s' border=0 ALT='Delete/Cancel This Scheduled Downtime Entry' TITLE='Delete/Cancel This Scheduled Downtime Entry'></td>", COMMAND_CGI, CMD_DEL_HOST_DOWNTIME, temp_downtime->downtime_id, url_images_path, DELETE_ICON);
2736
2692
                printf("</tr>\n");
2737
 
                }
 
2693
                }
2738
2694
 
2739
 
        if(total_downtime==0)
 
2695
        if(total_downtime == 0)
2740
2696
                printf("<TR CLASS='downtimeOdd'><TD CLASS='downtimeOdd' COLSPAN=11>There are no hosts with scheduled downtime</TD></TR>");
2741
2697
 
2742
2698
        printf("</TABLE>\n");
2748
2704
        printf("<A NAME=SERVICEDOWNTIME></A>\n");
2749
2705
        printf("<DIV CLASS='downtimeTitle'>Scheduled Service Downtime</DIV>\n");
2750
2706
 
2751
 
        printf("<div CLASS='comment'><img src='%s%s' border=0>&nbsp;",url_images_path,DOWNTIME_ICON);
2752
 
        printf("<a href='%s?cmd_typ=%d'>",COMMAND_CGI,CMD_SCHEDULE_SVC_DOWNTIME);
 
2707
        printf("<div CLASS='comment'><img src='%s%s' border=0>&nbsp;", url_images_path, DOWNTIME_ICON);
 
2708
        printf("<a href='%s?cmd_typ=%d'>", COMMAND_CGI, CMD_SCHEDULE_SVC_DOWNTIME);
2753
2709
        printf("Schedule service downtime</a></div>\n");
2754
2710
 
2755
2711
        printf("<BR />\n");
2758
2714
        printf("<TR CLASS='downtime'><TH CLASS='downtime'>Host Name</TH><TH CLASS='downtime'>Service</TH><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='downtime'>Actions</TH></TR>\n");
2759
2715
 
2760
2716
        /* display all the service downtime */
2761
 
        for(temp_downtime=scheduled_downtime_list,total_downtime=0;temp_downtime!=NULL;temp_downtime=temp_downtime->next){
 
2717
        for(temp_downtime = scheduled_downtime_list, total_downtime = 0; temp_downtime != NULL; temp_downtime = temp_downtime->next) {
2762
2718
 
2763
 
                if(temp_downtime->type!=SERVICE_DOWNTIME)
 
2719
                if(temp_downtime->type != SERVICE_DOWNTIME)
2764
2720
                        continue;
2765
2721
 
2766
 
                temp_service=find_service(temp_downtime->host_name,temp_downtime->service_description);
 
2722
                temp_service = find_service(temp_downtime->host_name, temp_downtime->service_description);
2767
2723
 
2768
2724
                /* make sure the user has rights to view service information */
2769
 
                if(is_authorized_for_service(temp_service,&current_authdata)==FALSE)
 
2725
                if(is_authorized_for_service(temp_service, &current_authdata) == FALSE)
2770
2726
                        continue;
2771
2727
 
2772
2728
                total_downtime++;
2773
2729
 
2774
 
                if(odd){
2775
 
                        odd=0;
2776
 
                        bg_class="downtimeOdd";
2777
 
                        }
2778
 
                else{
2779
 
                        odd=1;
2780
 
                        bg_class="downtimeEven";
2781
 
                        }
 
2730
                if(odd) {
 
2731
                        odd = 0;
 
2732
                        bg_class = "downtimeOdd";
 
2733
                        }
 
2734
                else {
 
2735
                        odd = 1;
 
2736
                        bg_class = "downtimeEven";
 
2737
                        }
2782
2738
 
2783
 
                printf("<tr CLASS='%s'>",bg_class);
2784
 
                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_downtime->host_name);
2785
 
                printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s",bg_class,EXTINFO_CGI,DISPLAY_SERVICE_INFO,url_encode(temp_downtime->host_name));
2786
 
                printf("&service=%s'>%s</A></td>",url_encode(temp_downtime->service_description),temp_downtime->service_description);
2787
 
                get_time_string(&temp_downtime->entry_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2788
 
                printf("<td CLASS='%s'>%s</td>",bg_class,date_time);
2789
 
                printf("<td CLASS='%s'>%s</td>",bg_class,(temp_downtime->author==NULL)?"N/A":temp_downtime->author);
2790
 
                printf("<td CLASS='%s'>%s</td>",bg_class,(temp_downtime->comment==NULL)?"N/A":temp_downtime->comment);
2791
 
                get_time_string(&temp_downtime->start_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2792
 
                printf("<td CLASS='%s'>%s</td>",bg_class,date_time);
2793
 
                get_time_string(&temp_downtime->end_time,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2794
 
                printf("<td CLASS='%s'>%s</td>",bg_class,date_time);
2795
 
                printf("<td CLASS='%s'>%s</td>",bg_class,(temp_downtime->fixed==TRUE)?"Fixed":"Flexible");
2796
 
                get_time_breakdown(temp_downtime->duration,&days,&hours,&minutes,&seconds);
2797
 
                printf("<td CLASS='%s'>%dd %dh %dm %ds</td>",bg_class,days,hours,minutes,seconds);
2798
 
                printf("<td CLASS='%s'>%lu</td>",bg_class,temp_downtime->downtime_id);
2799
 
                printf("<td CLASS='%s'>",bg_class);
2800
 
                if(temp_downtime->triggered_by==0)
 
2739
                printf("<tr CLASS='%s'>", bg_class);
 
2740
                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_downtime->host_name);
 
2741
                printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s", bg_class, EXTINFO_CGI, DISPLAY_SERVICE_INFO, url_encode(temp_downtime->host_name));
 
2742
                printf("&service=%s'>%s</A></td>", url_encode(temp_downtime->service_description), temp_downtime->service_description);
 
2743
                get_time_string(&temp_downtime->entry_time, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2744
                printf("<td CLASS='%s'>%s</td>", bg_class, date_time);
 
2745
                printf("<td CLASS='%s'>%s</td>", bg_class, (temp_downtime->author == NULL) ? "N/A" : temp_downtime->author);
 
2746
                printf("<td CLASS='%s'>%s</td>", bg_class, (temp_downtime->comment == NULL) ? "N/A" : temp_downtime->comment);
 
2747
                get_time_string(&temp_downtime->start_time, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2748
                printf("<td CLASS='%s'>%s</td>", bg_class, date_time);
 
2749
                get_time_string(&temp_downtime->end_time, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2750
                printf("<td CLASS='%s'>%s</td>", bg_class, date_time);
 
2751
                printf("<td CLASS='%s'>%s</td>", bg_class, (temp_downtime->fixed == TRUE) ? "Fixed" : "Flexible");
 
2752
                get_time_breakdown(temp_downtime->duration, &days, &hours, &minutes, &seconds);
 
2753
                printf("<td CLASS='%s'>%dd %dh %dm %ds</td>", bg_class, days, hours, minutes, seconds);
 
2754
                printf("<td CLASS='%s'>%lu</td>", bg_class, temp_downtime->downtime_id);
 
2755
                printf("<td CLASS='%s'>", bg_class);
 
2756
                if(temp_downtime->triggered_by == 0)
2801
2757
                        printf("N/A");
2802
2758
                else
2803
 
                        printf("%lu",temp_downtime->triggered_by);
 
2759
                        printf("%lu", temp_downtime->triggered_by);
2804
2760
                printf("</td>\n");
2805
 
                printf("<td><a href='%s?cmd_typ=%d&down_id=%lu'><img src='%s%s' border=0 ALT='Delete/Cancel This Scheduled Downtime Entry' TITLE='Delete/Cancel This Scheduled Downtime Entry'></td>",COMMAND_CGI,CMD_DEL_SVC_DOWNTIME,temp_downtime->downtime_id,url_images_path,DELETE_ICON);
 
2761
                printf("<td><a href='%s?cmd_typ=%d&down_id=%lu'><img src='%s%s' border=0 ALT='Delete/Cancel This Scheduled Downtime Entry' TITLE='Delete/Cancel This Scheduled Downtime Entry'></td>", COMMAND_CGI, CMD_DEL_SVC_DOWNTIME, temp_downtime->downtime_id, url_images_path, DELETE_ICON);
2806
2762
                printf("</tr>\n");
2807
 
                }
 
2763
                }
2808
2764
 
2809
 
        if(total_downtime==0)
 
2765
        if(total_downtime == 0)
2810
2766
                printf("<TR CLASS='downtimeOdd'><TD CLASS='downtimeOdd' COLSPAN=12>There are no services with scheduled downtime</TD></TR>");
2811
2767
 
2812
2768
        printf("</TABLE>\n");
2813
2769
        printf("</DIV>\n");
2814
2770
 
2815
2771
        return;
2816
 
        }
 
2772
        }
2817
2773
 
2818
2774
 
2819
2775
 
2820
2776
/* shows check scheduling queue */
2821
 
void show_scheduling_queue(void){
 
2777
void show_scheduling_queue(void) {
2822
2778
        sortdata *temp_sortdata;
2823
 
        servicestatus *temp_svcstatus=NULL;
2824
 
        hoststatus *temp_hststatus=NULL;
 
2779
        servicestatus *temp_svcstatus = NULL;
 
2780
        hoststatus *temp_hststatus = NULL;
2825
2781
        char date_time[MAX_DATETIME_LENGTH];
2826
2782
        char temp_url[MAX_INPUT_BUFFER];
2827
 
        int odd=0;
2828
 
        char *bgclass="";
 
2783
        int odd = 0;
 
2784
        char *bgclass = "";
2829
2785
 
2830
2786
 
2831
2787
        /* make sure the user has rights to view system information */
2832
 
        if(is_authorized_for_system_information(&current_authdata)==FALSE){
 
2788
        if(is_authorized_for_system_information(&current_authdata) == FALSE) {
2833
2789
 
2834
2790
                printf("<P><DIV CLASS='errorMessage'>It appears as though you do not have permission to view process information...</DIV></P>\n");
2835
2791
                printf("<P><DIV CLASS='errorDescription'>If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI<br>");
2836
2792
                printf("and check the authorization options in your CGI configuration file.</DIV></P>\n");
2837
2793
 
2838
2794
                return;
2839
 
                }
 
2795
                }
2840
2796
 
2841
2797
        /* sort hosts and services */
2842
 
        sort_data(sort_type,sort_option);
 
2798
        sort_data(sort_type, sort_option);
2843
2799
 
2844
2800
        printf("<DIV ALIGN=CENTER CLASS='statusSort'>Entries sorted by <b>");
2845
 
        if(sort_option==SORT_HOSTNAME)
 
2801
        if(sort_option == SORT_HOSTNAME)
2846
2802
                printf("host name");
2847
 
        else if(sort_option==SORT_SERVICENAME)
 
2803
        else if(sort_option == SORT_SERVICENAME)
2848
2804
                printf("service name");
2849
 
        else if(sort_option==SORT_SERVICESTATUS)
 
2805
        else if(sort_option == SORT_SERVICESTATUS)
2850
2806
                printf("service status");
2851
 
        else if(sort_option==SORT_LASTCHECKTIME)
 
2807
        else if(sort_option == SORT_LASTCHECKTIME)
2852
2808
                printf("last check time");
2853
 
        else if(sort_option==SORT_NEXTCHECKTIME)
 
2809
        else if(sort_option == SORT_NEXTCHECKTIME)
2854
2810
                printf("next check time");
2855
 
        printf("</b> (%s)\n",(sort_type==SORT_ASCENDING)?"ascending":"descending");
 
2811
        printf("</b> (%s)\n", (sort_type == SORT_ASCENDING) ? "ascending" : "descending");
2856
2812
        printf("</DIV>\n");
2857
2813
 
2858
2814
        printf("<P>\n");
2860
2816
        printf("<TABLE BORDER=0 CLASS='queue'>\n");
2861
2817
        printf("<TR CLASS='queue'>");
2862
2818
 
2863
 
        snprintf(temp_url,sizeof(temp_url)-1,"%s?type=%d",EXTINFO_CGI,DISPLAY_SCHEDULING_QUEUE);
2864
 
        temp_url[sizeof(temp_url)-1]='\x0';
2865
 
 
2866
 
        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);
2867
 
 
2868
 
        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);
2869
 
 
2870
 
        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);
2871
 
 
2872
 
        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);
 
2819
        snprintf(temp_url, sizeof(temp_url) - 1, "%s?type=%d", EXTINFO_CGI, DISPLAY_SCHEDULING_QUEUE);
 
2820
        temp_url[sizeof(temp_url) - 1] = '\x0';
 
2821
 
 
2822
        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);
 
2823
 
 
2824
        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);
 
2825
 
 
2826
        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);
 
2827
 
 
2828
        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);
2873
2829
 
2874
2830
 
2875
2831
        printf("<TH CLASS='queue'>Type</TH><TH CLASS='queue'>Active Checks</TH><TH CLASS='queue'>Actions</TH></TR>\n");
2876
2832
 
2877
2833
 
2878
2834
        /* display all services and hosts */
2879
 
        for(temp_sortdata=sortdata_list;temp_sortdata!=NULL;temp_sortdata=temp_sortdata->next){
 
2835
        for(temp_sortdata = sortdata_list; temp_sortdata != NULL; temp_sortdata = temp_sortdata->next) {
2880
2836
 
2881
2837
                /* skip hosts and services that shouldn't be scheduled */
2882
 
                if(temp_sortdata->is_service==TRUE){
2883
 
                        temp_svcstatus=temp_sortdata->svcstatus;
2884
 
                        if(temp_svcstatus->should_be_scheduled==FALSE){
2885
 
                                /* passive-only checks should appear if they're being forced */
2886
 
                                if(!(temp_svcstatus->checks_enabled==FALSE && temp_svcstatus->next_check!=(time_t)0L && (temp_svcstatus->check_options & CHECK_OPTION_FORCE_EXECUTION)))
2887
 
                                        continue;
2888
 
                                }
2889
 
                        }
2890
 
                else{
2891
 
                        temp_hststatus=temp_sortdata->hststatus;
2892
 
                        if(temp_hststatus->should_be_scheduled==FALSE){
2893
 
                                /* passive-only checks should appear if they're being forced */
2894
 
                                if(!(temp_hststatus->checks_enabled==FALSE && temp_hststatus->next_check!=(time_t)0L && (temp_hststatus->check_options & CHECK_OPTION_FORCE_EXECUTION)))
2895
 
                                        continue;
2896
 
                                }
2897
 
                        }
2898
 
                
2899
 
                if(odd){
2900
 
                        odd=0;
2901
 
                        bgclass="Even";
2902
 
                        }
2903
 
                else{
2904
 
                        odd=1;
2905
 
                        bgclass="Odd";
2906
 
                        }
2907
 
 
2908
 
                printf("<TR CLASS='queue%s'>",bgclass);
 
2838
                if(temp_sortdata->is_service == TRUE) {
 
2839
                        temp_svcstatus = temp_sortdata->svcstatus;
 
2840
                        if(temp_svcstatus->should_be_scheduled == FALSE) {
 
2841
                                /* passive-only checks should appear if they're being forced */
 
2842
                                if(!(temp_svcstatus->checks_enabled == FALSE && temp_svcstatus->next_check != (time_t)0L && (temp_svcstatus->check_options & CHECK_OPTION_FORCE_EXECUTION)))
 
2843
                                        continue;
 
2844
                                }
 
2845
                        }
 
2846
                else {
 
2847
                        temp_hststatus = temp_sortdata->hststatus;
 
2848
                        if(temp_hststatus->should_be_scheduled == FALSE) {
 
2849
                                /* passive-only checks should appear if they're being forced */
 
2850
                                if(!(temp_hststatus->checks_enabled == FALSE && temp_hststatus->next_check != (time_t)0L && (temp_hststatus->check_options & CHECK_OPTION_FORCE_EXECUTION)))
 
2851
                                        continue;
 
2852
                                }
 
2853
                        }
 
2854
 
 
2855
                if(odd) {
 
2856
                        odd = 0;
 
2857
                        bgclass = "Even";
 
2858
                        }
 
2859
                else {
 
2860
                        odd = 1;
 
2861
                        bgclass = "Odd";
 
2862
                        }
 
2863
 
 
2864
                printf("<TR CLASS='queue%s'>", bgclass);
2909
2865
 
2910
2866
                /* get the service status */
2911
 
                if(temp_sortdata->is_service==TRUE){
2912
 
                        
2913
 
                        printf("<TD CLASS='queue%s'><A HREF='%s?type=%d&host=%s'>%s</A></TD>",bgclass,EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_svcstatus->host_name),temp_svcstatus->host_name);
2914
 
                        
2915
 
                        printf("<TD CLASS='queue%s'><A HREF='%s?type=%d&host=%s",bgclass,EXTINFO_CGI,DISPLAY_SERVICE_INFO,url_encode(temp_svcstatus->host_name));
2916
 
                        printf("&service=%s'>%s</A></TD>",url_encode(temp_svcstatus->description),temp_svcstatus->description);
2917
 
 
2918
 
                        get_time_string(&temp_svcstatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2919
 
                        printf("<TD CLASS='queue%s'>%s</TD>",bgclass,(temp_svcstatus->last_check==(time_t)0)?"N/A":date_time);
2920
 
 
2921
 
                        get_time_string(&temp_svcstatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2922
 
                        printf("<TD CLASS='queue%s'>%s</TD>",bgclass,(temp_svcstatus->next_check==(time_t)0)?"N/A":date_time);
2923
 
 
2924
 
                        printf("<TD CLASS='queue%s'>",bgclass);
2925
 
                        if(temp_svcstatus->check_options==CHECK_OPTION_NONE)
 
2867
                if(temp_sortdata->is_service == TRUE) {
 
2868
 
 
2869
                        printf("<TD CLASS='queue%s'><A HREF='%s?type=%d&host=%s'>%s</A></TD>", bgclass, EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_svcstatus->host_name), temp_svcstatus->host_name);
 
2870
 
 
2871
                        printf("<TD CLASS='queue%s'><A HREF='%s?type=%d&host=%s", bgclass, EXTINFO_CGI, DISPLAY_SERVICE_INFO, url_encode(temp_svcstatus->host_name));
 
2872
                        printf("&service=%s'>%s</A></TD>", url_encode(temp_svcstatus->description), temp_svcstatus->description);
 
2873
 
 
2874
                        get_time_string(&temp_svcstatus->last_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2875
                        printf("<TD CLASS='queue%s'>%s</TD>", bgclass, (temp_svcstatus->last_check == (time_t)0) ? "N/A" : date_time);
 
2876
 
 
2877
                        get_time_string(&temp_svcstatus->next_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2878
                        printf("<TD CLASS='queue%s'>%s</TD>", bgclass, (temp_svcstatus->next_check == (time_t)0) ? "N/A" : date_time);
 
2879
 
 
2880
                        printf("<TD CLASS='queue%s'>", bgclass);
 
2881
                        if(temp_svcstatus->check_options == CHECK_OPTION_NONE)
2926
2882
                                printf("Normal ");
2927
 
                        else{
 
2883
                        else {
2928
2884
                                if(temp_svcstatus->check_options & CHECK_OPTION_FORCE_EXECUTION)
2929
2885
                                        printf("Forced ");
2930
2886
                                if(temp_svcstatus->check_options & CHECK_OPTION_FRESHNESS_CHECK)
2934
2890
                                }
2935
2891
                        printf("</TD>");
2936
2892
 
2937
 
                        printf("<TD CLASS='queue%s'>%s</TD>",(temp_svcstatus->checks_enabled==TRUE)?"ENABLED":"DISABLED",(temp_svcstatus->checks_enabled==TRUE)?"ENABLED":"DISABLED");
 
2893
                        printf("<TD CLASS='queue%s'>%s</TD>", (temp_svcstatus->checks_enabled == TRUE) ? "ENABLED" : "DISABLED", (temp_svcstatus->checks_enabled == TRUE) ? "ENABLED" : "DISABLED");
2938
2894
 
2939
 
                        printf("<TD CLASS='queue%s'>",bgclass);
2940
 
                        if(temp_svcstatus->checks_enabled==TRUE){
2941
 
                                printf("<a href='%s?cmd_typ=%d&host=%s",COMMAND_CGI,CMD_DISABLE_SVC_CHECK,url_encode(temp_svcstatus->host_name));
2942
 
                                printf("&service=%s'><img src='%s%s' border=0 ALT='Disable Active Checks Of This Service' TITLE='Disable Active Checks Of This Service'></a>\n",url_encode(temp_svcstatus->description),url_images_path,DISABLED_ICON);
2943
 
                                }
2944
 
                        else{
2945
 
                                printf("<a href='%s?cmd_typ=%d&host=%s",COMMAND_CGI,CMD_ENABLE_SVC_CHECK,url_encode(temp_svcstatus->host_name));
2946
 
                                printf("&service=%s'><img src='%s%s' border=0 ALT='Enable Active Checks Of This Service' TITLE='Enable Active Checks Of This Service'></a>\n",url_encode(temp_svcstatus->description),url_images_path,ENABLED_ICON);
2947
 
                                }
2948
 
                        printf("<a href='%s?cmd_typ=%d&host=%s",COMMAND_CGI,CMD_SCHEDULE_SVC_CHECK,url_encode(temp_svcstatus->host_name));
2949
 
                        printf("&service=%s%s'><img src='%s%s' border=0 ALT='Re-schedule This Service Check' TITLE='Re-schedule This Service Check'></a>\n",url_encode(temp_svcstatus->description),(temp_svcstatus->checks_enabled==TRUE)?"&force_check":"",url_images_path,DELAY_ICON);
 
2895
                        printf("<TD CLASS='queue%s'>", bgclass);
 
2896
                        if(temp_svcstatus->checks_enabled == TRUE) {
 
2897
                                printf("<a href='%s?cmd_typ=%d&host=%s", COMMAND_CGI, CMD_DISABLE_SVC_CHECK, url_encode(temp_svcstatus->host_name));
 
2898
                                printf("&service=%s'><img src='%s%s' border=0 ALT='Disable Active Checks Of This Service' TITLE='Disable Active Checks Of This Service'></a>\n", url_encode(temp_svcstatus->description), url_images_path, DISABLED_ICON);
 
2899
                                }
 
2900
                        else {
 
2901
                                printf("<a href='%s?cmd_typ=%d&host=%s", COMMAND_CGI, CMD_ENABLE_SVC_CHECK, url_encode(temp_svcstatus->host_name));
 
2902
                                printf("&service=%s'><img src='%s%s' border=0 ALT='Enable Active Checks Of This Service' TITLE='Enable Active Checks Of This Service'></a>\n", url_encode(temp_svcstatus->description), url_images_path, ENABLED_ICON);
 
2903
                                }
 
2904
                        printf("<a href='%s?cmd_typ=%d&host=%s", COMMAND_CGI, CMD_SCHEDULE_SVC_CHECK, url_encode(temp_svcstatus->host_name));
 
2905
                        printf("&service=%s%s'><img src='%s%s' border=0 ALT='Re-schedule This Service Check' TITLE='Re-schedule This Service Check'></a>\n", url_encode(temp_svcstatus->description), (temp_svcstatus->checks_enabled == TRUE) ? "&force_check" : "", url_images_path, DELAY_ICON);
2950
2906
                        printf("</TD>\n");
2951
 
                        }
 
2907
                        }
2952
2908
 
2953
2909
                /* get the host status */
2954
 
                else{
2955
 
                        
2956
 
                        printf("<TD CLASS='queue%s'><A HREF='%s?type=%d&host=%s'>%s</A></TD>",bgclass,EXTINFO_CGI,DISPLAY_HOST_INFO,url_encode(temp_hststatus->host_name),temp_hststatus->host_name);
2957
 
                        
2958
 
                        printf("<TD CLASS='queue%s'>&nbsp;</TD>",bgclass);
2959
 
 
2960
 
                        get_time_string(&temp_hststatus->last_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2961
 
                        printf("<TD CLASS='queue%s'>%s</TD>",bgclass,(temp_hststatus->last_check==(time_t)0)?"N/A":date_time);
2962
 
 
2963
 
                        get_time_string(&temp_hststatus->next_check,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
2964
 
                        printf("<TD CLASS='queue%s'>%s</TD>",bgclass,(temp_hststatus->next_check==(time_t)0)?"N/A":date_time);
2965
 
 
2966
 
                        printf("<TD CLASS='queue%s'>",bgclass);
2967
 
                        if(temp_hststatus->check_options==CHECK_OPTION_NONE)
 
2910
                else {
 
2911
 
 
2912
                        printf("<TD CLASS='queue%s'><A HREF='%s?type=%d&host=%s'>%s</A></TD>", bgclass, EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_hststatus->host_name), temp_hststatus->host_name);
 
2913
 
 
2914
                        printf("<TD CLASS='queue%s'>&nbsp;</TD>", bgclass);
 
2915
 
 
2916
                        get_time_string(&temp_hststatus->last_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2917
                        printf("<TD CLASS='queue%s'>%s</TD>", bgclass, (temp_hststatus->last_check == (time_t)0) ? "N/A" : date_time);
 
2918
 
 
2919
                        get_time_string(&temp_hststatus->next_check, date_time, (int)sizeof(date_time), SHORT_DATE_TIME);
 
2920
                        printf("<TD CLASS='queue%s'>%s</TD>", bgclass, (temp_hststatus->next_check == (time_t)0) ? "N/A" : date_time);
 
2921
 
 
2922
                        printf("<TD CLASS='queue%s'>", bgclass);
 
2923
                        if(temp_hststatus->check_options == CHECK_OPTION_NONE)
2968
2924
                                printf("Normal ");
2969
 
                        else{
 
2925
                        else {
2970
2926
                                if(temp_hststatus->check_options & CHECK_OPTION_FORCE_EXECUTION)
2971
2927
                                        printf("Forced ");
2972
2928
                                if(temp_hststatus->check_options & CHECK_OPTION_FRESHNESS_CHECK)
2976
2932
                                }
2977
2933
                        printf("</TD>");
2978
2934
 
2979
 
                        printf("<TD CLASS='queue%s'>%s</TD>",(temp_hststatus->checks_enabled==TRUE)?"ENABLED":"DISABLED",(temp_hststatus->checks_enabled==TRUE)?"ENABLED":"DISABLED");
 
2935
                        printf("<TD CLASS='queue%s'>%s</TD>", (temp_hststatus->checks_enabled == TRUE) ? "ENABLED" : "DISABLED", (temp_hststatus->checks_enabled == TRUE) ? "ENABLED" : "DISABLED");
2980
2936
 
2981
 
                        printf("<TD CLASS='queue%s'>",bgclass);
2982
 
                        if(temp_hststatus->checks_enabled==TRUE){
2983
 
                                printf("<a href='%s?cmd_typ=%d&host=%s",COMMAND_CGI,CMD_DISABLE_HOST_CHECK,url_encode(temp_hststatus->host_name));
2984
 
                                printf("'><img src='%s%s' border=0 ALT='Disable Active Checks Of This Host' TITLE='Disable Active Checks Of This Host'></a>\n",url_images_path,DISABLED_ICON);
2985
 
                                }
2986
 
                        else{
2987
 
                                printf("<a href='%s?cmd_typ=%d&host=%s",COMMAND_CGI,CMD_ENABLE_HOST_CHECK,url_encode(temp_hststatus->host_name));
2988
 
                                printf("'><img src='%s%s' border=0 ALT='Enable Active Checks Of This Host' TITLE='Enable Active Checks Of This Host'></a>\n",url_images_path,ENABLED_ICON);
2989
 
                                }
2990
 
                        printf("<a href='%s?cmd_typ=%d&host=%s%s",COMMAND_CGI,CMD_SCHEDULE_HOST_CHECK,url_encode(temp_hststatus->host_name),(temp_hststatus->checks_enabled==TRUE)?"&force_check":"");
2991
 
                        printf("'><img src='%s%s' border=0 ALT='Re-schedule This Host Check' TITLE='Re-schedule This Host Check'></a>\n",url_images_path,DELAY_ICON);
 
2937
                        printf("<TD CLASS='queue%s'>", bgclass);
 
2938
                        if(temp_hststatus->checks_enabled == TRUE) {
 
2939
                                printf("<a href='%s?cmd_typ=%d&host=%s", COMMAND_CGI, CMD_DISABLE_HOST_CHECK, url_encode(temp_hststatus->host_name));
 
2940
                                printf("'><img src='%s%s' border=0 ALT='Disable Active Checks Of This Host' TITLE='Disable Active Checks Of This Host'></a>\n", url_images_path, DISABLED_ICON);
 
2941
                                }
 
2942
                        else {
 
2943
                                printf("<a href='%s?cmd_typ=%d&host=%s", COMMAND_CGI, CMD_ENABLE_HOST_CHECK, url_encode(temp_hststatus->host_name));
 
2944
                                printf("'><img src='%s%s' border=0 ALT='Enable Active Checks Of This Host' TITLE='Enable Active Checks Of This Host'></a>\n", url_images_path, ENABLED_ICON);
 
2945
                                }
 
2946
                        printf("<a href='%s?cmd_typ=%d&host=%s%s", COMMAND_CGI, CMD_SCHEDULE_HOST_CHECK, url_encode(temp_hststatus->host_name), (temp_hststatus->checks_enabled == TRUE) ? "&force_check" : "");
 
2947
                        printf("'><img src='%s%s' border=0 ALT='Re-schedule This Host Check' TITLE='Re-schedule This Host Check'></a>\n", url_images_path, DELAY_ICON);
2992
2948
                        printf("</TD>\n");
2993
 
                        }
 
2949
                        }
2994
2950
 
2995
2951
                printf("</TR>\n");
2996
2952
 
2997
 
                }
 
2953
                }
2998
2954
 
2999
2955
        printf("</TABLE>\n");
3000
2956
        printf("</DIV>\n");
3005
2961
        free_sortdata_list();
3006
2962
 
3007
2963
        return;
3008
 
        }
 
2964
        }
3009
2965
 
3010
2966
 
3011
2967
 
3012
2968
/* sorts host and service data */
3013
 
int sort_data(int s_type, int s_option){
 
2969
int sort_data(int s_type, int s_option) {
3014
2970
        sortdata *new_sortdata;
3015
2971
        sortdata *last_sortdata;
3016
2972
        sortdata *temp_sortdata;
3017
2973
        servicestatus *temp_svcstatus;
3018
2974
        hoststatus *temp_hststatus;
3019
2975
 
3020
 
        if(s_type==SORT_NONE)
 
2976
        if(s_type == SORT_NONE)
3021
2977
                return ERROR;
3022
2978
 
3023
2979
        /* sort all service status entries */
3024
 
        for(temp_svcstatus=servicestatus_list;temp_svcstatus!=NULL;temp_svcstatus=temp_svcstatus->next){
 
2980
        for(temp_svcstatus = servicestatus_list; temp_svcstatus != NULL; temp_svcstatus = temp_svcstatus->next) {
3025
2981
 
3026
2982
                /* allocate memory for a new sort structure */
3027
 
                new_sortdata=(sortdata *)malloc(sizeof(sortdata));
3028
 
                if(new_sortdata==NULL)
 
2983
                new_sortdata = (sortdata *)malloc(sizeof(sortdata));
 
2984
                if(new_sortdata == NULL)
3029
2985
                        return ERROR;
3030
2986
 
3031
 
                new_sortdata->is_service=TRUE;
3032
 
                new_sortdata->svcstatus=temp_svcstatus;
3033
 
                new_sortdata->hststatus=NULL;
3034
 
 
3035
 
                last_sortdata=sortdata_list;
3036
 
                for(temp_sortdata=sortdata_list;temp_sortdata!=NULL;temp_sortdata=temp_sortdata->next){
3037
 
 
3038
 
                        if(compare_sortdata_entries(s_type,s_option,new_sortdata,temp_sortdata)==TRUE){
3039
 
                                new_sortdata->next=temp_sortdata;
3040
 
                                if(temp_sortdata==sortdata_list)
3041
 
                                        sortdata_list=new_sortdata;
 
2987
                new_sortdata->is_service = TRUE;
 
2988
                new_sortdata->svcstatus = temp_svcstatus;
 
2989
                new_sortdata->hststatus = NULL;
 
2990
 
 
2991
                last_sortdata = sortdata_list;
 
2992
                for(temp_sortdata = sortdata_list; temp_sortdata != NULL; temp_sortdata = temp_sortdata->next) {
 
2993
 
 
2994
                        if(compare_sortdata_entries(s_type, s_option, new_sortdata, temp_sortdata) == TRUE) {
 
2995
                                new_sortdata->next = temp_sortdata;
 
2996
                                if(temp_sortdata == sortdata_list)
 
2997
                                        sortdata_list = new_sortdata;
3042
2998
                                else
3043
 
                                        last_sortdata->next=new_sortdata;
 
2999
                                        last_sortdata->next = new_sortdata;
3044
3000
                                break;
3045
 
                                }
 
3001
                                }
3046
3002
                        else
3047
 
                                last_sortdata=temp_sortdata;
3048
 
                        }
 
3003
                                last_sortdata = temp_sortdata;
 
3004
                        }
3049
3005
 
3050
 
                if(sortdata_list==NULL){
3051
 
                        new_sortdata->next=NULL;
3052
 
                        sortdata_list=new_sortdata;
3053
 
                        }
3054
 
                else if(temp_sortdata==NULL){
3055
 
                        new_sortdata->next=NULL;
3056
 
                        last_sortdata->next=new_sortdata;
3057
 
                        }
3058
 
                }
 
3006
                if(sortdata_list == NULL) {
 
3007
                        new_sortdata->next = NULL;
 
3008
                        sortdata_list = new_sortdata;
 
3009
                        }
 
3010
                else if(temp_sortdata == NULL) {
 
3011
                        new_sortdata->next = NULL;
 
3012
                        last_sortdata->next = new_sortdata;
 
3013
                        }
 
3014
                }
3059
3015
 
3060
3016
        /* sort all host status entries */
3061
 
        for(temp_hststatus=hoststatus_list;temp_hststatus!=NULL;temp_hststatus=temp_hststatus->next){
 
3017
        for(temp_hststatus = hoststatus_list; temp_hststatus != NULL; temp_hststatus = temp_hststatus->next) {
3062
3018
 
3063
3019
                /* allocate memory for a new sort structure */
3064
 
                new_sortdata=(sortdata *)malloc(sizeof(sortdata));
3065
 
                if(new_sortdata==NULL)
 
3020
                new_sortdata = (sortdata *)malloc(sizeof(sortdata));
 
3021
                if(new_sortdata == NULL)
3066
3022
                        return ERROR;
3067
3023
 
3068
 
                new_sortdata->is_service=FALSE;
3069
 
                new_sortdata->svcstatus=NULL;
3070
 
                new_sortdata->hststatus=temp_hststatus;
3071
 
 
3072
 
                last_sortdata=sortdata_list;
3073
 
                for(temp_sortdata=sortdata_list;temp_sortdata!=NULL;temp_sortdata=temp_sortdata->next){
3074
 
 
3075
 
                        if(compare_sortdata_entries(s_type,s_option,new_sortdata,temp_sortdata)==TRUE){
3076
 
                                new_sortdata->next=temp_sortdata;
3077
 
                                if(temp_sortdata==sortdata_list)
3078
 
                                        sortdata_list=new_sortdata;
 
3024
                new_sortdata->is_service = FALSE;
 
3025
                new_sortdata->svcstatus = NULL;
 
3026
                new_sortdata->hststatus = temp_hststatus;
 
3027
 
 
3028
                last_sortdata = sortdata_list;
 
3029
                for(temp_sortdata = sortdata_list; temp_sortdata != NULL; temp_sortdata = temp_sortdata->next) {
 
3030
 
 
3031
                        if(compare_sortdata_entries(s_type, s_option, new_sortdata, temp_sortdata) == TRUE) {
 
3032
                                new_sortdata->next = temp_sortdata;
 
3033
                                if(temp_sortdata == sortdata_list)
 
3034
                                        sortdata_list = new_sortdata;
3079
3035
                                else
3080
 
                                        last_sortdata->next=new_sortdata;
 
3036
                                        last_sortdata->next = new_sortdata;
3081
3037
                                break;
3082
 
                                }
 
3038
                                }
3083
3039
                        else
3084
 
                                last_sortdata=temp_sortdata;
3085
 
                        }
 
3040
                                last_sortdata = temp_sortdata;
 
3041
                        }
3086
3042
 
3087
 
                if(sortdata_list==NULL){
3088
 
                        new_sortdata->next=NULL;
3089
 
                        sortdata_list=new_sortdata;
3090
 
                        }
3091
 
                else if(temp_sortdata==NULL){
3092
 
                        new_sortdata->next=NULL;
3093
 
                        last_sortdata->next=new_sortdata;
3094
 
                        }
3095
 
                }
 
3043
                if(sortdata_list == NULL) {
 
3044
                        new_sortdata->next = NULL;
 
3045
                        sortdata_list = new_sortdata;
 
3046
                        }
 
3047
                else if(temp_sortdata == NULL) {
 
3048
                        new_sortdata->next = NULL;
 
3049
                        last_sortdata->next = new_sortdata;
 
3050
                        }
 
3051
                }
3096
3052
 
3097
3053
        return OK;
3098
 
        }
3099
 
 
3100
 
 
3101
 
int compare_sortdata_entries(int s_type, int s_option, sortdata *new_sortdata, sortdata *temp_sortdata){
3102
 
        hoststatus *temp_hststatus=NULL;
3103
 
        servicestatus *temp_svcstatus=NULL;
 
3054
        }
 
3055
 
 
3056
 
 
3057
int compare_sortdata_entries(int s_type, int s_option, sortdata *new_sortdata, sortdata *temp_sortdata) {
 
3058
        hoststatus *temp_hststatus = NULL;
 
3059
        servicestatus *temp_svcstatus = NULL;
3104
3060
        time_t last_check[2];
3105
3061
        time_t next_check[2];
3106
3062
        int current_attempt[2];
3108
3064
        char *host_name[2];
3109
3065
        char *service_description[2];
3110
3066
 
3111
 
        if(new_sortdata->is_service==TRUE){
3112
 
                temp_svcstatus=new_sortdata->svcstatus;
3113
 
                last_check[0]=temp_svcstatus->last_check;
3114
 
                next_check[0]=temp_svcstatus->next_check;
3115
 
                status[0]=temp_svcstatus->status;
3116
 
                host_name[0]=temp_svcstatus->host_name;
3117
 
                service_description[0]=temp_svcstatus->description;
3118
 
                current_attempt[0]=temp_svcstatus->current_attempt;
3119
 
                }
3120
 
        else{
3121
 
                temp_hststatus=new_sortdata->hststatus;
3122
 
                last_check[0]=temp_hststatus->last_check;
3123
 
                next_check[0]=temp_hststatus->next_check;
3124
 
                status[0]=temp_hststatus->status;
3125
 
                host_name[0]=temp_hststatus->host_name;
3126
 
                service_description[0]="";
3127
 
                current_attempt[0]=temp_hststatus->current_attempt;
3128
 
                }
3129
 
        if(temp_sortdata->is_service==TRUE){
3130
 
                temp_svcstatus=temp_sortdata->svcstatus;
3131
 
                last_check[1]=temp_svcstatus->last_check;
3132
 
                next_check[1]=temp_svcstatus->next_check;
3133
 
                status[1]=temp_svcstatus->status;
3134
 
                host_name[1]=temp_svcstatus->host_name;
3135
 
                service_description[1]=temp_svcstatus->description;
3136
 
                current_attempt[1]=temp_svcstatus->current_attempt;
3137
 
                }
3138
 
        else{
3139
 
                temp_hststatus=temp_sortdata->hststatus;
3140
 
                last_check[1]=temp_hststatus->last_check;
3141
 
                next_check[1]=temp_hststatus->next_check;
3142
 
                status[1]=temp_hststatus->status;
3143
 
                host_name[1]=temp_hststatus->host_name;
3144
 
                service_description[1]="";
3145
 
                current_attempt[1]=temp_hststatus->current_attempt;
3146
 
                }
3147
 
 
3148
 
        if(s_type==SORT_ASCENDING){
3149
 
 
3150
 
                if(s_option==SORT_LASTCHECKTIME){
 
3067
        if(new_sortdata->is_service == TRUE) {
 
3068
                temp_svcstatus = new_sortdata->svcstatus;
 
3069
                last_check[0] = temp_svcstatus->last_check;
 
3070
                next_check[0] = temp_svcstatus->next_check;
 
3071
                status[0] = temp_svcstatus->status;
 
3072
                host_name[0] = temp_svcstatus->host_name;
 
3073
                service_description[0] = temp_svcstatus->description;
 
3074
                current_attempt[0] = temp_svcstatus->current_attempt;
 
3075
                }
 
3076
        else {
 
3077
                temp_hststatus = new_sortdata->hststatus;
 
3078
                last_check[0] = temp_hststatus->last_check;
 
3079
                next_check[0] = temp_hststatus->next_check;
 
3080
                status[0] = temp_hststatus->status;
 
3081
                host_name[0] = temp_hststatus->host_name;
 
3082
                service_description[0] = "";
 
3083
                current_attempt[0] = temp_hststatus->current_attempt;
 
3084
                }
 
3085
        if(temp_sortdata->is_service == TRUE) {
 
3086
                temp_svcstatus = temp_sortdata->svcstatus;
 
3087
                last_check[1] = temp_svcstatus->last_check;
 
3088
                next_check[1] = temp_svcstatus->next_check;
 
3089
                status[1] = temp_svcstatus->status;
 
3090
                host_name[1] = temp_svcstatus->host_name;
 
3091
                service_description[1] = temp_svcstatus->description;
 
3092
                current_attempt[1] = temp_svcstatus->current_attempt;
 
3093
                }
 
3094
        else {
 
3095
                temp_hststatus = temp_sortdata->hststatus;
 
3096
                last_check[1] = temp_hststatus->last_check;
 
3097
                next_check[1] = temp_hststatus->next_check;
 
3098
                status[1] = temp_hststatus->status;
 
3099
                host_name[1] = temp_hststatus->host_name;
 
3100
                service_description[1] = "";
 
3101
                current_attempt[1] = temp_hststatus->current_attempt;
 
3102
                }
 
3103
 
 
3104
        if(s_type == SORT_ASCENDING) {
 
3105
 
 
3106
                if(s_option == SORT_LASTCHECKTIME) {
3151
3107
                        if(last_check[0] <= last_check[1])
3152
3108
                                return TRUE;
3153
3109
                        else
3154
3110
                                return FALSE;
3155
 
                        }
3156
 
                if(s_option==SORT_NEXTCHECKTIME){
 
3111
                        }
 
3112
                if(s_option == SORT_NEXTCHECKTIME) {
3157
3113
                        if(next_check[0] <= next_check[1])
3158
3114
                                return TRUE;
3159
3115
                        else
3160
3116
                                return FALSE;
3161
 
                        }
3162
 
                else if(s_option==SORT_CURRENTATTEMPT){
 
3117
                        }
 
3118
                else if(s_option == SORT_CURRENTATTEMPT) {
3163
3119
                        if(current_attempt[0] <= current_attempt[1])
3164
3120
                                return TRUE;
3165
3121
                        else
3166
3122
                                return FALSE;
3167
 
                        }
3168
 
                else if(s_option==SORT_SERVICESTATUS){
 
3123
                        }
 
3124
                else if(s_option == SORT_SERVICESTATUS) {
3169
3125
                        if(status[0] <= status[1])
3170
3126
                                return TRUE;
3171
3127
                        else
3172
3128
                                return FALSE;
3173
 
                        }
3174
 
                else if(s_option==SORT_HOSTNAME){
3175
 
                        if(strcasecmp(host_name[0],host_name[1])<0)
3176
 
                                return TRUE;
3177
 
                        else
3178
 
                                return FALSE;
3179
 
                        }
3180
 
                else if(s_option==SORT_SERVICENAME){
3181
 
                        if(strcasecmp(service_description[0],service_description[1])<0)
3182
 
                                return TRUE;
3183
 
                        else
3184
 
                                return FALSE;
3185
 
                        }
3186
 
                }
3187
 
        else{
3188
 
                if(s_option==SORT_LASTCHECKTIME){
 
3129
                        }
 
3130
                else if(s_option == SORT_HOSTNAME) {
 
3131
                        if(strcasecmp(host_name[0], host_name[1]) < 0)
 
3132
                                return TRUE;
 
3133
                        else
 
3134
                                return FALSE;
 
3135
                        }
 
3136
                else if(s_option == SORT_SERVICENAME) {
 
3137
                        if(strcasecmp(service_description[0], service_description[1]) < 0)
 
3138
                                return TRUE;
 
3139
                        else
 
3140
                                return FALSE;
 
3141
                        }
 
3142
                }
 
3143
        else {
 
3144
                if(s_option == SORT_LASTCHECKTIME) {
3189
3145
                        if(last_check[0] > last_check[1])
3190
3146
                                return TRUE;
3191
3147
                        else
3192
3148
                                return FALSE;
3193
 
                        }
3194
 
                if(s_option==SORT_NEXTCHECKTIME){
 
3149
                        }
 
3150
                if(s_option == SORT_NEXTCHECKTIME) {
3195
3151
                        if(next_check[0] > next_check[1])
3196
3152
                                return TRUE;
3197
3153
                        else
3198
3154
                                return FALSE;
3199
 
                        }
3200
 
                else if(s_option==SORT_CURRENTATTEMPT){
 
3155
                        }
 
3156
                else if(s_option == SORT_CURRENTATTEMPT) {
3201
3157
                        if(current_attempt[0] > current_attempt[1])
3202
3158
                                return TRUE;
3203
3159
                        else
3204
3160
                                return FALSE;
3205
 
                        }
3206
 
                else if(s_option==SORT_SERVICESTATUS){
 
3161
                        }
 
3162
                else if(s_option == SORT_SERVICESTATUS) {
3207
3163
                        if(status[0] > status[1])
3208
3164
                                return TRUE;
3209
3165
                        else
3210
3166
                                return FALSE;
3211
 
                        }
3212
 
                else if(s_option==SORT_HOSTNAME){
3213
 
                        if(strcasecmp(host_name[0],host_name[1])>0)
3214
 
                                return TRUE;
3215
 
                        else
3216
 
                                return FALSE;
3217
 
                        }
3218
 
                else if(s_option==SORT_SERVICENAME){
3219
 
                        if(strcasecmp(service_description[0],service_description[1])>0)
3220
 
                                return TRUE;
3221
 
                        else
3222
 
                                return FALSE;
3223
 
                        }
3224
 
                }
 
3167
                        }
 
3168
                else if(s_option == SORT_HOSTNAME) {
 
3169
                        if(strcasecmp(host_name[0], host_name[1]) > 0)
 
3170
                                return TRUE;
 
3171
                        else
 
3172
                                return FALSE;
 
3173
                        }
 
3174
                else if(s_option == SORT_SERVICENAME) {
 
3175
                        if(strcasecmp(service_description[0], service_description[1]) > 0)
 
3176
                                return TRUE;
 
3177
                        else
 
3178
                                return FALSE;
 
3179
                        }
 
3180
                }
3225
3181
 
3226
3182
        return TRUE;
3227
 
        }
 
3183
        }
3228
3184
 
3229
3185
 
3230
3186
 
3231
3187
/* free all memory allocated to the sortdata structures */
3232
 
void free_sortdata_list(void){
 
3188
void free_sortdata_list(void) {
3233
3189
        sortdata *this_sortdata;
3234
3190
        sortdata *next_sortdata;
3235
3191
 
3236
3192
        /* free memory for the sortdata list */
3237
 
        for(this_sortdata=sortdata_list;this_sortdata!=NULL;this_sortdata=next_sortdata){
3238
 
                next_sortdata=this_sortdata->next;
 
3193
        for(this_sortdata = sortdata_list; this_sortdata != NULL; this_sortdata = next_sortdata) {
 
3194
                next_sortdata = this_sortdata->next;
3239
3195
                free(this_sortdata);
3240
 
                }
 
3196
                }
3241
3197
 
3242
3198
        return;
3243
 
        }
 
3199
        }
3244
3200