![]() |
Icinga-core 1.4.0
next gen monitoring
|
00001 /***************************************************************************** 00002 * 00003 * SHOWLOG.C - Icinga Log File CGI 00004 * 00005 * Copyright (c) 1999-2009 Ethan Galstad (egalstad@nagios.org) 00006 * Copyright (c) 2009-2011 Icinga Development Team (http://www.icinga.org) 00007 * 00008 * License: 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License version 2 as 00012 * published by the Free Software Foundation. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00022 * 00023 *****************************************************************************/ 00024 00030 #include "../include/config.h" 00031 #include "../include/common.h" 00032 #include "../include/objects.h" 00033 00034 #include "../include/getcgi.h" 00035 #include "../include/cgiutils.h" 00036 #include "../include/cgiauth.h" 00037 #include "../include/readlogs.h" 00038 00041 extern char main_config_file[MAX_FILENAME_LENGTH]; 00042 extern char url_html_path[MAX_FILENAME_LENGTH]; 00043 extern char url_images_path[MAX_FILENAME_LENGTH]; 00044 extern char url_stylesheets_path[MAX_FILENAME_LENGTH]; 00045 extern char url_js_path[MAX_FILENAME_LENGTH]; 00046 00047 extern char *csv_delimiter; 00048 extern char *csv_data_enclosure; 00049 00050 extern int log_rotation_method; 00051 extern int enable_splunk_integration; 00052 extern int showlog_initial_states; 00053 extern int showlog_current_states; 00054 extern int escape_html_tags; 00055 00056 extern int embedded; 00057 extern int display_header; 00058 extern int daemon_check; 00059 extern int date_format; 00060 extern int content_type; 00061 extern int refresh; 00062 00063 extern logentry *entry_list; 00071 int display_type=DISPLAY_HOSTS; 00072 int show_all_hosts=TRUE; 00073 int show_all_hostgroups=TRUE; 00074 int show_all_servicegroups=TRUE; 00075 char *host_name=NULL; 00076 char *hostgroup_name=NULL; 00077 char *servicegroup_name=NULL; 00078 char *service_desc=NULL; 00083 int display_frills=TRUE; 00084 int display_timebreaks=TRUE; 00085 int reverse=FALSE; 00086 int timeperiod_type=TIMEPERIOD_SINGLE_DAY; 00088 int show_notifications=TRUE; 00089 int show_host_status=TRUE; 00090 int show_service_status=TRUE; 00091 int show_external_commands=TRUE; 00092 int show_system_messages=TRUE; 00093 int show_event_handler=TRUE; 00094 int show_flapping=TRUE; 00095 int show_downtime=TRUE; 00097 char *query_string=NULL; 00098 char *start_time_string=""; 00099 char *end_time_string=""; 00101 time_t ts_start=0L; 00102 time_t ts_end=0L; 00103 time_t ts_midnight=0L; 00105 authdata current_authdata; 00107 int CGI_ID=SHOWLOG_CGI_ID; 00117 int process_cgivars(void); 00118 00124 void display_logentries(void); 00125 00130 void show_filter(void); 00131 00137 void display_own_nav_table(void); 00138 00140 int main(void){ 00141 int result=OK; 00142 struct tm *t; 00143 time_t current_time=0L; 00144 00145 /* get the CGI variables passed in the URL */ 00146 process_cgivars(); 00147 00148 /* reset internal variables */ 00149 reset_cgi_vars(); 00150 00151 /* read the CGI configuration file */ 00152 result=read_cgi_config_file(get_cgi_config_location()); 00153 if(result==ERROR){ 00154 document_header(CGI_ID,FALSE); 00155 print_error(get_cgi_config_location(), ERROR_CGI_CFG_FILE); 00156 document_footer(CGI_ID); 00157 return ERROR; 00158 } 00159 00160 /* read the main configuration file */ 00161 result=read_main_config_file(main_config_file); 00162 if(result==ERROR){ 00163 document_header(CGI_ID,FALSE); 00164 print_error(main_config_file, ERROR_CGI_MAIN_CFG); 00165 document_footer(CGI_ID); 00166 return ERROR; 00167 } 00168 00169 /* read all object configuration data */ 00170 result=read_all_object_configuration_data(main_config_file,READ_ALL_OBJECT_DATA); 00171 if(result==ERROR){ 00172 document_header(CGI_ID,FALSE); 00173 print_error(NULL, ERROR_CGI_OBJECT_DATA); 00174 document_footer(CGI_ID); 00175 return ERROR; 00176 } 00177 00178 /* This requires the date_format parameter in the main config file */ 00179 if (timeperiod_type==TIMEPERIOD_CUSTOM) { 00180 if (strcmp(start_time_string,"")) 00181 string_to_time(start_time_string,&ts_start); 00182 00183 if (strcmp(end_time_string,"")) 00184 string_to_time(end_time_string,&ts_end); 00185 } 00186 00187 document_header(CGI_ID,TRUE); 00188 00189 /* calculate timestamps for reading logs */ 00190 convert_timeperiod_to_times(timeperiod_type,&ts_start,&ts_end); 00191 00192 /* get authentication information */ 00193 get_authentication_information(¤t_authdata); 00194 00195 /* get the current time */ 00196 time(¤t_time); 00197 t=localtime(¤t_time); 00198 00199 t->tm_sec=0; 00200 t->tm_min=0; 00201 t->tm_hour=0; 00202 t->tm_isdst=-1; 00203 00204 /* get timestamp for midnight today to find out if we have to show past log entries or present. (Also to give the right description to the info table)*/ 00205 ts_midnight=mktime(t); 00206 00207 if(display_header==TRUE){ 00208 00209 /* begin top table */ 00210 printf("<table border=0 width=100%% cellpadding=0 cellspacing=0>\n"); 00211 printf("<tr>\n"); 00212 00213 /* left column of top table - info box */ 00214 printf("<td align=left valign=top width=33%%>\n"); 00215 display_info_table((ts_end>ts_midnight)?"Current Event Log":"Archived Event Log",FALSE,¤t_authdata, daemon_check); 00216 printf("</td>\n"); 00217 00218 /* middle column of top table - log file navigation options */ 00219 printf("<td align=center valign=top width=33%%>\n"); 00220 00221 display_own_nav_table(); 00222 00223 printf("</td>\n"); 00224 00225 /* right hand column of top row */ 00226 printf("<td align=right valign=top width=33%%>\n"); 00227 00228 /* show filter */ 00229 printf("<table border=0 cellspacing=0 cellpadding=0 CLASS='optBox' align=right><tr><td>\n"); 00230 show_filter(); 00231 printf("</td></tr>\n"); 00232 00233 /* display context-sensitive help */ 00234 printf("<tr><td align=right>\n"); 00235 display_context_help(CONTEXTHELP_LOG); 00236 printf("</td></tr>\n"); 00237 00238 printf("</table>\n"); 00239 00240 printf("</td>\n"); 00241 00242 /* end of top table */ 00243 printf("</tr>\n"); 00244 printf("</table>\n"); 00245 } 00246 00247 /* check to see if the user is authorized to view the log file */ 00248 if(is_authorized_for_system_information(¤t_authdata)==FALSE){ 00249 print_generic_error_message("It appears as though you do not have permission to view the log file...","If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI and check the authorization options in your CGI configuration file.",0); 00250 return ERROR; 00251 } 00252 00253 /* display the contents of the log file */ 00254 display_logentries(); 00255 00256 document_footer(CGI_ID); 00257 00258 /* free allocated memory */ 00259 free_memory(); 00260 00261 return OK; 00262 } 00263 00264 int process_cgivars(void){ 00265 char **variables; 00266 int error=FALSE; 00267 int x; 00268 00269 variables=getcgivars(); 00270 00271 for(x=0;variables[x]!=NULL;x++){ 00272 00273 /* do some basic length checking on the variable identifier to prevent buffer overflows */ 00274 if(strlen(variables[x])>=MAX_INPUT_BUFFER-1) 00275 continue; 00276 00277 /* found query string */ 00278 else if(!strcmp(variables[x],"query_string")){ 00279 x++; 00280 if(variables[x]==NULL){ 00281 error=TRUE; 00282 break; 00283 } 00284 00285 query_string=strdup(variables[x]); 00286 strip_html_brackets(query_string); 00287 00288 if(strlen(query_string)==0) 00289 query_string=NULL; 00290 } 00291 00292 /* we found first time argument */ 00293 else if(!strcmp(variables[x],"ts_start")){ 00294 x++; 00295 if(variables[x]==NULL){ 00296 error=TRUE; 00297 break; 00298 } 00299 00300 ts_start=(time_t)strtoul(variables[x],NULL,10); 00301 } 00302 00303 /* we found last time argument */ 00304 else if(!strcmp(variables[x],"ts_end")){ 00305 x++; 00306 if(variables[x]==NULL){ 00307 error=TRUE; 00308 break; 00309 } 00310 00311 ts_end=(time_t)strtoul(variables[x],NULL,10); 00312 } 00313 00314 /* we found the start time */ 00315 else if(!strcmp(variables[x],"start_time")){ 00316 x++; 00317 if(variables[x]==NULL){ 00318 error=TRUE; 00319 break; 00320 } 00321 00322 start_time_string=(char *)malloc(strlen(variables[x])+1); 00323 if(start_time_string==NULL) 00324 start_time_string=""; 00325 else 00326 strcpy(start_time_string,variables[x]); 00327 } 00328 00329 /* we found the end time */ 00330 else if(!strcmp(variables[x],"end_time")){ 00331 x++; 00332 if(variables[x]==NULL){ 00333 error=TRUE; 00334 break; 00335 } 00336 00337 end_time_string=(char *)malloc(strlen(variables[x])+1); 00338 if(end_time_string==NULL) 00339 end_time_string=""; 00340 else 00341 strcpy(end_time_string,variables[x]); 00342 } 00343 00344 /* we found the standard timeperiod argument */ 00345 else if(!strcmp(variables[x],"timeperiod")){ 00346 x++; 00347 if(variables[x]==NULL){ 00348 error=TRUE; 00349 break; 00350 } 00351 00352 if(!strcmp(variables[x],"today")) 00353 timeperiod_type=TIMEPERIOD_TODAY; 00354 else if(!strcmp(variables[x],"singelday")) 00355 timeperiod_type=TIMEPERIOD_SINGLE_DAY; 00356 else if(!strcmp(variables[x],"last24hours")) 00357 timeperiod_type=TIMEPERIOD_LAST24HOURS; 00358 else if(!strcmp(variables[x],"thisweek")) 00359 timeperiod_type=TIMEPERIOD_THISWEEK; 00360 else if(!strcmp(variables[x],"lastweek")) 00361 timeperiod_type=TIMEPERIOD_LASTWEEK; 00362 else if(!strcmp(variables[x],"thismonth")) 00363 timeperiod_type=TIMEPERIOD_THISMONTH; 00364 else if(!strcmp(variables[x],"lastmonth")) 00365 timeperiod_type=TIMEPERIOD_LASTMONTH; 00366 else if(!strcmp(variables[x],"thisyear")) 00367 timeperiod_type=TIMEPERIOD_THISYEAR; 00368 else if(!strcmp(variables[x],"lastyear")) 00369 timeperiod_type=TIMEPERIOD_LASTYEAR; 00370 else if(!strcmp(variables[x],"last7days")) 00371 timeperiod_type=TIMEPERIOD_LAST7DAYS; 00372 else if(!strcmp(variables[x],"last31days")) 00373 timeperiod_type=TIMEPERIOD_LAST31DAYS; 00374 else if(!strcmp(variables[x],"custom")) 00375 timeperiod_type=TIMEPERIOD_CUSTOM; 00376 else 00377 continue; 00378 00379 convert_timeperiod_to_times(timeperiod_type,&ts_start,&ts_end); 00380 } 00381 00382 /* we found the order argument */ 00383 else if(!strcmp(variables[x],"order")){ 00384 x++; 00385 if(variables[x]==NULL){ 00386 error=TRUE; 00387 break; 00388 } 00389 00390 if(!strcmp(variables[x],"new2old")) 00391 reverse=FALSE; 00392 else if(!strcmp(variables[x],"old2new")) 00393 reverse=TRUE; 00394 } 00395 00396 /* notification filter */ 00397 else if(!strcmp(variables[x],"noti")){ 00398 x++; 00399 if(variables[x]==NULL){ 00400 error=TRUE; 00401 break; 00402 } 00403 00404 if(!strcmp(variables[x],"off")) 00405 show_notifications=FALSE; 00406 } 00407 00408 /* host status filter */ 00409 else if(!strcmp(variables[x],"hst")){ 00410 x++; 00411 if(variables[x]==NULL){ 00412 error=TRUE; 00413 break; 00414 } 00415 00416 if(!strcmp(variables[x],"off")) 00417 show_host_status=FALSE; 00418 } 00419 00420 /* service status filter */ 00421 else if(!strcmp(variables[x],"sst")){ 00422 x++; 00423 if(variables[x]==NULL){ 00424 error=TRUE; 00425 break; 00426 } 00427 00428 if(!strcmp(variables[x],"off")) 00429 show_service_status=FALSE; 00430 } 00431 00432 /* external commands filter */ 00433 else if(!strcmp(variables[x],"cmd")){ 00434 x++; 00435 if(variables[x]==NULL){ 00436 error=TRUE; 00437 break; 00438 } 00439 00440 if(!strcmp(variables[x],"off")) 00441 show_external_commands=FALSE; 00442 } 00443 00444 /* system messages filter */ 00445 else if(!strcmp(variables[x],"sms")){ 00446 x++; 00447 if(variables[x]==NULL){ 00448 error=TRUE; 00449 break; 00450 } 00451 00452 if(!strcmp(variables[x],"off")) 00453 show_system_messages=FALSE; 00454 } 00455 00456 /* event handler filter */ 00457 else if(!strcmp(variables[x],"evh")){ 00458 x++; 00459 if(variables[x]==NULL){ 00460 error=TRUE; 00461 break; 00462 } 00463 00464 if(!strcmp(variables[x],"off")) 00465 show_event_handler=FALSE; 00466 } 00467 00468 /* flapping filter */ 00469 else if(!strcmp(variables[x],"flp")){ 00470 x++; 00471 if(variables[x]==NULL){ 00472 error=TRUE; 00473 break; 00474 } 00475 00476 if(!strcmp(variables[x],"off")) 00477 show_flapping=FALSE; 00478 } 00479 00480 /* downtime filter */ 00481 else if(!strcmp(variables[x],"dwn")){ 00482 x++; 00483 if(variables[x]==NULL){ 00484 error=TRUE; 00485 break; 00486 } 00487 00488 if(!strcmp(variables[x],"off")) 00489 show_downtime=FALSE; 00490 } 00491 00492 /* we found the CSV output option */ 00493 else if(!strcmp(variables[x],"csvoutput")) { 00494 display_header=FALSE; 00495 content_type=CSV_CONTENT; 00496 } 00497 00498 /* we found the CSV output option */ 00499 else if(!strcmp(variables[x],"jsonoutput")) { 00500 display_header=FALSE; 00501 content_type=JSON_CONTENT; 00502 } 00503 00504 /* we found the embed option */ 00505 else if(!strcmp(variables[x],"embedded")) 00506 embedded=TRUE; 00507 00508 /* we found the pause option */ 00509 else if(!strcmp(variables[x],"paused")) 00510 refresh=FALSE; 00511 00512 /* we found the noheader option */ 00513 else if(!strcmp(variables[x],"noheader")) 00514 display_header=FALSE; 00515 00516 /* we found the nofrills option */ 00517 else if (!strcmp(variables[x],"nofrills")) 00518 display_frills=FALSE; 00519 00520 /* we found the notimebreaks option */ 00521 else if(!strcmp(variables[x],"notimebreaks")) 00522 display_timebreaks=FALSE; 00523 00524 /* we found the nodaemoncheck option */ 00525 else if(!strcmp(variables[x],"nodaemoncheck")) 00526 daemon_check=FALSE; 00527 00528 /* we received an invalid argument */ 00529 else 00530 error=TRUE; 00531 00532 } 00533 00534 /* free memory allocated to the CGI variables */ 00535 free_cgivars(variables); 00536 00537 return error; 00538 } 00539 00540 void display_logentries() { 00541 char image[MAX_INPUT_BUFFER]; 00542 char image_alt[MAX_INPUT_BUFFER]; 00543 char last_message_date[MAX_INPUT_BUFFER]=""; 00544 char current_message_date[MAX_INPUT_BUFFER]=""; 00545 char date_time[MAX_DATETIME_LENGTH]; 00546 char error_text[MAX_INPUT_BUFFER]=""; 00547 char filename[MAX_FILENAME_LENGTH]; 00548 int status=0, read_status=0, i; 00549 int oldest_archive=0; 00550 int newest_archive=0; 00551 int current_archive=0; 00552 int user_has_seen_something=FALSE; 00553 int json_start=TRUE; 00554 struct tm *time_ptr=NULL; 00555 logentry *temp_entry=NULL; 00556 int count=0; 00557 00558 00559 /* Add default filters */ 00560 if (showlog_initial_states==FALSE) { 00561 add_log_filter(LOGENTRY_SERVICE_INITIAL_STATE,LOGFILTER_EXCLUDE); 00562 add_log_filter(LOGENTRY_HOST_INITIAL_STATE,LOGFILTER_EXCLUDE); 00563 } 00564 if (showlog_current_states==FALSE) { 00565 add_log_filter(LOGENTRY_SERVICE_CURRENT_STATE,LOGFILTER_EXCLUDE); 00566 add_log_filter(LOGENTRY_HOST_CURRENT_STATE,LOGFILTER_EXCLUDE); 00567 } 00568 00569 /* Add requested filters */ 00570 if (show_notifications==FALSE) { 00571 add_log_filter(LOGENTRY_HOST_NOTIFICATION,LOGFILTER_EXCLUDE); 00572 add_log_filter(LOGENTRY_SERVICE_NOTIFICATION,LOGFILTER_EXCLUDE); 00573 } 00574 if (show_host_status==FALSE) { 00575 add_log_filter(LOGENTRY_HOST_UP,LOGFILTER_EXCLUDE); 00576 add_log_filter(LOGENTRY_HOST_DOWN,LOGFILTER_EXCLUDE); 00577 add_log_filter(LOGENTRY_HOST_UNREACHABLE,LOGFILTER_EXCLUDE); 00578 add_log_filter(LOGENTRY_HOST_RECOVERY,LOGFILTER_EXCLUDE); 00579 add_log_filter(LOGENTRY_PASSIVE_HOST_CHECK,LOGFILTER_EXCLUDE); 00580 } 00581 if (show_service_status==FALSE) { 00582 add_log_filter(LOGENTRY_SERVICE_OK,LOGFILTER_EXCLUDE); 00583 add_log_filter(LOGENTRY_SERVICE_WARNING,LOGFILTER_EXCLUDE); 00584 add_log_filter(LOGENTRY_SERVICE_CRITICAL,LOGFILTER_EXCLUDE); 00585 add_log_filter(LOGENTRY_SERVICE_UNKNOWN,LOGFILTER_EXCLUDE); 00586 add_log_filter(LOGENTRY_SERVICE_RECOVERY,LOGFILTER_EXCLUDE); 00587 add_log_filter(LOGENTRY_PASSIVE_SERVICE_CHECK,LOGFILTER_EXCLUDE); 00588 } 00589 if (show_external_commands==FALSE) 00590 add_log_filter(LOGENTRY_EXTERNAL_COMMAND,LOGFILTER_EXCLUDE); 00591 00592 if (show_system_messages==FALSE) { 00593 add_log_filter(LOGENTRY_SYSTEM_WARNING,LOGFILTER_EXCLUDE); 00594 add_log_filter(LOGENTRY_STARTUP,LOGFILTER_EXCLUDE); 00595 add_log_filter(LOGENTRY_SHUTDOWN,LOGFILTER_EXCLUDE); 00596 add_log_filter(LOGENTRY_BAILOUT,LOGFILTER_EXCLUDE); 00597 add_log_filter(LOGENTRY_RESTART,LOGFILTER_EXCLUDE); 00598 add_log_filter(LOGENTRY_LOG_ROTATION,LOGFILTER_EXCLUDE); 00599 add_log_filter(LOGENTRY_AUTOSAVE,LOGFILTER_EXCLUDE); 00600 add_log_filter(LOGENTRY_IDOMOD,LOGFILTER_EXCLUDE); 00601 } 00602 if (show_event_handler==FALSE) { 00603 add_log_filter(LOGENTRY_SERVICE_EVENT_HANDLER,LOGFILTER_EXCLUDE); 00604 add_log_filter(LOGENTRY_HOST_EVENT_HANDLER,LOGFILTER_EXCLUDE); 00605 } 00606 if (show_flapping==FALSE) { 00607 add_log_filter(LOGENTRY_SERVICE_FLAPPING_STARTED,LOGFILTER_EXCLUDE); 00608 add_log_filter(LOGENTRY_SERVICE_FLAPPING_STOPPED,LOGFILTER_EXCLUDE); 00609 add_log_filter(LOGENTRY_SERVICE_FLAPPING_DISABLED,LOGFILTER_EXCLUDE); 00610 add_log_filter(LOGENTRY_HOST_FLAPPING_STARTED,LOGFILTER_EXCLUDE); 00611 add_log_filter(LOGENTRY_HOST_FLAPPING_STOPPED,LOGFILTER_EXCLUDE); 00612 add_log_filter(LOGENTRY_HOST_FLAPPING_DISABLED,LOGFILTER_EXCLUDE); 00613 } 00614 if (show_downtime==FALSE) { 00615 add_log_filter(LOGENTRY_SERVICE_DOWNTIME_STARTED,LOGFILTER_EXCLUDE); 00616 add_log_filter(LOGENTRY_SERVICE_DOWNTIME_STOPPED,LOGFILTER_EXCLUDE); 00617 add_log_filter(LOGENTRY_SERVICE_DOWNTIME_CANCELLED,LOGFILTER_EXCLUDE); 00618 add_log_filter(LOGENTRY_HOST_DOWNTIME_STARTED,LOGFILTER_EXCLUDE); 00619 add_log_filter(LOGENTRY_HOST_DOWNTIME_STOPPED,LOGFILTER_EXCLUDE); 00620 add_log_filter(LOGENTRY_HOST_DOWNTIME_CANCELLED,LOGFILTER_EXCLUDE); 00621 } 00622 00623 00624 /* determine oldest archive to use when scanning for data */ 00625 oldest_archive=determine_archive_to_use_from_time(ts_start); 00626 00627 00628 /* determine most recent archive to use when scanning for data */ 00629 newest_archive=determine_archive_to_use_from_time(ts_end); 00630 00631 /* Add 10 backtrack archives */ 00632 newest_archive-=10; 00633 oldest_archive+=5; 00634 if (newest_archive<0) 00635 newest_archive=0; 00636 00637 /* correct archive id errors */ 00638 if(oldest_archive<newest_archive) 00639 oldest_archive=newest_archive; 00640 00641 current_archive=oldest_archive; 00642 00643 /* read in all the necessary archived logs */ 00644 while(1) { 00645 00646 /* get the name of the log file that contains this archive */ 00647 get_log_archive_to_use(current_archive,filename,sizeof(filename)-1); 00648 00649 /* scan the log file for archived state data */ 00650 status=get_log_entries(filename,query_string,reverse,ts_start,ts_end); 00651 00652 /* Stop if we out of memory or have a wrong filter */ 00653 if (status==READLOG_ERROR_FILTER || status==READLOG_ERROR_MEMORY) { 00654 read_status=status; 00655 break; 00656 } 00657 00658 /* Don't care if there isn't a file to read */ 00659 if (status==READLOG_ERROR_NOFILE && read_status==READLOG_OK) 00660 status=READLOG_OK; 00661 00662 /* set status */ 00663 read_status=status; 00664 00665 /* count/break depending on direction (new2old / old2new) */ 00666 if (current_archive<=newest_archive) 00667 break; 00668 00669 current_archive--; 00670 } 00671 00672 free_log_filters(); 00673 00674 /* dealing with errors */ 00675 if (read_status==READLOG_ERROR_MEMORY) { 00676 if (content_type==CSV_CONTENT) 00677 printf("Out of memory..., showing all I could get!"); 00678 else 00679 printf("<P><DIV CLASS='warningMessage'>Out of memory..., showing all I could get!</DIV></P>"); 00680 } 00681 if (read_status==READLOG_ERROR_NOFILE) { 00682 snprintf(error_text,sizeof(error_text),"Error: Could not open log file '%s' for reading!",filename); 00683 error_text[sizeof(error_text)-1]='\x0'; 00684 print_generic_error_message(error_text,NULL,0); 00685 } 00686 if (read_status==READLOG_ERROR_FILTER) 00687 print_generic_error_message("It seems like that reagular expressions don't like waht you searched for. Please change your search string.",NULL,0); 00688 00689 /* now we start displaying the log entries */ 00690 else { 00691 00692 if(content_type==JSON_CONTENT) { 00693 display_timebreaks=FALSE; 00694 printf("\"log_entries\": [\n"); 00695 }else if(content_type==CSV_CONTENT) { 00696 display_timebreaks=FALSE; 00697 00698 printf("%sTimestamp%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter); 00699 printf("%sDate Time%s%s",csv_data_enclosure,csv_data_enclosure,csv_delimiter); 00700 printf("%sLog Entry%s\n",csv_data_enclosure,csv_data_enclosure); 00701 00702 } else { 00703 printf("<DIV CLASS='logEntries'>\n"); 00704 00705 /* add export to csv link */ 00706 printf("<div class='csv_export_link' align=right style='margin-right:1em;'><a href='%s' target='_blank'>Export to CSV</a></DIV>\n",get_export_csv_link(SHOWLOG_CGI)); 00707 } 00708 00709 for(temp_entry=entry_list;temp_entry!=NULL;temp_entry=temp_entry->next) { 00710 00711 /* set the correct icon and icon alt text for current log entry */ 00712 if(temp_entry->type==LOGENTRY_STARTUP){ 00713 strcpy(image,START_ICON); 00714 strcpy(image_alt,START_ICON_ALT); 00715 } 00716 else if(temp_entry->type==LOGENTRY_SHUTDOWN || temp_entry->type==LOGENTRY_BAILOUT){ 00717 strcpy(image,STOP_ICON); 00718 strcpy(image_alt,STOP_ICON_ALT); 00719 } 00720 else if(temp_entry->type==LOGENTRY_RESTART){ 00721 strcpy(image,RESTART_ICON); 00722 strcpy(image_alt,RESTART_ICON_ALT); 00723 } 00724 else if(temp_entry->type==LOGENTRY_HOST_DOWN){ 00725 strcpy(image,HOST_DOWN_ICON); 00726 strcpy(image_alt,HOST_DOWN_ICON_ALT); 00727 } 00728 else if(temp_entry->type==LOGENTRY_HOST_UNREACHABLE){ 00729 strcpy(image,HOST_UNREACHABLE_ICON); 00730 strcpy(image_alt,HOST_UNREACHABLE_ICON_ALT); 00731 } 00732 else if(temp_entry->type==LOGENTRY_HOST_RECOVERY || temp_entry->type==LOGENTRY_HOST_UP){ 00733 strcpy(image,HOST_UP_ICON); 00734 strcpy(image_alt,HOST_UP_ICON_ALT); 00735 } 00736 else if(temp_entry->type==LOGENTRY_HOST_NOTIFICATION){ 00737 strcpy(image,HOST_NOTIFICATION_ICON); 00738 strcpy(image_alt,HOST_NOTIFICATION_ICON_ALT); 00739 } 00740 else if(temp_entry->type==LOGENTRY_SERVICE_CRITICAL){ 00741 strcpy(image,CRITICAL_ICON); 00742 strcpy(image_alt,CRITICAL_ICON_ALT); 00743 } 00744 else if(temp_entry->type==LOGENTRY_SERVICE_WARNING){ 00745 strcpy(image,WARNING_ICON); 00746 strcpy(image_alt,WARNING_ICON_ALT); 00747 } 00748 else if(temp_entry->type==LOGENTRY_SERVICE_UNKNOWN){ 00749 strcpy(image,UNKNOWN_ICON); 00750 strcpy(image_alt,UNKNOWN_ICON_ALT); 00751 } 00752 else if(temp_entry->type==LOGENTRY_SERVICE_RECOVERY || temp_entry->type==LOGENTRY_SERVICE_OK){ 00753 strcpy(image,OK_ICON); 00754 strcpy(image_alt,OK_ICON_ALT); 00755 } 00756 else if(temp_entry->type==LOGENTRY_SERVICE_NOTIFICATION){ 00757 strcpy(image,NOTIFICATION_ICON); 00758 strcpy(image_alt,NOTIFICATION_ICON_ALT); 00759 } 00760 else if(temp_entry->type==LOGENTRY_SERVICE_EVENT_HANDLER){ 00761 strcpy(image,SERVICE_EVENT_ICON); 00762 strcpy(image_alt,SERVICE_EVENT_ICON_ALT); 00763 } 00764 else if(temp_entry->type==LOGENTRY_HOST_EVENT_HANDLER){ 00765 strcpy(image,HOST_EVENT_ICON); 00766 strcpy(image_alt,HOST_EVENT_ICON_ALT); 00767 } 00768 else if(temp_entry->type==LOGENTRY_EXTERNAL_COMMAND){ 00769 strcpy(image,EXTERNAL_COMMAND_ICON); 00770 strcpy(image_alt,EXTERNAL_COMMAND_ICON_ALT); 00771 } 00772 else if(temp_entry->type==LOGENTRY_PASSIVE_SERVICE_CHECK){ 00773 strcpy(image,PASSIVE_ICON); 00774 strcpy(image_alt,"Passive Service Check"); 00775 } 00776 else if(temp_entry->type==LOGENTRY_PASSIVE_HOST_CHECK){ 00777 strcpy(image,PASSIVE_ICON); 00778 strcpy(image_alt,"Passive Host Check"); 00779 } 00780 else if(temp_entry->type==LOGENTRY_LOG_ROTATION){ 00781 strcpy(image,LOG_ROTATION_ICON); 00782 strcpy(image_alt,LOG_ROTATION_ICON_ALT); 00783 } 00784 else if(temp_entry->type==LOGENTRY_ACTIVE_MODE){ 00785 strcpy(image,ACTIVE_ICON); 00786 strcpy(image_alt,ACTIVE_ICON_ALT); 00787 } 00788 else if(temp_entry->type==LOGENTRY_STANDBY_MODE){ 00789 strcpy(image,STANDBY_ICON); 00790 strcpy(image_alt,STANDBY_ICON_ALT); 00791 } 00792 else if(temp_entry->type==LOGENTRY_SERVICE_FLAPPING_STARTED){ 00793 strcpy(image,FLAPPING_ICON); 00794 strcpy(image_alt,"Service started flapping"); 00795 } 00796 else if(temp_entry->type==LOGENTRY_SERVICE_FLAPPING_STOPPED){ 00797 strcpy(image,FLAPPING_ICON); 00798 strcpy(image_alt,"Service stopped flapping"); 00799 } 00800 else if(temp_entry->type==LOGENTRY_SERVICE_FLAPPING_DISABLED){ 00801 strcpy(image,FLAPPING_ICON); 00802 strcpy(image_alt,"Service flap detection disabled"); 00803 } 00804 else if(temp_entry->type==LOGENTRY_HOST_FLAPPING_STARTED){ 00805 strcpy(image,FLAPPING_ICON); 00806 strcpy(image_alt,"Host started flapping"); 00807 } 00808 else if(temp_entry->type==LOGENTRY_HOST_FLAPPING_STOPPED){ 00809 strcpy(image,FLAPPING_ICON); 00810 strcpy(image_alt,"Host stopped flapping"); 00811 } 00812 else if(temp_entry->type==LOGENTRY_HOST_FLAPPING_DISABLED){ 00813 strcpy(image,FLAPPING_ICON); 00814 strcpy(image_alt,"Host flap detection disabled"); 00815 } 00816 else if(temp_entry->type==LOGENTRY_SERVICE_DOWNTIME_STARTED){ 00817 strcpy(image,SCHEDULED_DOWNTIME_ICON); 00818 strcpy(image_alt,"Service entered a period of scheduled downtime"); 00819 } 00820 else if(temp_entry->type==LOGENTRY_SERVICE_DOWNTIME_STOPPED){ 00821 strcpy(image,SCHEDULED_DOWNTIME_ICON); 00822 strcpy(image_alt,"Service exited a period of scheduled downtime"); 00823 } 00824 else if(temp_entry->type==LOGENTRY_SERVICE_DOWNTIME_CANCELLED){ 00825 strcpy(image,SCHEDULED_DOWNTIME_ICON); 00826 strcpy(image_alt,"Service scheduled downtime has been cancelled"); 00827 } 00828 else if(temp_entry->type==LOGENTRY_HOST_DOWNTIME_STARTED){ 00829 strcpy(image,SCHEDULED_DOWNTIME_ICON); 00830 strcpy(image_alt,"Host entered a period of scheduled downtime"); 00831 } 00832 else if(temp_entry->type==LOGENTRY_HOST_DOWNTIME_STOPPED){ 00833 strcpy(image,SCHEDULED_DOWNTIME_ICON); 00834 strcpy(image_alt,"Host exited a period of scheduled downtime"); 00835 } 00836 else if(temp_entry->type==LOGENTRY_HOST_DOWNTIME_CANCELLED){ 00837 strcpy(image,SCHEDULED_DOWNTIME_ICON); 00838 strcpy(image_alt,"Host scheduled downtime has been cancelled"); 00839 } 00840 else if(temp_entry->type==LOGENTRY_IDOMOD){ 00841 strcpy(image,DATABASE_ICON); 00842 strcpy(image_alt,"IDOMOD Information"); 00843 } 00844 else if(temp_entry->type==LOGENTRY_NPCDMOD){ 00845 strcpy(image,STATS_ICON); 00846 strcpy(image_alt,"NPCDMOD Information"); 00847 } 00848 else if(temp_entry->type==LOGENTRY_AUTOSAVE){ 00849 strcpy(image,AUTOSAVE_ICON); 00850 strcpy(image_alt,"Auto-save retention data"); 00851 } 00852 else if(temp_entry->type==LOGENTRY_SYSTEM_WARNING){ 00853 strcpy(image,DAEMON_WARNING_ICON); 00854 strcpy(image_alt,"Icinga warning message"); 00855 } 00856 else{ 00857 strcpy(image,INFO_ICON); 00858 strcpy(image_alt,INFO_ICON_ALT); 00859 } 00860 00861 time_ptr=localtime(&temp_entry->timestamp); 00862 strftime(current_message_date,sizeof(current_message_date),"%B %d, %Y %H:00",time_ptr); 00863 current_message_date[sizeof(current_message_date)-1]='\x0'; 00864 00865 if(strcmp(last_message_date,current_message_date)!=0 && display_timebreaks==TRUE){ 00866 printf("</DIV>\n"); 00867 printf("<BR>\n"); 00868 printf("<DIV>\n"); 00869 printf("<table border=0 width=99%% CLASS='dateTimeBreak' align=center><tr>"); 00870 printf("<td width=40%%><hr width=100%%></td>"); 00871 printf("<td align=center CLASS='dateTimeBreak'>%s</td>",current_message_date); 00872 printf("<td width=40%%><hr width=100%%></td>"); 00873 printf("</tr></table>\n"); 00874 printf("</DIV>\n"); 00875 printf("<BR><DIV CLASS='logEntries'>\n"); 00876 strncpy(last_message_date,current_message_date,sizeof(last_message_date)); 00877 last_message_date[sizeof(last_message_date)-1]='\x0'; 00878 } 00879 00880 get_time_string(&temp_entry->timestamp,date_time,(int)sizeof(date_time),SHORT_DATE_TIME); 00881 strip(date_time); 00882 00883 /* preparing logentries for json and csv output */ 00884 if(content_type==CSV_CONTENT || content_type==JSON_CONTENT){ 00885 for (i = 0; i < strlen(temp_entry->entry_text)-1; i++) 00886 *(temp_entry->entry_text+i) = *(temp_entry->entry_text+i+1); 00887 temp_entry->entry_text[strlen(temp_entry->entry_text)-1]='\x0'; 00888 } 00889 00890 /* displays log entry depending on requested content type */ 00891 if(content_type==JSON_CONTENT) { 00892 // always add a comma, except for the first line 00893 if (json_start==FALSE) 00894 printf(",\n"); 00895 json_start=FALSE; 00896 printf("{ \"timestamp\": %lu, ",temp_entry->timestamp); 00897 printf(" \"date_time\": \"%s\", ",date_time); 00898 printf(" \"log_entry\": \"%s\"}",json_encode(temp_entry->entry_text)); 00899 }else if(content_type==CSV_CONTENT) { 00900 printf("%s%lu%s%s",csv_data_enclosure,temp_entry->timestamp,csv_data_enclosure,csv_delimiter); 00901 printf("%s%s%s%s",csv_data_enclosure,date_time,csv_data_enclosure,csv_delimiter); 00902 printf("%s%s%s\n",csv_data_enclosure,temp_entry->entry_text,csv_data_enclosure); 00903 }else{ 00904 if(display_frills==TRUE) 00905 printf("<img align=left src='%s%s' alt='%s' title='%s'>",url_images_path,image,image_alt,image_alt); 00906 printf("[%s] %s",date_time,(temp_entry->entry_text==NULL)?"":html_encode(temp_entry->entry_text,FALSE)); 00907 if(enable_splunk_integration==TRUE){ 00908 printf(" "); 00909 display_splunk_generic_url(temp_entry->entry_text,2); 00910 } 00911 printf("<br clear=all>\n"); 00912 } 00913 00914 user_has_seen_something=TRUE; 00915 count++; 00916 } 00917 00918 if(content_type!=CSV_CONTENT && content_type!=JSON_CONTENT){ 00919 printf("</DIV><br><div align=center>%d entries displayed</div><HR>\n",count); 00920 }else if (content_type==JSON_CONTENT) 00921 printf("\n]\n"); 00922 00923 } 00924 00925 free_log_entries(); 00926 00927 if (user_has_seen_something==FALSE && content_type!=CSV_CONTENT) 00928 printf("<P><DIV CLASS='warningMessage'>No log entries found!</DIV></P>"); 00929 00930 return; 00931 } 00932 00933 void show_filter(void) { 00934 char buffer[MAX_INPUT_BUFFER]; 00935 int temp_htmlencode=escape_html_tags; 00936 00937 // escape all characters, otherwise they won't show up in search box 00938 escape_html_tags=TRUE; 00939 00940 printf("<form method='GET' action='%s'>\n",SHOWLOG_CGI); 00941 printf("<input type='hidden' name='ts_start' value='%lu'>\n",ts_start); 00942 printf("<input type='hidden' name='ts_end' value='%lu'>\n",ts_end); 00943 00944 printf("<table id='filters' border=0 cellspacing=2 cellpadding=2>\n"); 00945 00946 /* search box */ 00947 printf("<tr><td align=right width='10%%'>Search:</td>"); 00948 printf("<td nowrap><input type='text' name='query_string' id='query_string' size='15' class='NavBarSearchItem' value='%s'>",(query_string==NULL)?"":html_encode(query_string,TRUE)); 00949 printf(" <input type='button' value='Clear' onClick=\"document.getElementById('query_string').value = '';\"></td></tr>"); 00950 00951 /* Order */ 00952 printf("<tr><td align=right>Order:</td>"); 00953 printf("<td nowrap><input type=radio name='order' value='new2old' %s> Newer Entries First | <input type=radio name='order' value='old2new' %s> Older Entries First</td></tr>",(reverse==TRUE)?"":"checked",(reverse==TRUE)?"checked":""); 00954 00955 /* Timeperiod */ 00956 printf("<tr><td align=left>Timeperiod:</td>"); 00957 printf("<td align=left>"); 00958 00959 printf("<select id='selecttp' name='timeperiod' onChange=\"var i=document.getElementById('selecttp').selectedIndex; if (document.getElementById('selecttp').options[i].value == 'custom') { document.getElementById('custtime').style.display = ''; } else { document.getElementById('custtime').style.display = 'none';}\">\n"); 00960 printf("<option value=singleday %s>Single Day\n",(timeperiod_type==TIMEPERIOD_SINGLE_DAY)?"selected":""); 00961 printf("<option value=today %s>Today\n",(timeperiod_type==TIMEPERIOD_TODAY)?"selected":""); 00962 printf("<option value=last24hours %s>Last 24 Hours\n",(timeperiod_type==TIMEPERIOD_LAST24HOURS)?"selected":""); 00963 printf("<option value=thisweek %s>This Week\n",(timeperiod_type==TIMEPERIOD_THISWEEK)?"selected":""); 00964 printf("<option value=last7days %s>Last 7 Days\n",(timeperiod_type==TIMEPERIOD_LAST7DAYS)?"selected":""); 00965 printf("<option value=lastweek %s>Last Week\n",(timeperiod_type==TIMEPERIOD_LASTWEEK)?"selected":""); 00966 printf("<option value=thismonth %s>This Month\n",(timeperiod_type==TIMEPERIOD_THISMONTH)?"selected":""); 00967 printf("<option value=last31days %s>Last 31 Days\n",(timeperiod_type==TIMEPERIOD_LAST31DAYS)?"selected":""); 00968 printf("<option value=lastmonth %s>Last Month\n",(timeperiod_type==TIMEPERIOD_LASTMONTH)?"selected":""); 00969 printf("<option value=thisyear %s>This Year\n",(timeperiod_type==TIMEPERIOD_THISYEAR)?"selected":""); 00970 printf("<option value=lastyear %s>Last Year\n",(timeperiod_type==TIMEPERIOD_LASTYEAR)?"selected":""); 00971 printf("<option value=custom %s>* CUSTOM PERIOD *\n",(timeperiod_type==TIMEPERIOD_CUSTOM)?"selected":""); 00972 printf("</select>\n"); 00973 printf("<div id='custtime' style='display:%s;'>",(timeperiod_type==TIMEPERIOD_CUSTOM)?"":"none"); 00974 00975 printf("<br><table border=0 cellspacing=0 cellpadding=0>\n"); 00976 get_time_string(&ts_start,buffer,sizeof(buffer)-1,SHORT_DATE_TIME); 00977 printf("<tr><td>Start: </td><td><INPUT TYPE='TEXT' NAME='start_time' VALUE='%s' SIZE=\"25\"></td></tr>",buffer); 00978 00979 get_time_string(&ts_end,buffer,sizeof(buffer)-1,SHORT_DATE_TIME); 00980 printf("<tr><td>End: </td><td><INPUT TYPE='TEXT' NAME='end_time' VALUE='%s' SIZE=\"25\"></td></tr></table></div>",buffer); 00981 00982 printf("</td></tr>\n"); 00983 00984 /* Filter Entry types */ 00985 printf("<tr><td>Entry Type:</td><td>\n"); 00986 printf("<table border=0 cellspacing=0 cellpadding=0>\n"); 00987 printf("<tr><td align=center>on</td><td align=center>off</td><td>Type</td></tr>\n"); 00988 printf("<tr><td><input type=radio name='noti' value=on %s></td><td><input type=radio name='noti' value=off %s></td><td>Notifications</td></tr>\n",(show_notifications==TRUE)?"checked":"",(show_notifications==FALSE)?"checked":""); 00989 printf("<tr><td><input type=radio name='hst' value=on %s></td><td><input type=radio name='hst' value=off %s></td><td>Host Status</td></tr>\n",(show_host_status==TRUE)?"checked":"",(show_host_status==FALSE)?"checked":""); 00990 printf("<tr><td><input type=radio name='sst' value=on %s></td><td><input type=radio name='sst' value=off %s></td><td>Service Status</td></tr>\n",(show_service_status==TRUE)?"checked":"",(show_service_status==FALSE)?"checked":""); 00991 printf("<tr><td><input type=radio name='cmd' value=on %s></td><td><input type=radio name='cmd' value=off %s></td><td>External Commands</td></tr>\n",(show_external_commands==TRUE)?"checked":"",(show_external_commands==FALSE)?"checked":""); 00992 printf("<tr><td><input type=radio name='sms' value=on %s></td><td><input type=radio name='sms' value=off %s></td><td>System Messages</td></tr>\n",(show_system_messages==TRUE)?"checked":"",(show_system_messages==FALSE)?"checked":""); 00993 printf("<tr><td><input type=radio name='evh' value=on %s></td><td><input type=radio name='evh' value=off %s></td><td>Event Handler</td></tr>\n",(show_event_handler==TRUE)?"checked":"",(show_event_handler==FALSE)?"checked":""); 00994 printf("<tr><td><input type=radio name='flp' value=on %s></td><td><input type=radio name='flp' value=off %s></td><td>Flapping</td></tr>\n",(show_flapping==TRUE)?"checked":"",(show_flapping==FALSE)?"checked":""); 00995 printf("<tr><td><input type=radio name='dwn' value=on %s></td><td><input type=radio name='dwn' value=off %s></td><td>Downtime</td></tr>\n",(show_downtime==TRUE)?"checked":"",(show_downtime==FALSE)?"checked":""); 00996 00997 printf("</table>\n"); 00998 printf("</td></tr>\n"); 00999 01000 /* submit Button */ 01001 printf("<tr><td><input type='submit' value='Apply'></td><td align=right><input type='reset' value='Reset' onClick=\"window.location.href='%s?order=new2old&timeperiod=singleday&ts_start=%lu&ts_end=%lu'\"> </td></tr>\n",SHOWLOG_CGI,ts_start,ts_end); 01002 01003 printf("</table>\n"); 01004 01005 printf("</form>\n"); 01006 01007 escape_html_tags=temp_htmlencode; 01008 return; 01009 } 01010 01011 void display_own_nav_table(){ 01012 char *url; 01013 char temp_buffer[MAX_INPUT_BUFFER]; 01014 char date_time[MAX_INPUT_BUFFER]; 01015 int dummy; 01016 01017 /* construct url */ 01018 dummy = asprintf(&url,"%s?timeperiod=singleday&order=%s",SHOWLOG_CGI,(reverse==TRUE)?"old2new":"new2old"); 01019 01020 if (query_string!=NULL) { 01021 strncpy(temp_buffer,url,sizeof(temp_buffer)); 01022 dummy = asprintf(&url,"%s&query_string=%s",temp_buffer,url_encode(query_string)); 01023 } 01024 if (show_notifications==FALSE) { 01025 strncpy(temp_buffer,url,sizeof(temp_buffer)); 01026 dummy = asprintf(&url,"%s¬i=off",temp_buffer); 01027 } 01028 if (show_host_status==FALSE) { 01029 strncpy(temp_buffer,url,sizeof(temp_buffer)); 01030 dummy = asprintf(&url,"%s&hst=off",temp_buffer); 01031 } 01032 if (show_service_status==FALSE) { 01033 strncpy(temp_buffer,url,sizeof(temp_buffer)); 01034 dummy = asprintf(&url,"%s&sst=off",temp_buffer); 01035 } 01036 if (show_external_commands==FALSE) { 01037 strncpy(temp_buffer,url,sizeof(temp_buffer)); 01038 dummy = asprintf(&url,"%s&cmd=off",temp_buffer); 01039 } 01040 if (show_system_messages==FALSE) { 01041 strncpy(temp_buffer,url,sizeof(temp_buffer)); 01042 dummy = asprintf(&url,"%s&sms=off",temp_buffer); 01043 } 01044 if (show_event_handler==FALSE) { 01045 strncpy(temp_buffer,url,sizeof(temp_buffer)); 01046 dummy = asprintf(&url,"%s&evh=off",temp_buffer); 01047 } 01048 if (show_flapping==FALSE) { 01049 strncpy(temp_buffer,url,sizeof(temp_buffer)); 01050 dummy = asprintf(&url,"%s&flp=off",temp_buffer); 01051 } 01052 if (show_downtime==FALSE) { 01053 strncpy(temp_buffer,url,sizeof(temp_buffer)); 01054 dummy = asprintf(&url,"%s&dwn=off",temp_buffer); 01055 } 01056 01057 /* show table */ 01058 printf("<table border=0 cellspacing=0 cellpadding=0 CLASS='navBox'>\n"); 01059 printf("<tr>\n"); 01060 printf("<td align=center valign=center CLASS='navBoxItem'>\n"); 01061 if(ts_end>ts_midnight){ 01062 printf("Latest Archive<br>"); 01063 printf("<a href='%s&ts_start=%lu&ts_end=%lu'><img src='%s%s' border=0 alt='Latest Archive' title='Latest Archive'></a>",url,ts_midnight-86400,ts_midnight-1,url_images_path,LEFT_ARROW_ICON); 01064 }else{ 01065 printf("Earlier Archive<br>"); 01066 printf("<a href='%s&ts_start=%lu&ts_end=%lu'><img src='%s%s' border=0 alt='Earlier Archive' title='Earlier Archive'></a>",url,ts_start-86400,ts_start-1,url_images_path,LEFT_ARROW_ICON); 01067 } 01068 printf("</td>\n"); 01069 01070 printf("<td width=15></td>\n"); 01071 01072 printf("<td align=center CLASS='navBoxDate'>\n"); 01073 printf("<DIV CLASS='navBoxTitle'>Log Navigation</DIV>\n"); 01074 get_time_string(&ts_start,date_time,(int)sizeof(date_time),LONG_DATE_TIME); 01075 printf("%s",date_time); 01076 printf("<br>to<br>"); 01077 if(ts_end>ts_midnight) 01078 printf("Present.."); 01079 else{ 01080 get_time_string(&ts_end,date_time,(int)sizeof(date_time),LONG_DATE_TIME); 01081 printf("%s",date_time); 01082 } 01083 printf("</td>\n"); 01084 01085 printf("<td width=15></td>\n"); 01086 01087 if(ts_end<=ts_midnight){ 01088 01089 printf("<td align=center valign=center CLASS='navBoxItem'>\n"); 01090 if(ts_end==ts_midnight){ 01091 printf("Current Log<br>"); 01092 printf("<a href='%s&ts_start=%lu&ts_end=%lu'><img src='%s%s' border=0 alt='Current Log' title='Current Log'></a>",url,ts_midnight+1,ts_midnight+86400,url_images_path,RIGHT_ARROW_ICON); 01093 }else{ 01094 printf("More Recent Archive<br>"); 01095 printf("<a href='%s&ts_start=%lu&ts_end=%lu'><img src='%s%s' border=0 alt='More Recent Archive' title='More Recent Archive'></a>",url,ts_end+1,ts_end+86400,url_images_path,RIGHT_ARROW_ICON); 01096 } 01097 printf("</td>\n"); 01098 } else 01099 printf("<td><img src='%s%s' border=0 width=75 height=1></td>\n",url_images_path,EMPTY_ICON); 01100 01101 printf("</tr>\n"); 01102 01103 printf("</table>\n"); 01104 01105 return; 01106 }