![]() |
Icinga-core 1.4.0
next gen monitoring
|
00001 /***************************************************************************** 00002 * 00003 * IDOMOD.C - Icinga Data Output Event Broker Module 00004 * 00005 * Copyright (c) 2005-2007 Ethan Galstad 00006 * Copyright (c) 2009-2011 Icinga Development Team (http://www.icinga.org) 00007 * 00008 *****************************************************************************/ 00009 00010 /* include our project's header files */ 00011 #include "../../../include/config.h" 00012 #include "../include/common.h" 00013 #include "../include/io.h" 00014 #include "../include/utils.h" 00015 #include "../include/protoapi.h" 00016 #include "../include/idomod.h" 00017 00018 /* include (minimum required) event broker header files */ 00019 #include "../../../include/nebstructs.h" 00020 #include "../../../include/nebmodules.h" 00021 #include "../../../include/nebcallbacks.h" 00022 #include "../../../include/broker.h" 00023 00024 /* include other Icinga header files for access to functions, data structs, etc. */ 00025 #include "../../../include/common.h" 00026 #include "../../../include/icinga.h" 00027 #include "../../../include/downtime.h" 00028 #include "../../../include/comments.h" 00029 #include "../../../include/macros.h" 00030 00031 /* specify event broker API version (required) */ 00032 NEB_API_VERSION(CURRENT_NEB_API_VERSION) 00033 00034 00035 00036 void *idomod_module_handle=NULL; 00037 char *idomod_instance_name=NULL; 00038 char *idomod_buffer_file=NULL; 00039 char *idomod_sink_name=NULL; 00040 int idomod_sink_type=IDO_SINK_UNIXSOCKET; 00041 int idomod_sink_tcp_port=IDO_DEFAULT_TCP_PORT; 00042 int idomod_sink_is_open=IDO_FALSE; 00043 int idomod_sink_previously_open=IDO_FALSE; 00044 int idomod_sink_fd=-1; 00045 time_t idomod_sink_last_reconnect_attempt=0L; 00046 time_t idomod_sink_last_reconnect_warning=0L; 00047 unsigned long idomod_sink_connect_attempt=0L; 00048 unsigned long idomod_sink_reconnect_interval=15; 00049 unsigned long idomod_sink_reconnect_warning_interval=900; 00050 unsigned long idomod_sink_rotation_interval=3600; 00051 char *idomod_sink_rotation_command=NULL; 00052 int idomod_sink_rotation_timeout=60; 00053 int idomod_allow_sink_activity=IDO_TRUE; 00054 unsigned long idomod_process_options=IDOMOD_PROCESS_EVERYTHING; 00055 int idomod_config_output_options=IDOMOD_CONFIG_DUMP_ALL; 00056 unsigned long idomod_sink_buffer_slots=5000; 00057 idomod_sink_buffer sinkbuf; 00058 00059 char *idomod_debug_file=NULL; 00060 int idomod_debug_level=IDOMOD_DEBUGL_NONE; 00061 int idomod_debug_verbosity=IDOMOD_DEBUGV_BASIC; 00062 FILE *idomod_debug_file_fp=NULL; 00063 unsigned long idomod_max_debug_file_size=0L; 00064 00065 int idomod_open_debug_log(void); 00066 int idomod_close_debug_log(void); 00067 00068 extern int errno; 00069 00070 /**** Icinga VARIABLES ****/ 00071 extern command *command_list; 00072 extern timeperiod *timeperiod_list; 00073 extern contact *contact_list; 00074 extern contactgroup *contactgroup_list; 00075 extern host *host_list; 00076 extern hostgroup *hostgroup_list; 00077 extern service *service_list; 00078 extern servicegroup *servicegroup_list; 00079 extern hostescalation *hostescalation_list; 00080 extern serviceescalation *serviceescalation_list; 00081 extern hostdependency *hostdependency_list; 00082 extern servicedependency *servicedependency_list; 00083 00084 extern char *config_file; 00085 extern sched_info scheduling_info; 00086 extern char *global_host_event_handler; 00087 extern char *global_service_event_handler; 00088 00089 extern int __icinga_object_structure_version; 00090 00091 extern int use_ssl; 00092 00093 #define DEBUG_IDO 1 00094 00095 00096 00097 /* this function gets called when the module is loaded by the event broker */ 00098 int nebmodule_init(int flags, char *args, void *handle){ 00099 char temp_buffer[IDOMOD_MAX_BUFLEN]; 00100 00101 /* save our handle */ 00102 idomod_module_handle=handle; 00103 00104 /* log module info to the Icinga log file */ 00105 snprintf(temp_buffer, sizeof(temp_buffer)-1, "idomod: %s %s (%s) Copyright (c) 2005-2008 Ethan Galstad (nagios@nagios.org), Copyright (c) 2009-2011 Icinga Development Team (http://www.icinga.org))", IDOMOD_NAME, IDOMOD_VERSION, IDOMOD_DATE); 00106 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 00107 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00108 00109 /* check Icinga object structure version */ 00110 if(idomod_check_icinga_object_version()==IDO_ERROR) 00111 return -1; 00112 00113 /* process arguments */ 00114 if(idomod_process_module_args(args)==IDO_ERROR){ 00115 idomod_write_to_logs("idomod: An error occurred while attempting to process module arguments.",NSLOG_INFO_MESSAGE); 00116 return -1; 00117 } 00118 00119 if(idomod_sink_type==IDO_SINK_UNIXSOCKET && use_ssl == IDO_TRUE){ 00120 idomod_write_to_logs("idomod: use_ssl=1 while using socket_type=unix is not allowed. Aborting...",NSLOG_INFO_MESSAGE); 00121 return -1; 00122 } 00123 00124 /* do some initialization stuff... */ 00125 if(idomod_init()==IDO_ERROR){ 00126 idomod_write_to_logs("idomod: An error occurred while attempting to initialize.",NSLOG_INFO_MESSAGE); 00127 return -1; 00128 } 00129 00130 return 0; 00131 } 00132 00133 00134 /* this function gets called when the module is unloaded by the event broker */ 00135 int nebmodule_deinit(int flags, int reason){ 00136 char temp_buffer[IDOMOD_MAX_BUFLEN]; 00137 00138 /* do some shutdown stuff... */ 00139 idomod_deinit(); 00140 00141 /* log a message to the Icinga log file */ 00142 snprintf(temp_buffer,sizeof(temp_buffer)-1,"idomod: Shutdown complete.\n"); 00143 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 00144 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00145 00146 return 0; 00147 } 00148 00149 00150 00151 /****************************************************************************/ 00152 /* INIT/DEINIT FUNCTIONS */ 00153 /****************************************************************************/ 00154 00155 /* checks to make sure Icinga object version matches what we know about */ 00156 int idomod_check_icinga_object_version(void){ 00157 char temp_buffer[IDOMOD_MAX_BUFLEN]; 00158 00159 if(__icinga_object_structure_version!=CURRENT_OBJECT_STRUCTURE_VERSION){ 00160 00161 snprintf(temp_buffer,sizeof(temp_buffer)-1,"idomod: I've been compiled with support for revision %d of the internal Icinga object structures, but the Icinga daemon is currently using revision %d. I'm going to unload so I don't cause any problems...\n",CURRENT_OBJECT_STRUCTURE_VERSION,__icinga_object_structure_version); 00162 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 00163 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00164 00165 return IDO_ERROR; 00166 } 00167 00168 return IDO_OK; 00169 } 00170 00171 00172 /* performs some initialization stuff */ 00173 int idomod_init(void){ 00174 char temp_buffer[IDOMOD_MAX_BUFLEN]; 00175 time_t current_time; 00176 00177 /* open debug log */ 00178 idomod_open_debug_log(); 00179 00180 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_init() start\n"); 00181 00182 /* initialize some vars (needed for restarts of daemon - why, if the module gets reloaded ???) */ 00183 idomod_sink_is_open=IDO_FALSE; 00184 idomod_sink_previously_open=IDO_FALSE; 00185 idomod_sink_fd=-1; 00186 idomod_sink_last_reconnect_attempt=0L; 00187 idomod_sink_last_reconnect_warning=0L; 00188 idomod_allow_sink_activity=IDO_TRUE; 00189 00190 /* initialize data sink buffer */ 00191 idomod_sink_buffer_init(&sinkbuf,idomod_sink_buffer_slots); 00192 00193 /* read unprocessed data from buffer file */ 00194 idomod_load_unprocessed_data(idomod_buffer_file); 00195 00196 /* open data sink and say hello */ 00197 /* 05/04/06 - modified to flush buffer items that may have been read in from file */ 00198 idomod_write_to_sink("\n",IDO_FALSE,IDO_TRUE); 00199 00200 /* register callbacks */ 00201 if(idomod_register_callbacks()==IDO_ERROR) 00202 return IDO_ERROR; 00203 00204 if(idomod_sink_type==IDO_SINK_FILE){ 00205 00206 /* make sure we have a rotation command defined... */ 00207 if(idomod_sink_rotation_command==NULL){ 00208 00209 /* log an error message to the Icinga log file */ 00210 snprintf(temp_buffer,sizeof(temp_buffer)-1,"idomod: Warning - No file rotation command defined.\n"); 00211 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 00212 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00213 } 00214 00215 /* schedule a file rotation event */ 00216 else{ 00217 time(¤t_time); 00218 schedule_new_event(EVENT_USER_FUNCTION,TRUE,current_time+idomod_sink_rotation_interval,TRUE,idomod_sink_rotation_interval,NULL,TRUE,(void *)idomod_rotate_sink_file,NULL,0); 00219 } 00220 } 00221 00222 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_init() end\n"); 00223 00224 return IDO_OK; 00225 } 00226 00227 00228 /* performs some shutdown stuff */ 00229 int idomod_deinit(void){ 00230 00231 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_deinit() start\n"); 00232 00233 /* deregister callbacks */ 00234 idomod_deregister_callbacks(); 00235 00236 /* save unprocessed data to buffer file */ 00237 idomod_save_unprocessed_data(idomod_buffer_file); 00238 00239 /* clear sink buffer */ 00240 idomod_sink_buffer_deinit(&sinkbuf); 00241 00242 /* close data sink */ 00243 idomod_goodbye_sink(); 00244 idomod_close_sink(); 00245 00246 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_deinit() end\n"); 00247 00248 /* close debug log */ 00249 idomod_close_debug_log(); 00250 00251 return IDO_OK; 00252 } 00253 00254 00255 00256 /****************************************************************************/ 00257 /* CONFIG FUNCTIONS */ 00258 /****************************************************************************/ 00259 00260 /* process arguments that were passed to the module at startup */ 00261 int idomod_process_module_args(char *args){ 00262 char *ptr=NULL; 00263 char **arglist=NULL; 00264 char **newarglist=NULL; 00265 int argcount=0; 00266 int memblocks=64; 00267 int arg=0; 00268 00269 if(args==NULL) 00270 return IDO_OK; 00271 00272 00273 /* get all the var/val argument pairs */ 00274 00275 /* allocate some memory */ 00276 if((arglist=(char **)malloc(memblocks*sizeof(char **)))==NULL) 00277 return IDO_ERROR; 00278 00279 /* process all args */ 00280 ptr=strtok(args,","); 00281 while(ptr){ 00282 00283 /* save the argument */ 00284 arglist[argcount++]=strdup(ptr); 00285 00286 /* allocate more memory if needed */ 00287 if(!(argcount%memblocks)){ 00288 if((newarglist=(char **)realloc(arglist,(argcount+memblocks)*sizeof(char **)))==NULL){ 00289 for(arg=0;arg<argcount;arg++) 00290 free(arglist[argcount]); 00291 free(arglist); 00292 return IDO_ERROR; 00293 } 00294 else 00295 arglist=newarglist; 00296 } 00297 00298 ptr=strtok(NULL,","); 00299 } 00300 00301 /* terminate the arg list */ 00302 arglist[argcount]='\x0'; 00303 00304 00305 /* process each argument */ 00306 for(arg=0;arg<argcount;arg++){ 00307 if(idomod_process_config_var(arglist[arg])==IDO_ERROR){ 00308 for(arg=0;arg<argcount;arg++) 00309 free(arglist[arg]); 00310 free(arglist); 00311 return IDO_ERROR; 00312 } 00313 } 00314 00315 /* free allocated memory */ 00316 for(arg=0;arg<argcount;arg++) 00317 free(arglist[arg]); 00318 free(arglist); 00319 00320 return IDO_OK; 00321 } 00322 00323 00324 /* process all config vars in a file */ 00325 int idomod_process_config_file(char *filename){ 00326 ido_mmapfile *thefile=NULL; 00327 char *buf=NULL; 00328 char temp_buffer[IDOMOD_MAX_BUFLEN]; 00329 int result=IDO_OK; 00330 00331 /* open the file */ 00332 if((thefile=ido_mmap_fopen(filename))==NULL){ 00333 snprintf(temp_buffer,sizeof(temp_buffer)-1,"idomod: Unable to open configuration file %s: %s\n", filename, strerror(errno)); 00334 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 00335 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00336 return IDO_ERROR; 00337 } 00338 00339 /* process each line of the file */ 00340 while((buf=ido_mmap_fgets(thefile))){ 00341 00342 /* skip comments */ 00343 if(buf[0]=='#'){ 00344 free(buf); 00345 continue; 00346 } 00347 00348 /* skip blank lines */ 00349 if(!strcmp(buf,"")){ 00350 free(buf); 00351 continue; 00352 } 00353 00354 /* process the variable */ 00355 result=idomod_process_config_var(buf); 00356 00357 /* free memory */ 00358 free(buf); 00359 00360 if(result!=IDO_OK) 00361 break; 00362 } 00363 00364 /* close the file */ 00365 ido_mmap_fclose(thefile); 00366 00367 return result; 00368 } 00369 00370 00371 /* process a single module config variable */ 00372 int idomod_process_config_var(char *arg){ 00373 char *var=NULL; 00374 char *val=NULL; 00375 00376 char temp_buffer[IDOMOD_MAX_BUFLEN]; 00377 00378 /* split var/val */ 00379 var=strtok(arg,"="); 00380 val=strtok(NULL,"\n"); 00381 00382 /* skip incomplete var/val pairs */ 00383 if(var==NULL || val==NULL) 00384 return IDO_OK; 00385 00386 /* strip var/val */ 00387 idomod_strip(var); 00388 idomod_strip(val); 00389 00390 /* process the variable... */ 00391 00392 if(!strcmp(var,"config_file")) 00393 return idomod_process_config_file(val); 00394 00395 else if(!strcmp(var,"instance_name")) 00396 idomod_instance_name=strdup(val); 00397 00398 else if(!strcmp(var,"output")) 00399 idomod_sink_name=strdup(val); 00400 00401 else if(!strcmp(var,"output_type")){ 00402 if(!strcmp(val,"file")) 00403 idomod_sink_type=IDO_SINK_FILE; 00404 else if(!strcmp(val,"tcpsocket")) 00405 idomod_sink_type=IDO_SINK_TCPSOCKET; 00406 else 00407 idomod_sink_type=IDO_SINK_UNIXSOCKET; 00408 } 00409 00410 else if(!strcmp(var,"tcp_port")) 00411 idomod_sink_tcp_port=atoi(val); 00412 00413 else if(!strcmp(var,"output_buffer_items")) 00414 idomod_sink_buffer_slots=strtoul(val,NULL,0); 00415 00416 else if(!strcmp(var,"reconnect_interval")) 00417 idomod_sink_reconnect_interval=strtoul(val,NULL,0); 00418 00419 else if(!strcmp(var,"reconnect_warning_interval")) 00420 idomod_sink_reconnect_warning_interval=strtoul(val,NULL,0); 00421 00422 else if(!strcmp(var,"file_rotation_interval")) 00423 idomod_sink_rotation_interval=strtoul(val,NULL,0); 00424 00425 else if(!strcmp(var,"file_rotation_command")) 00426 idomod_sink_rotation_command=strdup(val); 00427 00428 else if(!strcmp(var,"file_rotation_timeout")) 00429 idomod_sink_rotation_timeout=atoi(val); 00430 00431 else if(!strcmp(var,"data_processing_options")){ 00432 if(!strcmp(val,"-1")) 00433 idomod_process_options=IDOMOD_PROCESS_EVERYTHING; 00434 else 00435 idomod_process_options=strtoul(val,NULL,0); 00436 } 00437 00438 else if(!strcmp(var,"config_output_options")) 00439 idomod_config_output_options=atoi(val); 00440 00441 else if(!strcmp(var,"buffer_file")) 00442 idomod_buffer_file=strdup(val); 00443 00444 else if(!strcmp(var,"debug_file")){ 00445 if((idomod_debug_file=strdup(val))==NULL) 00446 return IDO_ERROR; 00447 } 00448 else if(!strcmp(var,"debug_level")) 00449 idomod_debug_level=atoi(val); 00450 else if(!strcmp(var,"debug_verbosity")) 00451 idomod_debug_verbosity=atoi(val); 00452 else if(!strcmp(var,"max_debug_file_size")) 00453 idomod_max_debug_file_size=strtoul(val,NULL,0); 00454 00455 else if(!strcmp(var,"use_ssl")){ 00456 if (strlen(val) == 1) { 00457 if (isdigit((int)val[strlen(val)-1]) != IDO_FALSE) 00458 use_ssl = atoi(val); 00459 else 00460 use_ssl = 0; 00461 } 00462 } 00463 00464 else { 00465 /* log an error message to the Icinga log file */ 00466 snprintf(temp_buffer,sizeof(temp_buffer)-1,"idomod: ERROR - Unknown config file variable '%s'.\n", var); 00467 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 00468 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00469 00470 return IDO_ERROR; 00471 } 00472 00473 return IDO_OK; 00474 } 00475 00476 00477 00478 /****************************************************************************/ 00479 /* UTILITY FUNCTIONS */ 00480 /****************************************************************************/ 00481 00482 /* writes a string to Icinga logs */ 00483 int idomod_write_to_logs(char *buf, int flags){ 00484 00485 if(buf==NULL) 00486 return IDO_ERROR; 00487 00488 return write_to_all_logs(buf,flags); 00489 } 00490 00491 00492 00493 /****************************************************************************/ 00494 /* DATA SINK FUNCTIONS */ 00495 /****************************************************************************/ 00496 00497 /* (re)open data sink */ 00498 int idomod_open_sink(void){ 00499 int flags=0; 00500 00501 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_open_sink() start\n"); 00502 00503 /* sink is already open... */ 00504 if(idomod_sink_is_open==IDO_TRUE) 00505 return idomod_sink_fd; 00506 00507 /* try and open sink */ 00508 if(idomod_sink_type==IDO_SINK_FILE) 00509 flags=O_WRONLY|O_CREAT|O_APPEND; 00510 if(ido_sink_open(idomod_sink_name,0,idomod_sink_type,idomod_sink_tcp_port,flags,&idomod_sink_fd)==IDO_ERROR) 00511 return IDO_ERROR; 00512 00513 /* mark the sink as being open */ 00514 idomod_sink_is_open=IDO_TRUE; 00515 00516 /* mark the sink as having once been open */ 00517 idomod_sink_previously_open=IDO_TRUE; 00518 00519 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_open_sink() end\n"); 00520 00521 return IDO_OK; 00522 } 00523 00524 00525 /* (re)open data sink */ 00526 int idomod_close_sink(void){ 00527 00528 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_close_sink() start\n"); 00529 00530 /* sink is already closed... */ 00531 if(idomod_sink_is_open==IDO_FALSE) 00532 return IDO_OK; 00533 00534 /* flush sink */ 00535 ido_sink_flush(idomod_sink_fd); 00536 00537 /* close sink */ 00538 ido_sink_close(idomod_sink_fd); 00539 00540 /* mark the sink as being closed */ 00541 idomod_sink_is_open=IDO_FALSE; 00542 00543 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_close_sink() end\n"); 00544 00545 return IDO_OK; 00546 } 00547 00548 00549 /* say hello */ 00550 int idomod_hello_sink(int reconnect, int problem_disconnect){ 00551 char temp_buffer[IDOMOD_MAX_BUFLEN]; 00552 char *connection_type=NULL; 00553 char *connect_type=NULL; 00554 00555 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_hello_sink() start\n"); 00556 00557 /* get the connection type string */ 00558 if(idomod_sink_type==IDO_SINK_FD || idomod_sink_type==IDO_SINK_FILE) 00559 connection_type=IDO_API_CONNECTION_FILE; 00560 else if(idomod_sink_type==IDO_SINK_TCPSOCKET) 00561 connection_type=IDO_API_CONNECTION_TCPSOCKET; 00562 else 00563 connection_type=IDO_API_CONNECTION_UNIXSOCKET; 00564 00565 /* get the connect type string */ 00566 if(reconnect==TRUE && problem_disconnect==TRUE) 00567 connect_type=IDO_API_CONNECTTYPE_RECONNECT; 00568 else 00569 connect_type=IDO_API_CONNECTTYPE_INITIAL; 00570 00571 snprintf(temp_buffer,sizeof(temp_buffer)-1 00572 ,"\n\n%s\n%s: %d\n%s: %s\n%s: %s\n%s: %lu\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s\n\n" 00573 ,IDO_API_HELLO 00574 ,IDO_API_PROTOCOL 00575 ,IDO_API_PROTOVERSION 00576 ,IDO_API_AGENT 00577 ,IDOMOD_NAME 00578 ,IDO_API_AGENTVERSION 00579 ,IDOMOD_VERSION 00580 ,IDO_API_STARTTIME 00581 ,(unsigned long)time(NULL) 00582 ,IDO_API_DISPOSITION 00583 ,IDO_API_DISPOSITION_REALTIME 00584 ,IDO_API_CONNECTION 00585 ,connection_type 00586 ,IDO_API_CONNECTTYPE 00587 ,connect_type 00588 ,IDO_API_INSTANCENAME 00589 ,(idomod_instance_name==NULL)?"default":idomod_instance_name 00590 ,IDO_API_STARTDATADUMP 00591 ); 00592 00593 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 00594 00595 idomod_write_to_sink(temp_buffer,IDO_FALSE,IDO_FALSE); 00596 00597 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_hello_sink() end\n"); 00598 00599 return IDO_OK; 00600 } 00601 00602 00603 /* say goodbye */ 00604 int idomod_goodbye_sink(void){ 00605 char temp_buffer[IDOMOD_MAX_BUFLEN]; 00606 00607 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_goodbye_sink() start\n"); 00608 00609 snprintf(temp_buffer,sizeof(temp_buffer)-1 00610 ,"\n%d\n%s: %lu\n%s\n\n" 00611 ,IDO_API_ENDDATADUMP 00612 ,IDO_API_ENDTIME 00613 ,(unsigned long)time(NULL) 00614 ,IDO_API_GOODBYE 00615 ); 00616 00617 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 00618 00619 idomod_write_to_sink(temp_buffer,IDO_FALSE,IDO_TRUE); 00620 00621 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_goodbye_sink() end\n"); 00622 00623 return IDO_OK; 00624 } 00625 00626 00627 /* used to rotate data sink file on a regular basis */ 00628 int idomod_rotate_sink_file(void *args){ 00629 char *raw_command_line_3x=NULL; 00630 char *processed_command_line_3x=NULL; 00631 int early_timeout=FALSE; 00632 double exectime; 00633 icinga_macros *mac; 00634 00635 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_rotate_sink_file() start\n"); 00636 00637 /* get global macros */ 00638 mac=get_global_macros(); 00639 00640 /* close sink */ 00641 idomod_goodbye_sink(); 00642 idomod_close_sink(); 00643 00644 /* we shouldn't write any data to the sink while we're rotating it... */ 00645 idomod_allow_sink_activity=IDO_FALSE; 00646 00647 00648 /****** ROTATE THE FILE *****/ 00649 00650 /* get the raw command line */ 00651 get_raw_command_line_r(mac, find_command(idomod_sink_rotation_command),idomod_sink_rotation_command,&raw_command_line_3x,STRIP_ILLEGAL_MACRO_CHARS|ESCAPE_MACRO_CHARS); 00652 strip(raw_command_line_3x); 00653 00654 /* process any macros in the raw command line */ 00655 process_macros_r(mac, raw_command_line_3x,&processed_command_line_3x,STRIP_ILLEGAL_MACRO_CHARS|ESCAPE_MACRO_CHARS); 00656 00657 /* run the command */ 00658 my_system(processed_command_line_3x,idomod_sink_rotation_timeout,&early_timeout,&exectime,NULL,0); 00659 00660 00661 /* allow data to be written to the sink */ 00662 idomod_allow_sink_activity=IDO_TRUE; 00663 00664 /* re-open sink */ 00665 idomod_open_sink(); 00666 idomod_hello_sink(TRUE,FALSE); 00667 00668 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_rotate_sink_file() end\n"); 00669 00670 return IDO_OK; 00671 } 00672 00673 00674 /* writes data to sink */ 00675 int idomod_write_to_sink(char *buf, int buffer_write, int flush_buffer){ 00676 char *temp_buffer=NULL; 00677 char *sbuf=NULL; 00678 int buflen=0; 00679 int result=IDO_OK; 00680 time_t current_time; 00681 int reconnect=IDO_FALSE; 00682 unsigned long items_to_flush=0L; 00683 00684 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_to_sink() start\n"); 00685 00686 /* we have nothing to write... */ 00687 if(buf==NULL) 00688 return IDO_OK; 00689 00690 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_to_sink(%s)\n", buf); 00691 00692 /* we shouldn't be messing with things... */ 00693 if(idomod_allow_sink_activity==IDO_FALSE) 00694 return IDO_ERROR; 00695 00696 /* open the sink if necessary... */ 00697 if(idomod_sink_is_open==IDO_FALSE){ 00698 00699 time(¤t_time); 00700 00701 /* are we reopening the sink? */ 00702 if(idomod_sink_previously_open==IDO_TRUE) 00703 reconnect=IDO_TRUE; 00704 00705 /* (re)connect to the sink if its time */ 00706 if((unsigned long)((unsigned long)current_time-idomod_sink_reconnect_interval)>(unsigned long)idomod_sink_last_reconnect_attempt){ 00707 00708 result=idomod_open_sink(); 00709 00710 idomod_sink_last_reconnect_attempt=current_time; 00711 00712 idomod_sink_connect_attempt++; 00713 00714 /* sink was (re)opened... */ 00715 if(result==IDO_OK){ 00716 00717 if(reconnect==IDO_TRUE){ 00718 if(asprintf(&temp_buffer,"idomod: Successfully reconnected to data sink! %lu items lost, %lu queued items to flush.",sinkbuf.overflow,sinkbuf.items)==-1) 00719 temp_buffer=NULL; 00720 00721 idomod_hello_sink(TRUE,TRUE); 00722 00723 } else { 00724 if(sinkbuf.overflow==0L) { 00725 if(asprintf(&temp_buffer,"idomod: Successfully connected to data sink. %lu queued items to flush.",sinkbuf.items)==-1) 00726 ;//temp_buffer=NULL; 00727 } else { 00728 if(asprintf(&temp_buffer,"idomod: Successfully connected to data sink. %lu items lost, %lu queued items to flush.",sinkbuf.overflow,sinkbuf.items)==-1) 00729 ;//temp_buffer=NULL; 00730 } 00731 00732 idomod_hello_sink(FALSE,FALSE); 00733 } 00734 00735 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00736 free(temp_buffer); 00737 temp_buffer=NULL; 00738 00739 /* reset sink overflow */ 00740 sinkbuf.overflow=0L; 00741 00742 /* sink could not be (re)opened... */ 00743 } else { 00744 00745 if((unsigned long)((unsigned long)current_time-idomod_sink_reconnect_warning_interval)>(unsigned long)idomod_sink_last_reconnect_warning){ 00746 if(reconnect==IDO_TRUE) { 00747 if(asprintf(&temp_buffer,"idomod: Still unable to reconnect to data sink. %lu items lost, %lu queued items to flush.",sinkbuf.overflow,sinkbuf.items)==-1) 00748 temp_buffer=NULL; 00749 } else if(idomod_sink_connect_attempt==1) { 00750 if(asprintf(&temp_buffer,"idomod: Could not open data sink! I'll keep trying, but some output may get lost...")==-1) 00751 temp_buffer=NULL; 00752 } else { 00753 if(asprintf(&temp_buffer,"idomod: Still unable to connect to data sink. %lu items lost, %lu queued items to flush.",sinkbuf.overflow,sinkbuf.items)==-1) 00754 temp_buffer=NULL; 00755 } 00756 00757 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00758 free(temp_buffer); 00759 temp_buffer=NULL; 00760 00761 idomod_sink_last_reconnect_warning=current_time; 00762 } 00763 } 00764 } 00765 } 00766 00767 /* we weren't able to (re)connect */ 00768 if(idomod_sink_is_open==IDO_FALSE){ 00769 00770 /***** BUFFER OUTPUT FOR LATER *****/ 00771 00772 if(buffer_write==IDO_TRUE) 00773 idomod_sink_buffer_push(&sinkbuf,buf); 00774 00775 return IDO_ERROR; 00776 } 00777 00778 00779 /***** FLUSH BUFFERED DATA FIRST *****/ 00780 00781 if(flush_buffer==IDO_TRUE && (items_to_flush=idomod_sink_buffer_items(&sinkbuf))>0){ 00782 00783 while(idomod_sink_buffer_items(&sinkbuf)>0){ 00784 00785 /* get next item from buffer */ 00786 sbuf=idomod_sink_buffer_peek(&sinkbuf); 00787 00788 buflen=strlen(sbuf); 00789 result=ido_sink_write(idomod_sink_fd,sbuf,buflen); 00790 00791 /* an error occurred... */ 00792 if(result<0){ 00793 00794 /* sink problem! */ 00795 if(errno!=EAGAIN){ 00796 00797 /* close the sink */ 00798 idomod_close_sink(); 00799 00800 if(asprintf(&temp_buffer,"idomod: Error writing to data sink! Some output may get lost. %lu queued items to flush.",sinkbuf.items)==-1) 00801 temp_buffer=NULL; 00802 00803 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00804 free(temp_buffer); 00805 temp_buffer=NULL; 00806 00807 time(¤t_time); 00808 idomod_sink_last_reconnect_attempt=current_time; 00809 idomod_sink_last_reconnect_warning=current_time; 00810 } 00811 00812 /***** BUFFER ORIGINAL OUTPUT FOR LATER *****/ 00813 00814 if(buffer_write==IDO_TRUE) 00815 idomod_sink_buffer_push(&sinkbuf,buf); 00816 00817 return IDO_ERROR; 00818 } 00819 00820 /* buffer was written okay, so remove it from buffer */ 00821 idomod_sink_buffer_pop(&sinkbuf); 00822 } 00823 00824 if(asprintf(&temp_buffer,"idomod: Successfully flushed %lu queued items to data sink.",items_to_flush)==-1) 00825 temp_buffer=NULL; 00826 00827 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00828 free(temp_buffer); 00829 temp_buffer=NULL; 00830 } 00831 00832 00833 /***** WRITE ORIGINAL DATA *****/ 00834 00835 /* write the data */ 00836 buflen=strlen(buf); 00837 result=ido_sink_write(idomod_sink_fd,buf,buflen); 00838 00839 /* an error occurred... */ 00840 if(result<0){ 00841 00842 /* sink problem! */ 00843 if(errno!=EAGAIN){ 00844 00845 /* close the sink */ 00846 idomod_close_sink(); 00847 00848 time(¤t_time); 00849 idomod_sink_last_reconnect_attempt=current_time; 00850 idomod_sink_last_reconnect_warning=current_time; 00851 00852 if(asprintf(&temp_buffer,"idomod: Error writing to data sink! Some output may get lost...")==-1) 00853 temp_buffer=NULL; 00854 00855 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00856 free(temp_buffer); 00857 00858 if(asprintf(&temp_buffer,"idomod: Please check remote ido2db log, database connection or SSL Parameters")==-1) 00859 temp_buffer=NULL; 00860 00861 idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE); 00862 free(temp_buffer); 00863 temp_buffer=NULL; 00864 } 00865 00866 /***** BUFFER OUTPUT FOR LATER *****/ 00867 00868 if(buffer_write==IDO_TRUE) 00869 idomod_sink_buffer_push(&sinkbuf,buf); 00870 00871 return IDO_ERROR; 00872 } 00873 00874 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_to_sink() end\n"); 00875 00876 return IDO_OK; 00877 } 00878 00879 00880 00881 /* save unprocessed data to buffer file */ 00882 int idomod_save_unprocessed_data(char *f){ 00883 FILE *fp=NULL; 00884 char *buf=NULL; 00885 char *ebuf=NULL; 00886 00887 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_save_unprocessed_data() start\n"); 00888 00889 /* no file */ 00890 if(f==NULL) 00891 return IDO_OK; 00892 00893 /* open the file for writing */ 00894 if((fp=fopen(f,"w"))==NULL) 00895 return IDO_ERROR; 00896 00897 /* save all buffered items */ 00898 while(idomod_sink_buffer_items(&sinkbuf)>0){ 00899 00900 /* get next item from buffer */ 00901 buf=idomod_sink_buffer_pop(&sinkbuf); 00902 00903 /* escape the string */ 00904 ebuf=ido_escape_buffer(buf); 00905 00906 /* write string to file */ 00907 fputs(ebuf,fp); 00908 fputs("\n",fp); 00909 00910 /* free memory */ 00911 free(buf); 00912 buf=NULL; 00913 free(ebuf); 00914 ebuf=NULL; 00915 } 00916 00917 fclose(fp); 00918 00919 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_save_unprocessed_data() end\n"); 00920 00921 return IDO_OK; 00922 } 00923 00924 00925 00926 /* load unprocessed data from buffer file */ 00927 int idomod_load_unprocessed_data(char *f){ 00928 ido_mmapfile *thefile=NULL; 00929 char *ebuf=NULL; 00930 char *buf=NULL; 00931 00932 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_load_unprocessed_data() start\n"); 00933 00934 /* open the file */ 00935 if((thefile=ido_mmap_fopen(f))==NULL) 00936 return IDO_ERROR; 00937 00938 /* process each line of the file */ 00939 while((ebuf=ido_mmap_fgets(thefile))){ 00940 00941 /* unescape string */ 00942 buf=ido_unescape_buffer(ebuf); 00943 00944 /* save the data to the sink buffer */ 00945 idomod_sink_buffer_push(&sinkbuf,buf); 00946 00947 /* free memory */ 00948 free(ebuf); 00949 } 00950 00951 /* close the file */ 00952 ido_mmap_fclose(thefile); 00953 00954 /* remove the file so we don't process it again in the future */ 00955 unlink(f); 00956 00957 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_load_unprocessed_data() end\n"); 00958 00959 return IDO_OK; 00960 } 00961 00962 00963 00964 /* initializes sink buffer */ 00965 int idomod_sink_buffer_init(idomod_sink_buffer *sbuf,unsigned long maxitems){ 00966 unsigned long x; 00967 00968 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_init() start\n"); 00969 00970 if(sbuf==NULL || maxitems<=0) 00971 return IDO_ERROR; 00972 00973 /* allocate memory for the buffer */ 00974 if((sbuf->buffer=(char **)malloc(sizeof(char *)*maxitems))){ 00975 for(x=0;x<maxitems;x++) 00976 sbuf->buffer[x]=NULL; 00977 } 00978 00979 sbuf->size=0L; 00980 sbuf->head=0L; 00981 sbuf->tail=0L; 00982 sbuf->items=0L; 00983 sbuf->maxitems=maxitems; 00984 sbuf->overflow=0L; 00985 00986 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_init() end\n"); 00987 00988 return IDO_OK; 00989 } 00990 00991 00992 /* deinitializes sink buffer */ 00993 int idomod_sink_buffer_deinit(idomod_sink_buffer *sbuf){ 00994 unsigned long x; 00995 00996 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_deinit() start\n"); 00997 00998 if(sbuf==NULL) 00999 return IDO_ERROR; 01000 01001 /* free any allocated memory */ 01002 for(x=0;x<sbuf->maxitems;x++) 01003 free(sbuf->buffer[x]); 01004 01005 free(sbuf->buffer); 01006 sbuf->buffer=NULL; 01007 01008 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_deinit() end\n"); 01009 01010 return IDO_OK; 01011 } 01012 01013 01014 /* buffers output */ 01015 int idomod_sink_buffer_push(idomod_sink_buffer *sbuf,char *buf){ 01016 01017 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_push() start\n"); 01018 01019 if(sbuf==NULL || buf==NULL) 01020 return IDO_ERROR; 01021 01022 /* no space to store buffer */ 01023 if(sbuf->buffer==NULL || sbuf->items==sbuf->maxitems){ 01024 sbuf->overflow++; 01025 return IDO_ERROR; 01026 } 01027 01028 /* store buffer */ 01029 sbuf->buffer[sbuf->head]=strdup(buf); 01030 sbuf->head=(sbuf->head+1)%sbuf->maxitems; 01031 sbuf->items++; 01032 01033 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_push() end\n"); 01034 01035 return IDO_OK; 01036 } 01037 01038 01039 /* gets and removes next item from buffer */ 01040 char *idomod_sink_buffer_pop(idomod_sink_buffer *sbuf){ 01041 char *buf=NULL; 01042 01043 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_pop() start\n"); 01044 01045 if(sbuf==NULL) 01046 return NULL; 01047 01048 if(sbuf->buffer==NULL) 01049 return NULL; 01050 01051 if(sbuf->items==0) 01052 return NULL; 01053 01054 /* remove item from buffer */ 01055 buf=sbuf->buffer[sbuf->tail]; 01056 sbuf->buffer[sbuf->tail]=NULL; 01057 sbuf->tail=(sbuf->tail+1)%sbuf->maxitems; 01058 sbuf->items--; 01059 01060 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_pop() end\n"); 01061 01062 return buf; 01063 } 01064 01065 01066 /* gets next items from buffer */ 01067 char *idomod_sink_buffer_peek(idomod_sink_buffer *sbuf){ 01068 char *buf=NULL; 01069 01070 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_peek() start\n"); 01071 01072 if(sbuf==NULL) 01073 return NULL; 01074 01075 if(sbuf->buffer==NULL) 01076 return NULL; 01077 01078 buf=sbuf->buffer[sbuf->tail]; 01079 01080 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_peek() end\n"); 01081 01082 return buf; 01083 } 01084 01085 01086 /* returns number of items buffered */ 01087 int idomod_sink_buffer_items(idomod_sink_buffer *sbuf){ 01088 01089 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_items()\n"); 01090 01091 if(sbuf==NULL) 01092 return 0; 01093 else 01094 return sbuf->items; 01095 } 01096 01097 01098 01099 /* gets number of items lost due to buffer overflow */ 01100 unsigned long idomod_sink_buffer_get_overflow(idomod_sink_buffer *sbuf){ 01101 01102 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_get_overflow()\n"); 01103 01104 if(sbuf==NULL) 01105 return 0; 01106 else 01107 return sbuf->overflow; 01108 } 01109 01110 01111 /* sets number of items lost due to buffer overflow */ 01112 int idomod_sink_buffer_set_overflow(idomod_sink_buffer *sbuf, unsigned long num){ 01113 01114 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_sink_buffer_set_overflow()\n"); 01115 01116 if(sbuf==NULL) 01117 return 0; 01118 else 01119 sbuf->overflow=num; 01120 01121 return sbuf->overflow; 01122 } 01123 01124 01125 01126 /****************************************************************************/ 01127 /* CALLBACK FUNCTIONS */ 01128 /****************************************************************************/ 01129 01130 /* registers for callbacks */ 01131 int idomod_register_callbacks(void){ 01132 int priority=0; 01133 int result=IDO_OK; 01134 01135 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_register_callbacks() start\n"); 01136 01137 if(result==IDO_OK) 01138 result=neb_register_callback(NEBCALLBACK_PROCESS_DATA,idomod_module_handle,priority,idomod_broker_data); 01139 if(result==IDO_OK) 01140 result=neb_register_callback(NEBCALLBACK_TIMED_EVENT_DATA,idomod_module_handle,priority,idomod_broker_data); 01141 if(result==IDO_OK) 01142 result=neb_register_callback(NEBCALLBACK_LOG_DATA,idomod_module_handle,priority,idomod_broker_data); 01143 if(result==IDO_OK) 01144 result=neb_register_callback(NEBCALLBACK_SYSTEM_COMMAND_DATA,idomod_module_handle,priority,idomod_broker_data); 01145 if(result==IDO_OK) 01146 result=neb_register_callback(NEBCALLBACK_EVENT_HANDLER_DATA,idomod_module_handle,priority,idomod_broker_data); 01147 if(result==IDO_OK) 01148 result=neb_register_callback(NEBCALLBACK_NOTIFICATION_DATA,idomod_module_handle,priority,idomod_broker_data); 01149 if(result==IDO_OK) 01150 result=neb_register_callback(NEBCALLBACK_SERVICE_CHECK_DATA,idomod_module_handle,priority,idomod_broker_data); 01151 if(result==IDO_OK) 01152 result=neb_register_callback(NEBCALLBACK_HOST_CHECK_DATA,idomod_module_handle,priority,idomod_broker_data); 01153 if(result==IDO_OK) 01154 result=neb_register_callback(NEBCALLBACK_COMMENT_DATA,idomod_module_handle,priority,idomod_broker_data); 01155 if(result==IDO_OK) 01156 result=neb_register_callback(NEBCALLBACK_DOWNTIME_DATA,idomod_module_handle,priority,idomod_broker_data); 01157 if(result==IDO_OK) 01158 result=neb_register_callback(NEBCALLBACK_FLAPPING_DATA,idomod_module_handle,priority,idomod_broker_data); 01159 if(result==IDO_OK) 01160 result=neb_register_callback(NEBCALLBACK_PROGRAM_STATUS_DATA,idomod_module_handle,priority,idomod_broker_data); 01161 if(result==IDO_OK) 01162 result=neb_register_callback(NEBCALLBACK_HOST_STATUS_DATA,idomod_module_handle,priority,idomod_broker_data); 01163 if(result==IDO_OK) 01164 result=neb_register_callback(NEBCALLBACK_SERVICE_STATUS_DATA,idomod_module_handle,priority,idomod_broker_data); 01165 if(result==IDO_OK) 01166 result=neb_register_callback(NEBCALLBACK_ADAPTIVE_PROGRAM_DATA,idomod_module_handle,priority,idomod_broker_data); 01167 if(result==IDO_OK) 01168 result=neb_register_callback(NEBCALLBACK_ADAPTIVE_HOST_DATA,idomod_module_handle,priority,idomod_broker_data); 01169 if(result==IDO_OK) 01170 result=neb_register_callback(NEBCALLBACK_ADAPTIVE_SERVICE_DATA,idomod_module_handle,priority,idomod_broker_data); 01171 if(result==IDO_OK) 01172 result=neb_register_callback(NEBCALLBACK_EXTERNAL_COMMAND_DATA,idomod_module_handle,priority,idomod_broker_data); 01173 if(result==IDO_OK) 01174 result=neb_register_callback(NEBCALLBACK_AGGREGATED_STATUS_DATA,idomod_module_handle,priority,idomod_broker_data); 01175 if(result==IDO_OK) 01176 result=neb_register_callback(NEBCALLBACK_RETENTION_DATA,idomod_module_handle,priority,idomod_broker_data); 01177 if(result==IDO_OK) 01178 result=neb_register_callback(NEBCALLBACK_CONTACT_NOTIFICATION_DATA,idomod_module_handle,priority,idomod_broker_data); 01179 if(result==IDO_OK) 01180 result=neb_register_callback(NEBCALLBACK_CONTACT_NOTIFICATION_METHOD_DATA,idomod_module_handle,priority,idomod_broker_data); 01181 if(result==IDO_OK) 01182 result=neb_register_callback(NEBCALLBACK_ACKNOWLEDGEMENT_DATA,idomod_module_handle,priority,idomod_broker_data); 01183 if(result==IDO_OK) 01184 result=neb_register_callback(NEBCALLBACK_STATE_CHANGE_DATA,idomod_module_handle,priority,idomod_broker_data); 01185 if(result==IDO_OK) 01186 result=neb_register_callback(NEBCALLBACK_CONTACT_STATUS_DATA,idomod_module_handle,priority,idomod_broker_data); 01187 if(result==IDO_OK) 01188 result=neb_register_callback(NEBCALLBACK_ADAPTIVE_CONTACT_DATA,idomod_module_handle,priority,idomod_broker_data); 01189 01190 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_register_callbacks() end\n"); 01191 01192 return result; 01193 } 01194 01195 01196 /* deregisters callbacks */ 01197 int idomod_deregister_callbacks(void){ 01198 01199 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_deregister_callbacks() start\n"); 01200 01201 neb_deregister_callback(NEBCALLBACK_PROCESS_DATA,idomod_broker_data); 01202 neb_deregister_callback(NEBCALLBACK_TIMED_EVENT_DATA,idomod_broker_data); 01203 neb_deregister_callback(NEBCALLBACK_LOG_DATA,idomod_broker_data); 01204 neb_deregister_callback(NEBCALLBACK_SYSTEM_COMMAND_DATA,idomod_broker_data); 01205 neb_deregister_callback(NEBCALLBACK_EVENT_HANDLER_DATA,idomod_broker_data); 01206 neb_deregister_callback(NEBCALLBACK_NOTIFICATION_DATA,idomod_broker_data); 01207 neb_deregister_callback(NEBCALLBACK_SERVICE_CHECK_DATA,idomod_broker_data); 01208 neb_deregister_callback(NEBCALLBACK_HOST_CHECK_DATA,idomod_broker_data); 01209 neb_deregister_callback(NEBCALLBACK_COMMENT_DATA,idomod_broker_data); 01210 neb_deregister_callback(NEBCALLBACK_DOWNTIME_DATA,idomod_broker_data); 01211 neb_deregister_callback(NEBCALLBACK_FLAPPING_DATA,idomod_broker_data); 01212 neb_deregister_callback(NEBCALLBACK_PROGRAM_STATUS_DATA,idomod_broker_data); 01213 neb_deregister_callback(NEBCALLBACK_HOST_STATUS_DATA,idomod_broker_data); 01214 neb_deregister_callback(NEBCALLBACK_SERVICE_STATUS_DATA,idomod_broker_data); 01215 neb_deregister_callback(NEBCALLBACK_ADAPTIVE_PROGRAM_DATA,idomod_broker_data); 01216 neb_deregister_callback(NEBCALLBACK_ADAPTIVE_HOST_DATA,idomod_broker_data); 01217 neb_deregister_callback(NEBCALLBACK_ADAPTIVE_SERVICE_DATA,idomod_broker_data); 01218 neb_deregister_callback(NEBCALLBACK_EXTERNAL_COMMAND_DATA,idomod_broker_data); 01219 neb_deregister_callback(NEBCALLBACK_AGGREGATED_STATUS_DATA,idomod_broker_data); 01220 neb_deregister_callback(NEBCALLBACK_RETENTION_DATA,idomod_broker_data); 01221 neb_deregister_callback(NEBCALLBACK_CONTACT_NOTIFICATION_DATA,idomod_broker_data); 01222 neb_deregister_callback(NEBCALLBACK_CONTACT_NOTIFICATION_METHOD_DATA,idomod_broker_data); 01223 neb_deregister_callback(NEBCALLBACK_ACKNOWLEDGEMENT_DATA,idomod_broker_data); 01224 neb_deregister_callback(NEBCALLBACK_STATE_CHANGE_DATA,idomod_broker_data); 01225 neb_deregister_callback(NEBCALLBACK_CONTACT_STATUS_DATA,idomod_broker_data); 01226 neb_deregister_callback(NEBCALLBACK_ADAPTIVE_CONTACT_DATA,idomod_broker_data); 01227 01228 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_deregister_callbacks() end\n"); 01229 01230 return IDO_OK; 01231 } 01232 01233 01234 /* handles brokered event data */ 01235 int idomod_broker_data(int event_type, void *data){ 01236 char temp_buffer[IDOMOD_MAX_BUFLEN]; 01237 ido_dbuf dbuf; 01238 int write_to_sink=IDO_TRUE; 01239 host *temp_host=NULL; 01240 service *temp_service=NULL; 01241 contact *temp_contact=NULL; 01242 char *es[9]; 01243 int x=0; 01244 scheduled_downtime *temp_downtime=NULL; 01245 comment *temp_comment=NULL; 01246 nebstruct_process_data *procdata=NULL; 01247 nebstruct_timed_event_data *eventdata=NULL; 01248 nebstruct_log_data *logdata=NULL; 01249 nebstruct_system_command_data *cmddata=NULL; 01250 nebstruct_event_handler_data *ehanddata=NULL; 01251 nebstruct_notification_data *notdata=NULL; 01252 nebstruct_service_check_data *scdata=NULL; 01253 nebstruct_host_check_data *hcdata=NULL; 01254 nebstruct_comment_data *comdata=NULL; 01255 nebstruct_downtime_data *downdata=NULL; 01256 nebstruct_flapping_data *flapdata=NULL; 01257 nebstruct_program_status_data *psdata=NULL; 01258 nebstruct_host_status_data *hsdata=NULL; 01259 nebstruct_service_status_data *ssdata=NULL; 01260 nebstruct_adaptive_program_data *apdata=NULL; 01261 nebstruct_adaptive_host_data *ahdata=NULL; 01262 nebstruct_adaptive_service_data *asdata=NULL; 01263 nebstruct_external_command_data *ecdata=NULL; 01264 nebstruct_aggregated_status_data *agsdata=NULL; 01265 nebstruct_retention_data *rdata=NULL; 01266 nebstruct_contact_notification_data *cnotdata=NULL; 01267 nebstruct_contact_notification_method_data *cnotmdata=NULL; 01268 nebstruct_acknowledgement_data *ackdata=NULL; 01269 nebstruct_statechange_data *schangedata=NULL; 01270 nebstruct_contact_status_data *csdata=NULL; 01271 nebstruct_adaptive_contact_data *acdata=NULL; 01272 01273 double retry_interval=0.0; 01274 int last_state=-1; 01275 int last_hard_state=-1; 01276 01277 customvariablesmember *temp_customvar=NULL; 01278 01279 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_broker_data() start\n"); 01280 01281 if(data==NULL) 01282 return 0; 01283 01284 /* should we handle this type of data? */ 01285 switch(event_type){ 01286 01287 case NEBCALLBACK_PROCESS_DATA: 01288 if(!(idomod_process_options & IDOMOD_PROCESS_PROCESS_DATA)) 01289 return 0; 01290 break; 01291 case NEBCALLBACK_TIMED_EVENT_DATA: 01292 if(!(idomod_process_options & IDOMOD_PROCESS_TIMED_EVENT_DATA)) 01293 return 0; 01294 break; 01295 case NEBCALLBACK_LOG_DATA: 01296 if(!(idomod_process_options & IDOMOD_PROCESS_LOG_DATA)) 01297 return 0; 01298 break; 01299 case NEBCALLBACK_SYSTEM_COMMAND_DATA: 01300 if(!(idomod_process_options & IDOMOD_PROCESS_SYSTEM_COMMAND_DATA)) 01301 return 0; 01302 break; 01303 case NEBCALLBACK_EVENT_HANDLER_DATA: 01304 if(!(idomod_process_options & IDOMOD_PROCESS_EVENT_HANDLER_DATA)) 01305 return 0; 01306 break; 01307 case NEBCALLBACK_NOTIFICATION_DATA: 01308 if(!(idomod_process_options & IDOMOD_PROCESS_NOTIFICATION_DATA)) 01309 return 0; 01310 break; 01311 case NEBCALLBACK_SERVICE_CHECK_DATA: 01312 if(!(idomod_process_options & IDOMOD_PROCESS_SERVICE_CHECK_DATA)) 01313 return 0; 01314 break; 01315 case NEBCALLBACK_HOST_CHECK_DATA: 01316 if(!(idomod_process_options & IDOMOD_PROCESS_HOST_CHECK_DATA)) 01317 return 0; 01318 break; 01319 case NEBCALLBACK_COMMENT_DATA: 01320 if(!(idomod_process_options & IDOMOD_PROCESS_COMMENT_DATA)) 01321 return 0; 01322 break; 01323 case NEBCALLBACK_DOWNTIME_DATA: 01324 if(!(idomod_process_options & IDOMOD_PROCESS_DOWNTIME_DATA)) 01325 return 0; 01326 break; 01327 case NEBCALLBACK_FLAPPING_DATA: 01328 if(!(idomod_process_options & IDOMOD_PROCESS_FLAPPING_DATA)) 01329 return 0; 01330 break; 01331 case NEBCALLBACK_PROGRAM_STATUS_DATA: 01332 if(!(idomod_process_options & IDOMOD_PROCESS_PROGRAM_STATUS_DATA)) 01333 return 0; 01334 break; 01335 case NEBCALLBACK_HOST_STATUS_DATA: 01336 if(!(idomod_process_options & IDOMOD_PROCESS_HOST_STATUS_DATA)) 01337 return 0; 01338 break; 01339 case NEBCALLBACK_SERVICE_STATUS_DATA: 01340 if(!(idomod_process_options & IDOMOD_PROCESS_SERVICE_STATUS_DATA)) 01341 return 0; 01342 break; 01343 case NEBCALLBACK_CONTACT_STATUS_DATA: 01344 if(!(idomod_process_options & IDOMOD_PROCESS_CONTACT_STATUS_DATA)) 01345 return 0; 01346 break; 01347 case NEBCALLBACK_ADAPTIVE_PROGRAM_DATA: 01348 if(!(idomod_process_options & IDOMOD_PROCESS_ADAPTIVE_PROGRAM_DATA)) 01349 return 0; 01350 break; 01351 case NEBCALLBACK_ADAPTIVE_HOST_DATA: 01352 if(!(idomod_process_options & IDOMOD_PROCESS_ADAPTIVE_HOST_DATA)) 01353 return 0; 01354 break; 01355 case NEBCALLBACK_ADAPTIVE_SERVICE_DATA: 01356 if(!(idomod_process_options & IDOMOD_PROCESS_ADAPTIVE_SERVICE_DATA)) 01357 return 0; 01358 break; 01359 case NEBCALLBACK_ADAPTIVE_CONTACT_DATA: 01360 if(!(idomod_process_options & IDOMOD_PROCESS_ADAPTIVE_CONTACT_DATA)) 01361 return 0; 01362 break; 01363 case NEBCALLBACK_EXTERNAL_COMMAND_DATA: 01364 if(!(idomod_process_options & IDOMOD_PROCESS_EXTERNAL_COMMAND_DATA)) 01365 return 0; 01366 break; 01367 case NEBCALLBACK_AGGREGATED_STATUS_DATA: 01368 if(!(idomod_process_options & IDOMOD_PROCESS_AGGREGATED_STATUS_DATA)) 01369 return 0; 01370 break; 01371 case NEBCALLBACK_RETENTION_DATA: 01372 if(!(idomod_process_options & IDOMOD_PROCESS_RETENTION_DATA)) 01373 return 0; 01374 break; 01375 case NEBCALLBACK_CONTACT_NOTIFICATION_DATA: 01376 if(!(idomod_process_options & IDOMOD_PROCESS_NOTIFICATION_DATA)) 01377 return 0; 01378 break; 01379 case NEBCALLBACK_CONTACT_NOTIFICATION_METHOD_DATA: 01380 if(!(idomod_process_options & IDOMOD_PROCESS_NOTIFICATION_DATA)) 01381 return 0; 01382 break; 01383 case NEBCALLBACK_ACKNOWLEDGEMENT_DATA: 01384 if(!(idomod_process_options & IDOMOD_PROCESS_ACKNOWLEDGEMENT_DATA)) 01385 return 0; 01386 break; 01387 case NEBCALLBACK_STATE_CHANGE_DATA: 01388 if(!(idomod_process_options & IDOMOD_PROCESS_STATECHANGE_DATA)) 01389 return 0; 01390 break; 01391 default: 01392 break; 01393 } 01394 01395 01396 /* initialize escaped buffers */ 01397 for(x=0;x<8;x++) 01398 es[x]=NULL; 01399 01400 /* initialize dynamic buffer (2KB chunk size) */ 01401 ido_dbuf_init(&dbuf,2048); 01402 01403 01404 /* handle the event */ 01405 switch(event_type){ 01406 01407 case NEBCALLBACK_PROCESS_DATA: 01408 01409 procdata=(nebstruct_process_data *)data; 01410 01411 snprintf(temp_buffer,sizeof(temp_buffer)-1 01412 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%lu\n%d\n\n" 01413 ,IDO_API_PROCESSDATA 01414 ,IDO_DATA_TYPE 01415 ,procdata->type 01416 ,IDO_DATA_FLAGS 01417 ,procdata->flags 01418 ,IDO_DATA_ATTRIBUTES 01419 ,procdata->attr 01420 ,IDO_DATA_TIMESTAMP 01421 ,procdata->timestamp.tv_sec 01422 ,procdata->timestamp.tv_usec 01423 ,IDO_DATA_PROGRAMNAME 01424 ,"Icinga" 01425 ,IDO_DATA_PROGRAMVERSION 01426 ,get_program_version() 01427 ,IDO_DATA_PROGRAMDATE 01428 ,get_program_modification_date() 01429 ,IDO_DATA_PROCESSID 01430 ,(unsigned long)getpid() 01431 ,IDO_API_ENDDATA 01432 ); 01433 01434 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 01435 ido_dbuf_strcat(&dbuf,temp_buffer); 01436 01437 break; 01438 01439 case NEBCALLBACK_TIMED_EVENT_DATA: 01440 01441 eventdata=(nebstruct_timed_event_data *)data; 01442 01443 switch(eventdata->event_type){ 01444 01445 case EVENT_SERVICE_CHECK: 01446 temp_service=(service *)eventdata->event_data; 01447 01448 es[0]=ido_escape_buffer(temp_service->host_name); 01449 es[1]=ido_escape_buffer(temp_service->description); 01450 01451 snprintf(temp_buffer,sizeof(temp_buffer)-1 01452 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%d\n%d=%lu\n%d=%s\n%d=%s\n%d\n\n" 01453 ,IDO_API_TIMEDEVENTDATA 01454 ,IDO_DATA_TYPE 01455 ,eventdata->type 01456 ,IDO_DATA_FLAGS 01457 ,eventdata->flags 01458 ,IDO_DATA_ATTRIBUTES 01459 ,eventdata->attr 01460 ,IDO_DATA_TIMESTAMP 01461 ,eventdata->timestamp.tv_sec 01462 ,eventdata->timestamp.tv_usec 01463 ,IDO_DATA_EVENTTYPE 01464 ,eventdata->event_type 01465 ,IDO_DATA_RECURRING 01466 ,eventdata->recurring 01467 ,IDO_DATA_RUNTIME 01468 ,(unsigned long)eventdata->run_time 01469 ,IDO_DATA_HOST 01470 ,(es[0]==NULL)?"":es[0] 01471 ,IDO_DATA_SERVICE 01472 ,(es[1]==NULL)?"":es[1] 01473 ,IDO_API_ENDDATA 01474 ); 01475 01476 break; 01477 01478 case EVENT_HOST_CHECK: 01479 temp_host=(host *)eventdata->event_data; 01480 01481 es[0]=ido_escape_buffer(temp_host->name); 01482 01483 snprintf(temp_buffer,sizeof(temp_buffer)-1 01484 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%d\n%d=%lu\n%d=%s\n%d\n\n" 01485 ,IDO_API_TIMEDEVENTDATA 01486 ,IDO_DATA_TYPE 01487 ,eventdata->type 01488 ,IDO_DATA_FLAGS 01489 ,eventdata->flags 01490 ,IDO_DATA_ATTRIBUTES 01491 ,eventdata->attr 01492 ,IDO_DATA_TIMESTAMP 01493 ,eventdata->timestamp.tv_sec 01494 ,eventdata->timestamp.tv_usec 01495 ,IDO_DATA_EVENTTYPE 01496 ,eventdata->event_type 01497 ,IDO_DATA_RECURRING 01498 ,eventdata->recurring 01499 ,IDO_DATA_RUNTIME 01500 ,(unsigned long)eventdata->run_time 01501 ,IDO_DATA_HOST 01502 ,(es[0]==NULL)?"":es[0] 01503 ,IDO_API_ENDDATA 01504 ); 01505 01506 break; 01507 01508 case EVENT_SCHEDULED_DOWNTIME: 01509 temp_downtime=find_downtime(ANY_DOWNTIME,(unsigned long)eventdata->event_data); 01510 01511 if(temp_downtime!=NULL){ 01512 es[0]=ido_escape_buffer(temp_downtime->host_name); 01513 es[1]=ido_escape_buffer(temp_downtime->service_description); 01514 } 01515 01516 snprintf(temp_buffer,sizeof(temp_buffer)-1 01517 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%d\n%d=%lu\n%d=%s\n%d=%s\n%d\n\n" 01518 ,IDO_API_TIMEDEVENTDATA 01519 ,IDO_DATA_TYPE 01520 ,eventdata->type 01521 ,IDO_DATA_FLAGS 01522 ,eventdata->flags 01523 ,IDO_DATA_ATTRIBUTES 01524 ,eventdata->attr 01525 ,IDO_DATA_TIMESTAMP 01526 ,eventdata->timestamp.tv_sec 01527 ,eventdata->timestamp.tv_usec 01528 ,IDO_DATA_EVENTTYPE 01529 ,eventdata->event_type 01530 ,IDO_DATA_RECURRING 01531 ,eventdata->recurring 01532 ,IDO_DATA_RUNTIME 01533 ,(unsigned long)eventdata->run_time 01534 ,IDO_DATA_HOST 01535 ,(es[0]==NULL)?"":es[0] 01536 ,IDO_DATA_SERVICE 01537 ,(es[1]==NULL)?"":es[1] 01538 ,IDO_API_ENDDATA 01539 ); 01540 01541 break; 01542 01543 default: 01544 snprintf(temp_buffer,sizeof(temp_buffer)-1 01545 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%d\n%d=%lu\n%d\n\n" 01546 ,IDO_API_TIMEDEVENTDATA 01547 ,IDO_DATA_TYPE 01548 ,eventdata->type 01549 ,IDO_DATA_FLAGS 01550 ,eventdata->flags 01551 ,IDO_DATA_ATTRIBUTES 01552 ,eventdata->attr 01553 ,IDO_DATA_TIMESTAMP 01554 ,eventdata->timestamp.tv_sec 01555 ,eventdata->timestamp.tv_usec 01556 ,IDO_DATA_EVENTTYPE 01557 ,eventdata->event_type 01558 ,IDO_DATA_RECURRING 01559 ,eventdata->recurring 01560 ,IDO_DATA_RUNTIME 01561 ,(unsigned long)eventdata->run_time 01562 ,IDO_API_ENDDATA 01563 ); 01564 break; 01565 } 01566 01567 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 01568 ido_dbuf_strcat(&dbuf,temp_buffer); 01569 01570 break; 01571 01572 case NEBCALLBACK_LOG_DATA: 01573 01574 logdata=(nebstruct_log_data *)data; 01575 01576 snprintf(temp_buffer,sizeof(temp_buffer)-1 01577 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%lu\n%d=%d\n%d=%s\n%d\n\n" 01578 ,IDO_API_LOGDATA 01579 ,IDO_DATA_TYPE 01580 ,logdata->type 01581 ,IDO_DATA_FLAGS 01582 ,logdata->flags 01583 ,IDO_DATA_ATTRIBUTES 01584 ,logdata->attr 01585 ,IDO_DATA_TIMESTAMP 01586 ,logdata->timestamp.tv_sec 01587 ,logdata->timestamp.tv_usec 01588 ,IDO_DATA_LOGENTRYTIME 01589 ,logdata->entry_time 01590 ,IDO_DATA_LOGENTRYTYPE 01591 ,logdata->data_type 01592 ,IDO_DATA_LOGENTRY 01593 ,logdata->data 01594 ,IDO_API_ENDDATA 01595 ); 01596 01597 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 01598 ido_dbuf_strcat(&dbuf,temp_buffer); 01599 01600 break; 01601 01602 case NEBCALLBACK_SYSTEM_COMMAND_DATA: 01603 01604 cmddata=(nebstruct_system_command_data *)data; 01605 01606 es[0]=ido_escape_buffer(cmddata->command_line); 01607 es[1]=ido_escape_buffer(cmddata->output); 01608 es[2]=ido_escape_buffer(cmddata->output); 01609 01610 snprintf(temp_buffer,sizeof(temp_buffer)-1 01611 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%ld.%ld\n%d=%ld.%ld\n%d=%d\n%d=%s\n%d=%d\n%d=%.5lf\n%d=%d\n%d=%s\n%d=%s\n%d\n\n" 01612 ,IDO_API_SYSTEMCOMMANDDATA 01613 ,IDO_DATA_TYPE 01614 ,cmddata->type 01615 ,IDO_DATA_FLAGS 01616 ,cmddata->flags 01617 ,IDO_DATA_ATTRIBUTES 01618 ,cmddata->attr 01619 ,IDO_DATA_TIMESTAMP 01620 ,cmddata->timestamp.tv_sec 01621 ,cmddata->timestamp.tv_usec 01622 ,IDO_DATA_STARTTIME 01623 ,cmddata->start_time.tv_sec 01624 ,cmddata->start_time.tv_usec 01625 ,IDO_DATA_ENDTIME 01626 ,cmddata->end_time.tv_sec 01627 ,cmddata->end_time.tv_usec 01628 ,IDO_DATA_TIMEOUT 01629 ,cmddata->timeout 01630 ,IDO_DATA_COMMANDLINE 01631 ,(es[0]==NULL)?"":es[0] 01632 ,IDO_DATA_EARLYTIMEOUT 01633 ,cmddata->early_timeout 01634 ,IDO_DATA_EXECUTIONTIME 01635 ,cmddata->execution_time 01636 ,IDO_DATA_RETURNCODE 01637 ,cmddata->return_code 01638 ,IDO_DATA_OUTPUT 01639 ,(es[1]==NULL)?"":es[1] 01640 ,IDO_DATA_LONGOUTPUT 01641 ,(es[2]==NULL)?"":es[2] 01642 ,IDO_API_ENDDATA 01643 ); 01644 01645 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 01646 ido_dbuf_strcat(&dbuf,temp_buffer); 01647 01648 break; 01649 01650 case NEBCALLBACK_EVENT_HANDLER_DATA: 01651 01652 ehanddata=(nebstruct_event_handler_data *)data; 01653 01654 es[0]=ido_escape_buffer(ehanddata->host_name); 01655 es[1]=ido_escape_buffer(ehanddata->service_description); 01656 es[2]=ido_escape_buffer(ehanddata->command_name); 01657 es[3]=ido_escape_buffer(ehanddata->command_args); 01658 es[4]=ido_escape_buffer(ehanddata->command_line); 01659 es[5]=ido_escape_buffer(ehanddata->output); 01660 /* Preparing if eventhandler will have long_output in the future */ 01661 es[6]=ido_escape_buffer(ehanddata->output); 01662 01663 snprintf(temp_buffer,sizeof(temp_buffer)-1 01664 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%ld.%ld\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%.5lf\n%d=%d\n%d=%s\n%d=%s\n%d\n\n" 01665 ,IDO_API_EVENTHANDLERDATA 01666 ,IDO_DATA_TYPE 01667 ,ehanddata->type 01668 ,IDO_DATA_FLAGS 01669 ,ehanddata->flags 01670 ,IDO_DATA_ATTRIBUTES 01671 ,ehanddata->attr 01672 ,IDO_DATA_TIMESTAMP 01673 ,ehanddata->timestamp.tv_sec 01674 ,ehanddata->timestamp.tv_usec 01675 ,IDO_DATA_HOST 01676 ,(es[0]==NULL)?"":es[0] 01677 ,IDO_DATA_SERVICE 01678 ,(es[1]==NULL)?"":es[1] 01679 ,IDO_DATA_STATETYPE 01680 ,ehanddata->state_type 01681 ,IDO_DATA_STATE 01682 ,ehanddata->state 01683 ,IDO_DATA_STARTTIME 01684 ,ehanddata->start_time.tv_sec 01685 ,ehanddata->start_time.tv_usec 01686 ,IDO_DATA_ENDTIME 01687 ,ehanddata->end_time.tv_sec 01688 ,ehanddata->end_time.tv_usec 01689 ,IDO_DATA_TIMEOUT 01690 ,ehanddata->timeout 01691 ,IDO_DATA_COMMANDNAME 01692 ,(es[2]==NULL)?"":es[2] 01693 ,IDO_DATA_COMMANDARGS 01694 ,(es[3]==NULL)?"":es[3] 01695 ,IDO_DATA_COMMANDLINE 01696 ,(es[4]==NULL)?"":es[4] 01697 ,IDO_DATA_EARLYTIMEOUT 01698 ,ehanddata->early_timeout 01699 ,IDO_DATA_EXECUTIONTIME 01700 ,ehanddata->execution_time 01701 ,IDO_DATA_RETURNCODE 01702 ,ehanddata->return_code 01703 ,IDO_DATA_OUTPUT 01704 ,(es[5]==NULL)?"":es[5] 01705 ,IDO_DATA_LONGOUTPUT 01706 ,(es[6]==NULL)?"":es[6] 01707 ,IDO_API_ENDDATA 01708 ); 01709 01710 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 01711 ido_dbuf_strcat(&dbuf,temp_buffer); 01712 01713 break; 01714 01715 case NEBCALLBACK_NOTIFICATION_DATA: 01716 01717 notdata=(nebstruct_notification_data *)data; 01718 01719 es[0]=ido_escape_buffer(notdata->host_name); 01720 es[1]=ido_escape_buffer(notdata->service_description); 01721 es[2]=ido_escape_buffer(notdata->output); 01722 /* Preparing if notifications will have long_output in the future */ 01723 es[3]=ido_escape_buffer(notdata->output); 01724 es[4]=ido_escape_buffer(notdata->ack_author); 01725 es[5]=ido_escape_buffer(notdata->ack_data); 01726 01727 snprintf(temp_buffer,sizeof(temp_buffer)-1 01728 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%ld.%ld\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d\n\n" 01729 ,IDO_API_NOTIFICATIONDATA 01730 ,IDO_DATA_TYPE 01731 ,notdata->type 01732 ,IDO_DATA_FLAGS 01733 ,notdata->flags 01734 ,IDO_DATA_ATTRIBUTES 01735 ,notdata->attr 01736 ,IDO_DATA_TIMESTAMP 01737 ,notdata->timestamp.tv_sec 01738 ,notdata->timestamp.tv_usec 01739 ,IDO_DATA_NOTIFICATIONTYPE 01740 ,notdata->notification_type 01741 ,IDO_DATA_STARTTIME 01742 ,notdata->start_time.tv_sec 01743 ,notdata->start_time.tv_usec 01744 ,IDO_DATA_ENDTIME 01745 ,notdata->end_time.tv_sec 01746 ,notdata->end_time.tv_usec 01747 ,IDO_DATA_HOST 01748 ,(es[0]==NULL)?"":es[0] 01749 ,IDO_DATA_SERVICE 01750 ,(es[1]==NULL)?"":es[1] 01751 ,IDO_DATA_NOTIFICATIONREASON 01752 ,notdata->reason_type 01753 ,IDO_DATA_STATE 01754 ,notdata->state 01755 ,IDO_DATA_OUTPUT 01756 ,(es[2]==NULL)?"":es[2] 01757 ,IDO_DATA_LONGOUTPUT 01758 ,(es[3]==NULL)?"":es[3] 01759 ,IDO_DATA_ACKAUTHOR 01760 ,(es[4]==NULL)?"":es[4] 01761 ,IDO_DATA_ACKDATA 01762 ,(es[5]==NULL)?"":es[5] 01763 ,IDO_DATA_ESCALATED 01764 ,notdata->escalated 01765 ,IDO_DATA_CONTACTSNOTIFIED 01766 ,notdata->contacts_notified 01767 ,IDO_API_ENDDATA 01768 ); 01769 01770 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 01771 ido_dbuf_strcat(&dbuf,temp_buffer); 01772 01773 break; 01774 01775 case NEBCALLBACK_SERVICE_CHECK_DATA: 01776 01777 scdata=(nebstruct_service_check_data *)data; 01778 01779 /* only pass NEBTYPE_SERVICECHECK_PROCESSED to ido2db */ 01780 if(scdata->type!=NEBTYPE_SERVICECHECK_PROCESSED) 01781 break; 01782 01783 es[0]=ido_escape_buffer(scdata->host_name); 01784 es[1]=ido_escape_buffer(scdata->service_description); 01785 es[2]=ido_escape_buffer(scdata->command_name); 01786 es[3]=ido_escape_buffer(scdata->command_args); 01787 es[4]=ido_escape_buffer(scdata->command_line); 01788 es[5]=ido_escape_buffer(scdata->output); 01789 es[6]=ido_escape_buffer(scdata->long_output); 01790 es[7]=ido_escape_buffer(scdata->perf_data); 01791 01792 snprintf(temp_buffer,sizeof(temp_buffer)-1 01793 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d=%ld.%ld\n%d=%ld.%ld\n%d=%d\n%d=%.5lf\n%d=%.5lf\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d\n\n" 01794 ,IDO_API_SERVICECHECKDATA 01795 ,IDO_DATA_TYPE 01796 ,scdata->type 01797 ,IDO_DATA_FLAGS 01798 ,scdata->flags 01799 ,IDO_DATA_ATTRIBUTES 01800 ,scdata->attr 01801 ,IDO_DATA_TIMESTAMP 01802 ,scdata->timestamp.tv_sec 01803 ,scdata->timestamp.tv_usec 01804 ,IDO_DATA_HOST 01805 ,(es[0]==NULL)?"":es[0] 01806 ,IDO_DATA_SERVICE 01807 ,(es[1]==NULL)?"":es[1] 01808 ,IDO_DATA_CHECKTYPE 01809 ,scdata->check_type 01810 ,IDO_DATA_CURRENTCHECKATTEMPT 01811 ,scdata->current_attempt 01812 ,IDO_DATA_MAXCHECKATTEMPTS 01813 ,scdata->max_attempts 01814 ,IDO_DATA_STATETYPE 01815 ,scdata->state_type 01816 ,IDO_DATA_STATE 01817 ,scdata->state 01818 ,IDO_DATA_TIMEOUT 01819 ,scdata->timeout 01820 ,IDO_DATA_COMMANDNAME 01821 ,(es[2]==NULL)?"":es[2] 01822 ,IDO_DATA_COMMANDARGS 01823 ,(es[3]==NULL)?"":es[3] 01824 ,IDO_DATA_COMMANDLINE 01825 ,(es[4]==NULL)?"":es[4] 01826 ,IDO_DATA_STARTTIME 01827 ,scdata->start_time.tv_sec 01828 ,scdata->start_time.tv_usec 01829 ,IDO_DATA_ENDTIME 01830 ,scdata->end_time.tv_sec 01831 ,scdata->end_time.tv_usec 01832 ,IDO_DATA_EARLYTIMEOUT 01833 ,scdata->early_timeout 01834 ,IDO_DATA_EXECUTIONTIME 01835 ,scdata->execution_time 01836 ,IDO_DATA_LATENCY 01837 ,scdata->latency 01838 ,IDO_DATA_RETURNCODE 01839 ,scdata->return_code 01840 ,IDO_DATA_OUTPUT 01841 ,(es[5]==NULL)?"":es[5] 01842 ,IDO_DATA_LONGOUTPUT 01843 ,(es[6]==NULL)?"":es[6] 01844 ,IDO_DATA_PERFDATA 01845 ,(es[7]==NULL)?"":es[7] 01846 ,IDO_API_ENDDATA 01847 ); 01848 01849 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 01850 ido_dbuf_strcat(&dbuf,temp_buffer); 01851 01852 break; 01853 01854 case NEBCALLBACK_HOST_CHECK_DATA: 01855 01856 hcdata=(nebstruct_host_check_data *)data; 01857 01858 /* only pass NEBTYPE_HOSTCHECK_PROCESSED to ido2db */ 01859 if(hcdata->type!=NEBTYPE_HOSTCHECK_PROCESSED) 01860 break; 01861 01862 es[0]=ido_escape_buffer(hcdata->host_name); 01863 es[1]=ido_escape_buffer(hcdata->command_name); 01864 es[2]=ido_escape_buffer(hcdata->command_args); 01865 es[3]=ido_escape_buffer(hcdata->command_line); 01866 es[4]=ido_escape_buffer(hcdata->output); 01867 es[5]=ido_escape_buffer(hcdata->long_output); 01868 es[6]=ido_escape_buffer(hcdata->perf_data); 01869 01870 snprintf(temp_buffer,sizeof(temp_buffer)-1 01871 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d=%ld.%ld\n%d=%ld.%ld\n%d=%d\n%d=%.5lf\n%d=%.5lf\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d\n\n" 01872 ,IDO_API_HOSTCHECKDATA 01873 ,IDO_DATA_TYPE 01874 ,hcdata->type 01875 ,IDO_DATA_FLAGS 01876 ,hcdata->flags 01877 ,IDO_DATA_ATTRIBUTES 01878 ,hcdata->attr 01879 ,IDO_DATA_TIMESTAMP 01880 ,hcdata->timestamp.tv_sec 01881 ,hcdata->timestamp.tv_usec 01882 ,IDO_DATA_HOST 01883 ,(es[0]==NULL)?"":es[0] 01884 ,IDO_DATA_CHECKTYPE 01885 ,hcdata->check_type 01886 ,IDO_DATA_CURRENTCHECKATTEMPT 01887 ,hcdata->current_attempt 01888 ,IDO_DATA_MAXCHECKATTEMPTS 01889 ,hcdata->max_attempts 01890 ,IDO_DATA_STATETYPE 01891 ,hcdata->state_type 01892 ,IDO_DATA_STATE 01893 ,hcdata->state 01894 ,IDO_DATA_TIMEOUT 01895 ,hcdata->timeout 01896 ,IDO_DATA_COMMANDNAME 01897 ,(es[1]==NULL)?"":es[1] 01898 ,IDO_DATA_COMMANDARGS 01899 ,(es[2]==NULL)?"":es[2] 01900 ,IDO_DATA_COMMANDLINE 01901 ,(es[3]==NULL)?"":es[3] 01902 ,IDO_DATA_STARTTIME 01903 ,hcdata->start_time.tv_sec 01904 ,hcdata->start_time.tv_usec 01905 ,IDO_DATA_ENDTIME 01906 ,hcdata->end_time.tv_sec 01907 ,hcdata->end_time.tv_usec 01908 ,IDO_DATA_EARLYTIMEOUT 01909 ,hcdata->early_timeout 01910 ,IDO_DATA_EXECUTIONTIME 01911 ,hcdata->execution_time 01912 ,IDO_DATA_LATENCY 01913 ,hcdata->latency 01914 ,IDO_DATA_RETURNCODE 01915 ,hcdata->return_code 01916 ,IDO_DATA_OUTPUT 01917 ,(es[4]==NULL)?"":es[4] 01918 ,IDO_DATA_LONGOUTPUT 01919 ,(es[5]==NULL)?"":es[5] 01920 ,IDO_DATA_PERFDATA 01921 ,(es[6]==NULL)?"":es[6] 01922 ,IDO_API_ENDDATA 01923 ); 01924 01925 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 01926 ido_dbuf_strcat(&dbuf,temp_buffer); 01927 01928 break; 01929 01930 case NEBCALLBACK_COMMENT_DATA: 01931 01932 comdata=(nebstruct_comment_data *)data; 01933 01934 es[0]=ido_escape_buffer(comdata->host_name); 01935 es[1]=ido_escape_buffer(comdata->service_description); 01936 es[2]=ido_escape_buffer(comdata->author_name); 01937 es[3]=ido_escape_buffer(comdata->comment_data); 01938 01939 snprintf(temp_buffer,sizeof(temp_buffer)-1 01940 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%s\n%d=%s\n%d=%lu\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d\n\n" 01941 ,IDO_API_COMMENTDATA 01942 ,IDO_DATA_TYPE 01943 ,comdata->type 01944 ,IDO_DATA_FLAGS 01945 ,comdata->flags 01946 ,IDO_DATA_ATTRIBUTES 01947 ,comdata->attr 01948 ,IDO_DATA_TIMESTAMP 01949 ,comdata->timestamp.tv_sec 01950 ,comdata->timestamp.tv_usec 01951 ,IDO_DATA_COMMENTTYPE 01952 ,comdata->comment_type 01953 ,IDO_DATA_HOST 01954 ,(es[0]==NULL)?"":es[0] 01955 ,IDO_DATA_SERVICE 01956 ,(es[1]==NULL)?"":es[1] 01957 ,IDO_DATA_ENTRYTIME 01958 ,(unsigned long)comdata->entry_time 01959 ,IDO_DATA_AUTHORNAME 01960 ,(es[2]==NULL)?"":es[2] 01961 ,IDO_DATA_COMMENT 01962 ,(es[3]==NULL)?"":es[3] 01963 ,IDO_DATA_PERSISTENT 01964 ,comdata->persistent 01965 ,IDO_DATA_SOURCE 01966 ,comdata->source 01967 ,IDO_DATA_ENTRYTYPE 01968 ,comdata->entry_type 01969 ,IDO_DATA_EXPIRES 01970 ,comdata->expires 01971 ,IDO_DATA_EXPIRATIONTIME 01972 ,(unsigned long)comdata->expire_time 01973 ,IDO_DATA_COMMENTID 01974 ,comdata->comment_id 01975 ,IDO_API_ENDDATA 01976 ); 01977 01978 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 01979 ido_dbuf_strcat(&dbuf,temp_buffer); 01980 01981 break; 01982 01983 case NEBCALLBACK_DOWNTIME_DATA: 01984 01985 downdata=(nebstruct_downtime_data *)data; 01986 01987 es[0]=ido_escape_buffer(downdata->host_name); 01988 es[1]=ido_escape_buffer(downdata->service_description); 01989 es[2]=ido_escape_buffer(downdata->author_name); 01990 es[3]=ido_escape_buffer(downdata->comment_data); 01991 01992 snprintf(temp_buffer,sizeof(temp_buffer)-1 01993 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%s\n%d=%s\n%d=%lu\n%d=%s\n%d=%s\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d\n\n" 01994 ,IDO_API_DOWNTIMEDATA 01995 ,IDO_DATA_TYPE 01996 ,downdata->type 01997 ,IDO_DATA_FLAGS 01998 ,downdata->flags 01999 ,IDO_DATA_ATTRIBUTES 02000 ,downdata->attr 02001 ,IDO_DATA_TIMESTAMP 02002 ,downdata->timestamp.tv_sec 02003 ,downdata->timestamp.tv_usec 02004 ,IDO_DATA_DOWNTIMETYPE 02005 ,downdata->downtime_type 02006 ,IDO_DATA_HOST 02007 ,(es[0]==NULL)?"":es[0] 02008 ,IDO_DATA_SERVICE 02009 ,(es[1]==NULL)?"":es[1] 02010 ,IDO_DATA_ENTRYTIME 02011 ,downdata->entry_time 02012 ,IDO_DATA_AUTHORNAME 02013 ,(es[2]==NULL)?"":es[2] 02014 ,IDO_DATA_COMMENT 02015 ,(es[3]==NULL)?"":es[3] 02016 ,IDO_DATA_STARTTIME 02017 ,(unsigned long)downdata->start_time 02018 ,IDO_DATA_ENDTIME 02019 ,(unsigned long)downdata->end_time 02020 ,IDO_DATA_FIXED 02021 ,downdata->fixed 02022 ,IDO_DATA_DURATION 02023 ,(unsigned long)downdata->duration 02024 ,IDO_DATA_TRIGGEREDBY 02025 ,(unsigned long)downdata->triggered_by 02026 ,IDO_DATA_DOWNTIMEID 02027 ,(unsigned long)downdata->downtime_id 02028 ,IDO_API_ENDDATA 02029 ); 02030 02031 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02032 ido_dbuf_strcat(&dbuf,temp_buffer); 02033 02034 break; 02035 02036 case NEBCALLBACK_FLAPPING_DATA: 02037 02038 flapdata=(nebstruct_flapping_data *)data; 02039 02040 es[0]=ido_escape_buffer(flapdata->host_name); 02041 es[1]=ido_escape_buffer(flapdata->service_description); 02042 02043 if(flapdata->flapping_type==HOST_FLAPPING) 02044 temp_comment=find_host_comment(flapdata->comment_id); 02045 else 02046 temp_comment=find_service_comment(flapdata->comment_id); 02047 02048 snprintf(temp_buffer,sizeof(temp_buffer)-1 02049 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%s\n%d=%s\n%d=%.5lf\n%d=%.5lf\n%d=%.5lf\n%d=%lu\n%d=%lu\n%d\n\n" 02050 ,IDO_API_FLAPPINGDATA 02051 ,IDO_DATA_TYPE 02052 ,flapdata->type 02053 ,IDO_DATA_FLAGS 02054 ,flapdata->flags 02055 ,IDO_DATA_ATTRIBUTES 02056 ,flapdata->attr 02057 ,IDO_DATA_TIMESTAMP 02058 ,flapdata->timestamp.tv_sec 02059 ,flapdata->timestamp.tv_usec 02060 ,IDO_DATA_FLAPPINGTYPE 02061 ,flapdata->flapping_type 02062 ,IDO_DATA_HOST 02063 ,(es[0]==NULL)?"":es[0] 02064 ,IDO_DATA_SERVICE 02065 ,(es[1]==NULL)?"":es[1] 02066 ,IDO_DATA_PERCENTSTATECHANGE 02067 ,flapdata->percent_change 02068 ,IDO_DATA_HIGHTHRESHOLD 02069 ,flapdata->high_threshold 02070 ,IDO_DATA_LOWTHRESHOLD 02071 ,flapdata->low_threshold 02072 ,IDO_DATA_COMMENTTIME 02073 ,(temp_comment==NULL)?0L:(unsigned long)temp_comment->entry_time 02074 ,IDO_DATA_COMMENTID 02075 ,flapdata->comment_id 02076 ,IDO_API_ENDDATA 02077 ); 02078 02079 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02080 ido_dbuf_strcat(&dbuf,temp_buffer); 02081 02082 break; 02083 02084 case NEBCALLBACK_PROGRAM_STATUS_DATA: 02085 02086 psdata=(nebstruct_program_status_data *)data; 02087 02088 es[0]=ido_escape_buffer(psdata->global_host_event_handler); 02089 es[1]=ido_escape_buffer(psdata->global_service_event_handler); 02090 02091 snprintf(temp_buffer,sizeof(temp_buffer)-1 02092 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%lu\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d=%s\n%d=%s\n%d\n\n" 02093 ,IDO_API_PROGRAMSTATUSDATA 02094 ,IDO_DATA_TYPE 02095 ,psdata->type 02096 ,IDO_DATA_FLAGS 02097 ,psdata->flags 02098 ,IDO_DATA_ATTRIBUTES 02099 ,psdata->attr 02100 ,IDO_DATA_TIMESTAMP 02101 ,psdata->timestamp.tv_sec 02102 ,psdata->timestamp.tv_usec 02103 ,IDO_DATA_PROGRAMSTARTTIME 02104 ,(unsigned long)psdata->program_start 02105 ,IDO_DATA_PROCESSID 02106 ,psdata->pid 02107 ,IDO_DATA_DAEMONMODE 02108 ,psdata->daemon_mode 02109 ,IDO_DATA_LASTCOMMANDCHECK 02110 ,(unsigned long)psdata->last_command_check 02111 ,IDO_DATA_LASTLOGROTATION 02112 ,(unsigned long)psdata->last_log_rotation 02113 ,IDO_DATA_NOTIFICATIONSENABLED 02114 ,psdata->notifications_enabled 02115 ,IDO_DATA_ACTIVESERVICECHECKSENABLED 02116 ,psdata->active_service_checks_enabled 02117 ,IDO_DATA_PASSIVESERVICECHECKSENABLED 02118 ,psdata->passive_service_checks_enabled 02119 ,IDO_DATA_ACTIVEHOSTCHECKSENABLED 02120 ,psdata->active_host_checks_enabled 02121 ,IDO_DATA_PASSIVEHOSTCHECKSENABLED 02122 ,psdata->passive_host_checks_enabled 02123 ,IDO_DATA_EVENTHANDLERSENABLED 02124 ,psdata->event_handlers_enabled 02125 ,IDO_DATA_FLAPDETECTIONENABLED 02126 ,psdata->flap_detection_enabled 02127 ,IDO_DATA_FAILUREPREDICTIONENABLED 02128 ,psdata->failure_prediction_enabled 02129 ,IDO_DATA_PROCESSPERFORMANCEDATA 02130 ,psdata->process_performance_data 02131 ,IDO_DATA_OBSESSOVERHOSTS 02132 ,psdata->obsess_over_hosts 02133 ,IDO_DATA_OBSESSOVERSERVICES 02134 ,psdata->obsess_over_services 02135 ,IDO_DATA_MODIFIEDHOSTATTRIBUTES 02136 ,psdata->modified_host_attributes 02137 ,IDO_DATA_MODIFIEDSERVICEATTRIBUTES 02138 ,psdata->modified_service_attributes 02139 ,IDO_DATA_GLOBALHOSTEVENTHANDLER 02140 ,(es[0]==NULL)?"":es[0] 02141 ,IDO_DATA_GLOBALSERVICEEVENTHANDLER 02142 ,(es[1]==NULL)?"":es[1] 02143 ,IDO_API_ENDDATA 02144 ); 02145 02146 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02147 ido_dbuf_strcat(&dbuf,temp_buffer); 02148 02149 break; 02150 02151 case NEBCALLBACK_HOST_STATUS_DATA: 02152 02153 hsdata=(nebstruct_host_status_data *)data; 02154 02155 if((temp_host=(host *)hsdata->object_ptr)==NULL){ 02156 ido_dbuf_free(&dbuf); 02157 return 0; 02158 } 02159 02160 es[0]=ido_escape_buffer(temp_host->name); 02161 es[1]=ido_escape_buffer(temp_host->plugin_output); 02162 es[2]=ido_escape_buffer(temp_host->long_plugin_output); 02163 es[3]=ido_escape_buffer(temp_host->perf_data); 02164 es[4]=ido_escape_buffer(temp_host->event_handler); 02165 es[5]=ido_escape_buffer(temp_host->host_check_command); 02166 es[6]=ido_escape_buffer(temp_host->check_period); 02167 02168 retry_interval=temp_host->retry_interval; 02169 02170 snprintf(temp_buffer,sizeof(temp_buffer)-1 02171 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%.5lf\n%d=%.5lf\n%d=%.5lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%s\n" 02172 ,IDO_API_HOSTSTATUSDATA 02173 ,IDO_DATA_TYPE 02174 ,hsdata->type 02175 ,IDO_DATA_FLAGS 02176 ,hsdata->flags 02177 ,IDO_DATA_ATTRIBUTES 02178 ,hsdata->attr 02179 ,IDO_DATA_TIMESTAMP 02180 ,hsdata->timestamp.tv_sec 02181 ,hsdata->timestamp.tv_usec 02182 ,IDO_DATA_HOST 02183 ,(es[0]==NULL)?"":es[0] 02184 ,IDO_DATA_OUTPUT 02185 ,(es[1]==NULL)?"":es[1] 02186 ,IDO_DATA_LONGOUTPUT 02187 ,(es[2]==NULL)?"":es[2] 02188 ,IDO_DATA_PERFDATA 02189 ,(es[3]==NULL)?"":es[3] 02190 ,IDO_DATA_CURRENTSTATE 02191 ,temp_host->current_state 02192 ,IDO_DATA_HASBEENCHECKED 02193 ,temp_host->has_been_checked 02194 ,IDO_DATA_SHOULDBESCHEDULED 02195 ,temp_host->should_be_scheduled 02196 ,IDO_DATA_CURRENTCHECKATTEMPT 02197 ,temp_host->current_attempt 02198 ,IDO_DATA_MAXCHECKATTEMPTS 02199 ,temp_host->max_attempts 02200 ,IDO_DATA_LASTHOSTCHECK 02201 ,(unsigned long)temp_host->last_check 02202 ,IDO_DATA_NEXTHOSTCHECK 02203 ,(unsigned long)temp_host->next_check 02204 ,IDO_DATA_CHECKTYPE 02205 ,temp_host->check_type 02206 ,IDO_DATA_LASTSTATECHANGE 02207 ,(unsigned long)temp_host->last_state_change 02208 ,IDO_DATA_LASTHARDSTATECHANGE 02209 ,(unsigned long)temp_host->last_hard_state_change 02210 ,IDO_DATA_LASTHARDSTATE 02211 ,temp_host->last_hard_state 02212 ,IDO_DATA_LASTTIMEUP 02213 ,(unsigned long)temp_host->last_time_up 02214 ,IDO_DATA_LASTTIMEDOWN 02215 ,(unsigned long)temp_host->last_time_down 02216 ,IDO_DATA_LASTTIMEUNREACHABLE 02217 ,(unsigned long)temp_host->last_time_unreachable 02218 ,IDO_DATA_STATETYPE 02219 ,temp_host->state_type 02220 ,IDO_DATA_LASTHOSTNOTIFICATION 02221 ,(unsigned long)temp_host->last_host_notification 02222 ,IDO_DATA_NEXTHOSTNOTIFICATION 02223 ,(unsigned long)temp_host->next_host_notification 02224 ,IDO_DATA_NOMORENOTIFICATIONS 02225 ,temp_host->no_more_notifications 02226 ,IDO_DATA_NOTIFICATIONSENABLED 02227 ,temp_host->notifications_enabled 02228 ,IDO_DATA_PROBLEMHASBEENACKNOWLEDGED 02229 ,temp_host->problem_has_been_acknowledged 02230 ,IDO_DATA_ACKNOWLEDGEMENTTYPE 02231 ,temp_host->acknowledgement_type 02232 ,IDO_DATA_CURRENTNOTIFICATIONNUMBER 02233 ,temp_host->current_notification_number 02234 ,IDO_DATA_PASSIVEHOSTCHECKSENABLED 02235 ,temp_host->accept_passive_host_checks 02236 ,IDO_DATA_EVENTHANDLERENABLED 02237 ,temp_host->event_handler_enabled 02238 ,IDO_DATA_ACTIVEHOSTCHECKSENABLED 02239 ,temp_host->checks_enabled 02240 ,IDO_DATA_FLAPDETECTIONENABLED 02241 ,temp_host->flap_detection_enabled 02242 ,IDO_DATA_ISFLAPPING 02243 ,temp_host->is_flapping 02244 ,IDO_DATA_PERCENTSTATECHANGE 02245 ,temp_host->percent_state_change 02246 ,IDO_DATA_LATENCY 02247 ,temp_host->latency 02248 ,IDO_DATA_EXECUTIONTIME 02249 ,temp_host->execution_time 02250 ,IDO_DATA_SCHEDULEDDOWNTIMEDEPTH 02251 ,temp_host->scheduled_downtime_depth 02252 ,IDO_DATA_FAILUREPREDICTIONENABLED 02253 ,temp_host->failure_prediction_enabled 02254 ,IDO_DATA_PROCESSPERFORMANCEDATA 02255 ,temp_host->process_performance_data 02256 ,IDO_DATA_OBSESSOVERHOST 02257 ,temp_host->obsess_over_host 02258 02259 ,IDO_DATA_MODIFIEDHOSTATTRIBUTES 02260 ,temp_host->modified_attributes 02261 ,IDO_DATA_EVENTHANDLER 02262 ,(es[4]==NULL)?"":es[4] 02263 ,IDO_DATA_CHECKCOMMAND 02264 ,(es[5]==NULL)?"":es[5] 02265 ,IDO_DATA_NORMALCHECKINTERVAL 02266 ,(double)temp_host->check_interval 02267 ,IDO_DATA_RETRYCHECKINTERVAL 02268 ,(double)retry_interval 02269 ,IDO_DATA_HOSTCHECKPERIOD 02270 ,(es[6]==NULL)?"":es[6] 02271 ); 02272 02273 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02274 ido_dbuf_strcat(&dbuf,temp_buffer); 02275 02276 /* dump customvars */ 02277 for(temp_customvar=temp_host->custom_variables;temp_customvar!=NULL;temp_customvar=temp_customvar->next){ 02278 02279 for(x=0;x<2;x++){ 02280 free(es[x]); 02281 es[x]=NULL; 02282 } 02283 02284 es[0]=ido_escape_buffer(temp_customvar->variable_name); 02285 es[1]=ido_escape_buffer(temp_customvar->variable_value); 02286 02287 snprintf(temp_buffer,sizeof(temp_buffer)-1 02288 ,"%d=%s:%d:%s\n" 02289 ,IDO_DATA_CUSTOMVARIABLE 02290 ,(es[0]==NULL)?"":es[0] 02291 ,temp_customvar->has_been_modified 02292 ,(es[1]==NULL)?"":es[1] 02293 ); 02294 02295 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02296 ido_dbuf_strcat(&dbuf,temp_buffer); 02297 } 02298 02299 snprintf(temp_buffer,sizeof(temp_buffer)-1 02300 ,"%d\n\n" 02301 ,IDO_API_ENDDATA 02302 ); 02303 02304 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02305 ido_dbuf_strcat(&dbuf,temp_buffer); 02306 02307 break; 02308 02309 case NEBCALLBACK_SERVICE_STATUS_DATA: 02310 02311 ssdata=(nebstruct_service_status_data *)data; 02312 02313 if((temp_service=(service *)ssdata->object_ptr)==NULL){ 02314 ido_dbuf_free(&dbuf); 02315 return 0; 02316 } 02317 02318 es[0]=ido_escape_buffer(temp_service->host_name); 02319 es[1]=ido_escape_buffer(temp_service->description); 02320 es[2]=ido_escape_buffer(temp_service->plugin_output); 02321 es[3]=ido_escape_buffer(temp_service->long_plugin_output); 02322 es[4]=ido_escape_buffer(temp_service->perf_data); 02323 es[5]=ido_escape_buffer(temp_service->event_handler); 02324 es[6]=ido_escape_buffer(temp_service->service_check_command); 02325 es[7]=ido_escape_buffer(temp_service->check_period); 02326 02327 snprintf(temp_buffer,sizeof(temp_buffer)-1 02328 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%.5lf\n%d=%.5lf\n%d=%.5lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%s\n" 02329 ,IDO_API_SERVICESTATUSDATA 02330 ,IDO_DATA_TYPE 02331 ,ssdata->type 02332 ,IDO_DATA_FLAGS 02333 ,ssdata->flags 02334 ,IDO_DATA_ATTRIBUTES 02335 ,ssdata->attr 02336 ,IDO_DATA_TIMESTAMP 02337 ,ssdata->timestamp.tv_sec 02338 ,ssdata->timestamp.tv_usec 02339 ,IDO_DATA_HOST 02340 ,(es[0]==NULL)?"":es[0] 02341 ,IDO_DATA_SERVICE 02342 ,(es[1]==NULL)?"":es[1] 02343 ,IDO_DATA_OUTPUT 02344 ,(es[2]==NULL)?"":es[2] 02345 ,IDO_DATA_LONGOUTPUT 02346 ,(es[3]==NULL)?"":es[3] 02347 ,IDO_DATA_PERFDATA 02348 ,(es[4]==NULL)?"":es[4] 02349 ,IDO_DATA_CURRENTSTATE 02350 ,temp_service->current_state 02351 ,IDO_DATA_HASBEENCHECKED 02352 ,temp_service->has_been_checked 02353 ,IDO_DATA_SHOULDBESCHEDULED 02354 ,temp_service->should_be_scheduled 02355 ,IDO_DATA_CURRENTCHECKATTEMPT 02356 ,temp_service->current_attempt 02357 ,IDO_DATA_MAXCHECKATTEMPTS 02358 ,temp_service->max_attempts 02359 ,IDO_DATA_LASTSERVICECHECK 02360 ,(unsigned long)temp_service->last_check 02361 ,IDO_DATA_NEXTSERVICECHECK 02362 ,(unsigned long)temp_service->next_check 02363 ,IDO_DATA_CHECKTYPE 02364 ,temp_service->check_type 02365 ,IDO_DATA_LASTSTATECHANGE 02366 ,(unsigned long)temp_service->last_state_change 02367 ,IDO_DATA_LASTHARDSTATECHANGE 02368 ,(unsigned long)temp_service->last_hard_state_change 02369 ,IDO_DATA_LASTHARDSTATE 02370 ,temp_service->last_hard_state 02371 ,IDO_DATA_LASTTIMEOK 02372 ,(unsigned long)temp_service->last_time_ok 02373 ,IDO_DATA_LASTTIMEWARNING 02374 ,(unsigned long)temp_service->last_time_warning 02375 ,IDO_DATA_LASTTIMEUNKNOWN 02376 ,(unsigned long)temp_service->last_time_unknown 02377 ,IDO_DATA_LASTTIMECRITICAL 02378 ,(unsigned long)temp_service->last_time_critical 02379 ,IDO_DATA_STATETYPE 02380 ,temp_service->state_type 02381 ,IDO_DATA_LASTSERVICENOTIFICATION 02382 ,(unsigned long)temp_service->last_notification 02383 ,IDO_DATA_NEXTSERVICENOTIFICATION 02384 ,(unsigned long)temp_service->next_notification 02385 ,IDO_DATA_NOMORENOTIFICATIONS 02386 ,temp_service->no_more_notifications 02387 ,IDO_DATA_NOTIFICATIONSENABLED 02388 ,temp_service->notifications_enabled 02389 ,IDO_DATA_PROBLEMHASBEENACKNOWLEDGED 02390 ,temp_service->problem_has_been_acknowledged 02391 ,IDO_DATA_ACKNOWLEDGEMENTTYPE 02392 ,temp_service->acknowledgement_type 02393 ,IDO_DATA_CURRENTNOTIFICATIONNUMBER 02394 ,temp_service->current_notification_number 02395 ,IDO_DATA_PASSIVESERVICECHECKSENABLED 02396 ,temp_service->accept_passive_service_checks 02397 ,IDO_DATA_EVENTHANDLERENABLED 02398 ,temp_service->event_handler_enabled 02399 ,IDO_DATA_ACTIVESERVICECHECKSENABLED 02400 ,temp_service->checks_enabled 02401 ,IDO_DATA_FLAPDETECTIONENABLED 02402 ,temp_service->flap_detection_enabled 02403 ,IDO_DATA_ISFLAPPING 02404 ,temp_service->is_flapping 02405 ,IDO_DATA_PERCENTSTATECHANGE 02406 ,temp_service->percent_state_change 02407 ,IDO_DATA_LATENCY 02408 ,temp_service->latency 02409 ,IDO_DATA_EXECUTIONTIME 02410 ,temp_service->execution_time 02411 ,IDO_DATA_SCHEDULEDDOWNTIMEDEPTH 02412 ,temp_service->scheduled_downtime_depth 02413 ,IDO_DATA_FAILUREPREDICTIONENABLED 02414 ,temp_service->failure_prediction_enabled 02415 ,IDO_DATA_PROCESSPERFORMANCEDATA 02416 ,temp_service->process_performance_data 02417 ,IDO_DATA_OBSESSOVERSERVICE 02418 ,temp_service->obsess_over_service 02419 02420 ,IDO_DATA_MODIFIEDSERVICEATTRIBUTES 02421 ,temp_service->modified_attributes 02422 ,IDO_DATA_EVENTHANDLER 02423 ,(es[5]==NULL)?"":es[5] 02424 ,IDO_DATA_CHECKCOMMAND 02425 ,(es[6]==NULL)?"":es[6] 02426 ,IDO_DATA_NORMALCHECKINTERVAL 02427 ,(double)temp_service->check_interval 02428 ,IDO_DATA_RETRYCHECKINTERVAL 02429 ,(double)temp_service->retry_interval 02430 ,IDO_DATA_SERVICECHECKPERIOD 02431 ,(es[7]==NULL)?"":es[7] 02432 ); 02433 02434 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02435 ido_dbuf_strcat(&dbuf,temp_buffer); 02436 02437 /* dump customvars */ 02438 for(temp_customvar=temp_service->custom_variables;temp_customvar!=NULL;temp_customvar=temp_customvar->next){ 02439 02440 for(x=0;x<2;x++){ 02441 free(es[x]); 02442 es[x]=NULL; 02443 } 02444 02445 es[0]=ido_escape_buffer(temp_customvar->variable_name); 02446 es[1]=ido_escape_buffer(temp_customvar->variable_value); 02447 02448 snprintf(temp_buffer,sizeof(temp_buffer)-1 02449 ,"%d=%s:%d:%s\n" 02450 ,IDO_DATA_CUSTOMVARIABLE 02451 ,(es[0]==NULL)?"":es[0] 02452 ,temp_customvar->has_been_modified 02453 ,(es[1]==NULL)?"":es[1] 02454 ); 02455 02456 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02457 ido_dbuf_strcat(&dbuf,temp_buffer); 02458 } 02459 02460 snprintf(temp_buffer,sizeof(temp_buffer)-1 02461 ,"%d\n\n" 02462 ,IDO_API_ENDDATA 02463 ); 02464 02465 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02466 ido_dbuf_strcat(&dbuf,temp_buffer); 02467 02468 break; 02469 02470 case NEBCALLBACK_CONTACT_STATUS_DATA: 02471 02472 csdata=(nebstruct_contact_status_data *)data; 02473 02474 if((temp_contact=(contact *)csdata->object_ptr)==NULL){ 02475 ido_dbuf_free(&dbuf); 02476 return 0; 02477 } 02478 02479 es[0]=ido_escape_buffer(temp_contact->name); 02480 02481 snprintf(temp_buffer,sizeof(temp_buffer)-1 02482 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%lu\n" 02483 ,IDO_API_CONTACTSTATUSDATA 02484 ,IDO_DATA_TYPE 02485 ,csdata->type 02486 ,IDO_DATA_FLAGS 02487 ,csdata->flags 02488 ,IDO_DATA_ATTRIBUTES 02489 ,csdata->attr 02490 ,IDO_DATA_TIMESTAMP 02491 ,csdata->timestamp.tv_sec 02492 ,csdata->timestamp.tv_usec 02493 ,IDO_DATA_CONTACTNAME 02494 ,(es[0]==NULL)?"":es[0] 02495 ,IDO_DATA_HOSTNOTIFICATIONSENABLED 02496 ,temp_contact->host_notifications_enabled 02497 ,IDO_DATA_SERVICENOTIFICATIONSENABLED 02498 ,temp_contact->service_notifications_enabled 02499 ,IDO_DATA_LASTHOSTNOTIFICATION 02500 ,temp_contact->last_host_notification 02501 ,IDO_DATA_LASTSERVICENOTIFICATION 02502 ,temp_contact->last_service_notification 02503 02504 ,IDO_DATA_MODIFIEDCONTACTATTRIBUTES 02505 ,temp_contact->modified_attributes 02506 ,IDO_DATA_MODIFIEDHOSTATTRIBUTES 02507 ,temp_contact->modified_host_attributes 02508 ,IDO_DATA_MODIFIEDSERVICEATTRIBUTES 02509 ,temp_contact->modified_service_attributes 02510 ); 02511 02512 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02513 ido_dbuf_strcat(&dbuf,temp_buffer); 02514 02515 /* dump customvars */ 02516 for(temp_customvar=temp_contact->custom_variables;temp_customvar!=NULL;temp_customvar=temp_customvar->next){ 02517 02518 for(x=0;x<2;x++){ 02519 free(es[x]); 02520 es[x]=NULL; 02521 } 02522 02523 es[0]=ido_escape_buffer(temp_customvar->variable_name); 02524 es[1]=ido_escape_buffer(temp_customvar->variable_value); 02525 02526 snprintf(temp_buffer,sizeof(temp_buffer)-1 02527 ,"%d=%s:%d:%s\n" 02528 ,IDO_DATA_CUSTOMVARIABLE 02529 ,(es[0]==NULL)?"":es[0] 02530 ,temp_customvar->has_been_modified 02531 ,(es[1]==NULL)?"":es[1] 02532 ); 02533 02534 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02535 ido_dbuf_strcat(&dbuf,temp_buffer); 02536 } 02537 02538 snprintf(temp_buffer,sizeof(temp_buffer)-1 02539 ,"%d\n\n" 02540 ,IDO_API_ENDDATA 02541 ); 02542 02543 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02544 ido_dbuf_strcat(&dbuf,temp_buffer); 02545 02546 break; 02547 02548 case NEBCALLBACK_ADAPTIVE_PROGRAM_DATA: 02549 02550 apdata=(nebstruct_adaptive_program_data *)data; 02551 02552 es[0]=ido_escape_buffer(global_host_event_handler); 02553 es[1]=ido_escape_buffer(global_service_event_handler); 02554 02555 snprintf(temp_buffer,sizeof(temp_buffer)-1 02556 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%s\n%d=%s\n%d\n\n" 02557 ,IDO_API_ADAPTIVEPROGRAMDATA 02558 ,IDO_DATA_TYPE,apdata->type 02559 ,IDO_DATA_FLAGS 02560 ,apdata->flags 02561 ,IDO_DATA_ATTRIBUTES 02562 ,apdata->attr 02563 ,IDO_DATA_TIMESTAMP 02564 ,apdata->timestamp.tv_sec 02565 ,apdata->timestamp.tv_usec 02566 ,IDO_DATA_COMMANDTYPE 02567 ,apdata->command_type 02568 ,IDO_DATA_MODIFIEDHOSTATTRIBUTE 02569 ,apdata->modified_host_attribute 02570 ,IDO_DATA_MODIFIEDHOSTATTRIBUTES 02571 ,apdata->modified_host_attributes 02572 ,IDO_DATA_MODIFIEDSERVICEATTRIBUTE 02573 ,apdata->modified_service_attribute 02574 ,IDO_DATA_MODIFIEDSERVICEATTRIBUTES 02575 ,apdata->modified_service_attributes 02576 ,IDO_DATA_GLOBALHOSTEVENTHANDLER 02577 ,(es[0]==NULL)?"":es[0] 02578 ,IDO_DATA_GLOBALSERVICEEVENTHANDLER 02579 ,(es[1]==NULL)?"":es[1] 02580 ,IDO_API_ENDDATA 02581 ); 02582 02583 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02584 ido_dbuf_strcat(&dbuf,temp_buffer); 02585 02586 break; 02587 02588 case NEBCALLBACK_ADAPTIVE_HOST_DATA: 02589 02590 ahdata=(nebstruct_adaptive_host_data *)data; 02591 02592 if((temp_host=(host *)ahdata->object_ptr)==NULL){ 02593 ido_dbuf_free(&dbuf); 02594 return 0; 02595 } 02596 02597 retry_interval=temp_host->retry_interval; 02598 02599 es[0]=ido_escape_buffer(temp_host->name); 02600 es[1]=ido_escape_buffer(temp_host->event_handler); 02601 es[2]=ido_escape_buffer(temp_host->host_check_command); 02602 02603 snprintf(temp_buffer,sizeof(temp_buffer)-1 02604 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%lu\n%d=%lu\n%d=%s\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%d\n%d\n\n" 02605 ,IDO_API_ADAPTIVEHOSTDATA 02606 ,IDO_DATA_TYPE 02607 ,ahdata->type 02608 ,IDO_DATA_FLAGS 02609 ,ahdata->flags 02610 ,IDO_DATA_ATTRIBUTES 02611 ,ahdata->attr 02612 ,IDO_DATA_TIMESTAMP 02613 ,ahdata->timestamp.tv_sec 02614 ,ahdata->timestamp.tv_usec 02615 ,IDO_DATA_COMMANDTYPE 02616 ,ahdata->command_type 02617 ,IDO_DATA_MODIFIEDHOSTATTRIBUTE 02618 ,ahdata->modified_attribute 02619 ,IDO_DATA_MODIFIEDHOSTATTRIBUTES 02620 ,ahdata->modified_attributes 02621 ,IDO_DATA_HOST 02622 ,(es[0]==NULL)?"":es[0] 02623 ,IDO_DATA_EVENTHANDLER 02624 ,(es[1]==NULL)?"":es[1] 02625 ,IDO_DATA_CHECKCOMMAND 02626 ,(es[2]==NULL)?"":es[2] 02627 ,IDO_DATA_NORMALCHECKINTERVAL 02628 ,(double)temp_host->check_interval 02629 ,IDO_DATA_RETRYCHECKINTERVAL 02630 ,retry_interval 02631 ,IDO_DATA_MAXCHECKATTEMPTS 02632 ,temp_host->max_attempts 02633 ,IDO_API_ENDDATA 02634 ); 02635 02636 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02637 ido_dbuf_strcat(&dbuf,temp_buffer); 02638 02639 break; 02640 02641 case NEBCALLBACK_ADAPTIVE_SERVICE_DATA: 02642 02643 asdata=(nebstruct_adaptive_service_data *)data; 02644 02645 if((temp_service=(service *)asdata->object_ptr)==NULL){ 02646 ido_dbuf_free(&dbuf); 02647 return 0; 02648 } 02649 02650 es[0]=ido_escape_buffer(temp_service->host_name); 02651 es[1]=ido_escape_buffer(temp_service->description); 02652 es[2]=ido_escape_buffer(temp_service->event_handler); 02653 es[3]=ido_escape_buffer(temp_service->service_check_command); 02654 02655 snprintf(temp_buffer,sizeof(temp_buffer)-1 02656 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%lu\n%d=%lu\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%d\n%d\n\n" 02657 ,IDO_API_ADAPTIVESERVICEDATA 02658 ,IDO_DATA_TYPE 02659 ,asdata->type 02660 ,IDO_DATA_FLAGS 02661 ,asdata->flags 02662 ,IDO_DATA_ATTRIBUTES 02663 ,asdata->attr 02664 ,IDO_DATA_TIMESTAMP 02665 ,asdata->timestamp.tv_sec 02666 ,asdata->timestamp.tv_usec 02667 ,IDO_DATA_COMMANDTYPE 02668 ,asdata->command_type 02669 ,IDO_DATA_MODIFIEDSERVICEATTRIBUTE 02670 ,asdata->modified_attribute 02671 ,IDO_DATA_MODIFIEDSERVICEATTRIBUTES 02672 ,asdata->modified_attributes 02673 ,IDO_DATA_HOST 02674 ,(es[0]==NULL)?"":es[0] 02675 ,IDO_DATA_SERVICE 02676 ,(es[1]==NULL)?"":es[1] 02677 ,IDO_DATA_EVENTHANDLER 02678 ,(es[2]==NULL)?"":es[2] 02679 ,IDO_DATA_CHECKCOMMAND 02680 ,(es[3]==NULL)?"":es[3] 02681 ,IDO_DATA_NORMALCHECKINTERVAL 02682 ,(double)temp_service->check_interval 02683 ,IDO_DATA_RETRYCHECKINTERVAL 02684 ,(double)temp_service->retry_interval 02685 ,IDO_DATA_MAXCHECKATTEMPTS 02686 ,temp_service->max_attempts 02687 ,IDO_API_ENDDATA 02688 ); 02689 02690 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02691 ido_dbuf_strcat(&dbuf,temp_buffer); 02692 02693 break; 02694 02695 case NEBCALLBACK_ADAPTIVE_CONTACT_DATA: 02696 02697 acdata=(nebstruct_adaptive_contact_data *)data; 02698 02699 if((temp_contact=(contact *)acdata->object_ptr)==NULL){ 02700 ido_dbuf_free(&dbuf); 02701 return 0; 02702 } 02703 02704 es[0]=ido_escape_buffer(temp_contact->name); 02705 02706 snprintf(temp_buffer,sizeof(temp_buffer)-1 02707 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%s\n%d=%d\n%d=%d\n%d\n\n" 02708 ,IDO_API_ADAPTIVECONTACTDATA 02709 ,IDO_DATA_TYPE 02710 ,acdata->type 02711 ,IDO_DATA_FLAGS 02712 ,acdata->flags 02713 ,IDO_DATA_ATTRIBUTES 02714 ,acdata->attr 02715 ,IDO_DATA_TIMESTAMP 02716 ,acdata->timestamp.tv_sec 02717 ,acdata->timestamp.tv_usec 02718 ,IDO_DATA_COMMANDTYPE 02719 ,acdata->command_type 02720 ,IDO_DATA_MODIFIEDCONTACTATTRIBUTE 02721 ,acdata->modified_attribute 02722 ,IDO_DATA_MODIFIEDCONTACTATTRIBUTES 02723 ,acdata->modified_attributes 02724 ,IDO_DATA_MODIFIEDHOSTATTRIBUTE 02725 ,acdata->modified_host_attribute 02726 ,IDO_DATA_MODIFIEDHOSTATTRIBUTES 02727 ,acdata->modified_host_attributes 02728 ,IDO_DATA_MODIFIEDSERVICEATTRIBUTE 02729 ,acdata->modified_service_attribute 02730 ,IDO_DATA_MODIFIEDSERVICEATTRIBUTES 02731 ,acdata->modified_service_attributes 02732 ,IDO_DATA_CONTACTNAME 02733 ,(es[0]==NULL)?"":es[0] 02734 ,IDO_DATA_HOSTNOTIFICATIONSENABLED 02735 ,temp_contact->host_notifications_enabled 02736 ,IDO_DATA_SERVICENOTIFICATIONSENABLED 02737 ,temp_contact->service_notifications_enabled 02738 ,IDO_API_ENDDATA 02739 ); 02740 02741 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02742 ido_dbuf_strcat(&dbuf,temp_buffer); 02743 02744 break; 02745 02746 case NEBCALLBACK_EXTERNAL_COMMAND_DATA: 02747 02748 ecdata=(nebstruct_external_command_data *)data; 02749 02750 es[0]=ido_escape_buffer(ecdata->command_string); 02751 es[1]=ido_escape_buffer(ecdata->command_args); 02752 02753 snprintf(temp_buffer,sizeof(temp_buffer)-1 02754 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%lu\n%d=%s\n%d=%s\n%d\n\n" 02755 ,IDO_API_EXTERNALCOMMANDDATA 02756 ,IDO_DATA_TYPE 02757 ,ecdata->type 02758 ,IDO_DATA_FLAGS 02759 ,ecdata->flags 02760 ,IDO_DATA_ATTRIBUTES 02761 ,ecdata->attr 02762 ,IDO_DATA_TIMESTAMP 02763 ,ecdata->timestamp.tv_sec 02764 ,ecdata->timestamp.tv_usec 02765 ,IDO_DATA_COMMANDTYPE 02766 ,ecdata->command_type 02767 ,IDO_DATA_ENTRYTIME 02768 ,(unsigned long)ecdata->entry_time 02769 ,IDO_DATA_COMMANDSTRING 02770 ,(es[0]==NULL)?"":es[0] 02771 ,IDO_DATA_COMMANDARGS 02772 ,(es[1]==NULL)?"":es[1] 02773 ,IDO_API_ENDDATA 02774 ); 02775 02776 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02777 ido_dbuf_strcat(&dbuf,temp_buffer); 02778 02779 break; 02780 02781 case NEBCALLBACK_AGGREGATED_STATUS_DATA: 02782 02783 agsdata=(nebstruct_aggregated_status_data *)data; 02784 02785 snprintf(temp_buffer,sizeof(temp_buffer)-1 02786 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d\n\n" 02787 ,IDO_API_AGGREGATEDSTATUSDATA 02788 ,IDO_DATA_TYPE 02789 ,agsdata->type 02790 ,IDO_DATA_FLAGS 02791 ,agsdata->flags 02792 ,IDO_DATA_ATTRIBUTES 02793 ,agsdata->attr 02794 ,IDO_DATA_TIMESTAMP 02795 ,agsdata->timestamp.tv_sec 02796 ,agsdata->timestamp.tv_usec 02797 ,IDO_API_ENDDATA 02798 ); 02799 02800 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02801 ido_dbuf_strcat(&dbuf,temp_buffer); 02802 02803 break; 02804 02805 case NEBCALLBACK_RETENTION_DATA: 02806 02807 rdata=(nebstruct_retention_data *)data; 02808 02809 snprintf(temp_buffer,sizeof(temp_buffer)-1 02810 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d\n\n" 02811 ,IDO_API_RETENTIONDATA 02812 ,IDO_DATA_TYPE 02813 ,rdata->type 02814 ,IDO_DATA_FLAGS 02815 ,rdata->flags 02816 ,IDO_DATA_ATTRIBUTES 02817 ,rdata->attr 02818 ,IDO_DATA_TIMESTAMP 02819 ,rdata->timestamp.tv_sec 02820 ,rdata->timestamp.tv_usec 02821 ,IDO_API_ENDDATA 02822 ); 02823 02824 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02825 ido_dbuf_strcat(&dbuf,temp_buffer); 02826 02827 break; 02828 02829 case NEBCALLBACK_CONTACT_NOTIFICATION_DATA: 02830 02831 cnotdata=(nebstruct_contact_notification_data *)data; 02832 02833 es[0]=ido_escape_buffer(cnotdata->host_name); 02834 es[1]=ido_escape_buffer(cnotdata->service_description); 02835 es[2]=ido_escape_buffer(cnotdata->output); 02836 /* Preparing if contact notifications will have long_output in the future */ 02837 es[3]=ido_escape_buffer(cnotdata->output); 02838 es[4]=ido_escape_buffer(cnotdata->ack_author); 02839 es[5]=ido_escape_buffer(cnotdata->ack_data); 02840 es[6]=ido_escape_buffer(cnotdata->contact_name); 02841 02842 snprintf(temp_buffer,sizeof(temp_buffer)-1 02843 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%ld.%ld\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d\n\n" 02844 ,IDO_API_CONTACTNOTIFICATIONDATA 02845 ,IDO_DATA_TYPE 02846 ,cnotdata->type 02847 ,IDO_DATA_FLAGS 02848 ,cnotdata->flags 02849 ,IDO_DATA_ATTRIBUTES 02850 ,cnotdata->attr 02851 ,IDO_DATA_TIMESTAMP 02852 ,cnotdata->timestamp.tv_sec 02853 ,cnotdata->timestamp.tv_usec 02854 ,IDO_DATA_NOTIFICATIONTYPE 02855 ,cnotdata->notification_type 02856 ,IDO_DATA_STARTTIME 02857 ,cnotdata->start_time.tv_sec 02858 ,cnotdata->start_time.tv_usec 02859 ,IDO_DATA_ENDTIME 02860 ,cnotdata->end_time.tv_sec 02861 ,cnotdata->end_time.tv_usec 02862 ,IDO_DATA_HOST 02863 ,(es[0]==NULL)?"":es[0] 02864 ,IDO_DATA_SERVICE 02865 ,(es[1]==NULL)?"":es[1] 02866 ,IDO_DATA_CONTACTNAME 02867 ,(es[6]==NULL)?"":es[6] 02868 ,IDO_DATA_NOTIFICATIONREASON 02869 ,cnotdata->reason_type 02870 ,IDO_DATA_STATE 02871 ,cnotdata->state 02872 ,IDO_DATA_OUTPUT 02873 ,(es[2]==NULL)?"":es[2] 02874 ,IDO_DATA_LONGOUTPUT 02875 ,(es[3]==NULL)?"":es[3] 02876 ,IDO_DATA_ACKAUTHOR 02877 ,(es[4]==NULL)?"":es[4] 02878 ,IDO_DATA_ACKDATA 02879 ,(es[5]==NULL)?"":es[5] 02880 ,IDO_API_ENDDATA 02881 ); 02882 02883 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02884 ido_dbuf_strcat(&dbuf,temp_buffer); 02885 02886 break; 02887 02888 case NEBCALLBACK_CONTACT_NOTIFICATION_METHOD_DATA: 02889 02890 cnotmdata=(nebstruct_contact_notification_method_data *)data; 02891 02892 es[0]=ido_escape_buffer(cnotmdata->host_name); 02893 es[1]=ido_escape_buffer(cnotmdata->service_description); 02894 es[2]=ido_escape_buffer(cnotmdata->output); 02895 /* Preparing if contact notifications method will have long_output in the future */ 02896 es[3]=ido_escape_buffer(cnotmdata->output); 02897 es[4]=ido_escape_buffer(cnotmdata->ack_author); 02898 es[5]=ido_escape_buffer(cnotmdata->ack_data); 02899 es[6]=ido_escape_buffer(cnotmdata->contact_name); 02900 es[7]=ido_escape_buffer(cnotmdata->command_name); 02901 es[8]=ido_escape_buffer(cnotmdata->command_args); 02902 02903 snprintf(temp_buffer,sizeof(temp_buffer)-1 02904 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%ld.%ld\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d\n\n" 02905 ,IDO_API_CONTACTNOTIFICATIONMETHODDATA 02906 ,IDO_DATA_TYPE 02907 ,cnotmdata->type 02908 ,IDO_DATA_FLAGS 02909 ,cnotmdata->flags 02910 ,IDO_DATA_ATTRIBUTES 02911 ,cnotmdata->attr 02912 ,IDO_DATA_TIMESTAMP 02913 ,cnotmdata->timestamp.tv_sec 02914 ,cnotmdata->timestamp.tv_usec 02915 ,IDO_DATA_NOTIFICATIONTYPE 02916 ,cnotmdata->notification_type 02917 ,IDO_DATA_STARTTIME 02918 ,cnotmdata->start_time.tv_sec 02919 ,cnotmdata->start_time.tv_usec 02920 ,IDO_DATA_ENDTIME 02921 ,cnotmdata->end_time.tv_sec 02922 ,cnotmdata->end_time.tv_usec 02923 ,IDO_DATA_HOST 02924 ,(es[0]==NULL)?"":es[0] 02925 ,IDO_DATA_SERVICE 02926 ,(es[1]==NULL)?"":es[1] 02927 ,IDO_DATA_CONTACTNAME 02928 ,(es[6]==NULL)?"":es[6] 02929 ,IDO_DATA_COMMANDNAME 02930 ,(es[7]==NULL)?"":es[7] 02931 ,IDO_DATA_COMMANDARGS 02932 ,(es[8]==NULL)?"":es[8] 02933 ,IDO_DATA_NOTIFICATIONREASON 02934 ,cnotmdata->reason_type 02935 ,IDO_DATA_STATE 02936 ,cnotmdata->state 02937 ,IDO_DATA_OUTPUT 02938 ,(es[2]==NULL)?"":es[2] 02939 ,IDO_DATA_LONGOUTPUT 02940 ,(es[3]==NULL)?"":es[3] 02941 ,IDO_DATA_ACKAUTHOR 02942 ,(es[4]==NULL)?"":es[4] 02943 ,IDO_DATA_ACKDATA 02944 ,(es[5]==NULL)?"":es[5] 02945 ,IDO_API_ENDDATA 02946 ); 02947 02948 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02949 ido_dbuf_strcat(&dbuf,temp_buffer); 02950 02951 break; 02952 02953 case NEBCALLBACK_ACKNOWLEDGEMENT_DATA: 02954 02955 ackdata=(nebstruct_acknowledgement_data *)data; 02956 02957 es[0]=ido_escape_buffer(ackdata->host_name); 02958 es[1]=ido_escape_buffer(ackdata->service_description); 02959 es[2]=ido_escape_buffer(ackdata->author_name); 02960 es[3]=ido_escape_buffer(ackdata->comment_data); 02961 02962 snprintf(temp_buffer,sizeof(temp_buffer)-1 02963 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d\n\n" 02964 ,IDO_API_ACKNOWLEDGEMENTDATA 02965 ,IDO_DATA_TYPE 02966 ,ackdata->type 02967 ,IDO_DATA_FLAGS 02968 ,ackdata->flags 02969 ,IDO_DATA_ATTRIBUTES 02970 ,ackdata->attr 02971 ,IDO_DATA_TIMESTAMP 02972 ,ackdata->timestamp.tv_sec 02973 ,ackdata->timestamp.tv_usec 02974 ,IDO_DATA_ACKNOWLEDGEMENTTYPE 02975 ,ackdata->acknowledgement_type 02976 ,IDO_DATA_HOST 02977 ,(es[0]==NULL)?"":es[0] 02978 ,IDO_DATA_SERVICE 02979 ,(es[1]==NULL)?"":es[1] 02980 ,IDO_DATA_AUTHORNAME 02981 ,(es[2]==NULL)?"":es[2] 02982 ,IDO_DATA_COMMENT 02983 ,(es[3]==NULL)?"":es[3] 02984 ,IDO_DATA_STATE 02985 ,ackdata->state 02986 ,IDO_DATA_STICKY 02987 ,ackdata->is_sticky 02988 ,IDO_DATA_PERSISTENT 02989 ,ackdata->persistent_comment 02990 ,IDO_DATA_NOTIFYCONTACTS 02991 ,ackdata->notify_contacts 02992 ,IDO_API_ENDDATA 02993 ); 02994 02995 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 02996 ido_dbuf_strcat(&dbuf,temp_buffer); 02997 02998 break; 02999 03000 case NEBCALLBACK_STATE_CHANGE_DATA: 03001 03002 schangedata=(nebstruct_statechange_data *)data; 03003 03004 /* get the last state info */ 03005 if(schangedata->service_description==NULL){ 03006 if((temp_host=(host *)schangedata->object_ptr)==NULL){ 03007 ido_dbuf_free(&dbuf); 03008 return 0; 03009 } 03010 last_state=temp_host->last_state; 03011 last_state=temp_host->last_hard_state; 03012 } 03013 else{ 03014 if((temp_service=(service *)schangedata->object_ptr)==NULL){ 03015 ido_dbuf_free(&dbuf); 03016 return 0; 03017 } 03018 last_state=temp_service->last_state; 03019 last_hard_state=temp_service->last_hard_state; 03020 } 03021 03022 es[0]=ido_escape_buffer(schangedata->host_name); 03023 es[1]=ido_escape_buffer(schangedata->service_description); 03024 es[2]=ido_escape_buffer(schangedata->output); 03025 /* Preparing if servicecheck change data will have long_output in the future */ 03026 es[3]=ido_escape_buffer(schangedata->output); 03027 03028 snprintf(temp_buffer,sizeof(temp_buffer)-1 03029 ,"\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%d\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%s\n%d=%s\n%d\n\n" 03030 ,IDO_API_STATECHANGEDATA 03031 ,IDO_DATA_TYPE 03032 ,schangedata->type 03033 ,IDO_DATA_FLAGS 03034 ,schangedata->flags 03035 ,IDO_DATA_ATTRIBUTES 03036 ,schangedata->attr 03037 ,IDO_DATA_TIMESTAMP 03038 ,schangedata->timestamp.tv_sec 03039 ,schangedata->timestamp.tv_usec 03040 ,IDO_DATA_STATECHANGETYPE 03041 ,schangedata->statechange_type 03042 ,IDO_DATA_HOST 03043 ,(es[0]==NULL)?"":es[0] 03044 ,IDO_DATA_SERVICE 03045 ,(es[1]==NULL)?"":es[1] 03046 ,IDO_DATA_STATECHANGE 03047 ,TRUE 03048 ,IDO_DATA_STATE 03049 ,schangedata->state 03050 ,IDO_DATA_STATETYPE 03051 ,schangedata->state_type 03052 ,IDO_DATA_CURRENTCHECKATTEMPT 03053 ,schangedata->current_attempt 03054 ,IDO_DATA_MAXCHECKATTEMPTS 03055 ,schangedata->max_attempts 03056 ,IDO_DATA_LASTSTATE 03057 ,last_state 03058 ,IDO_DATA_LASTHARDSTATE 03059 ,last_hard_state 03060 ,IDO_DATA_OUTPUT 03061 ,es[2] 03062 ,IDO_DATA_LONGOUTPUT 03063 ,es[3] 03064 ,IDO_API_ENDDATA 03065 ); 03066 03067 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03068 ido_dbuf_strcat(&dbuf,temp_buffer); 03069 03070 break; 03071 03072 default: 03073 ido_dbuf_free(&dbuf); 03074 return 0; 03075 break; 03076 } 03077 03078 /* free escaped buffers */ 03079 for(x=0;x<8;x++){ 03080 free(es[x]); 03081 es[x]=NULL; 03082 } 03083 03084 /* write data to sink */ 03085 if(write_to_sink==IDO_TRUE) 03086 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 03087 03088 /* free dynamic buffer */ 03089 ido_dbuf_free(&dbuf); 03090 03091 03092 03093 /* POST PROCESSING... */ 03094 03095 switch(event_type){ 03096 03097 case NEBCALLBACK_PROCESS_DATA: 03098 03099 procdata=(nebstruct_process_data *)data; 03100 03101 /* process has passed pre-launch config verification, so dump original config */ 03102 if(procdata->type==NEBTYPE_PROCESS_START){ 03103 idomod_write_config_files(); 03104 idomod_write_config(IDOMOD_CONFIG_DUMP_ORIGINAL); 03105 } 03106 03107 /* process is starting the event loop, so dump runtime vars */ 03108 if(procdata->type==NEBTYPE_PROCESS_EVENTLOOPSTART){ 03109 idomod_write_runtime_variables(); 03110 } 03111 03112 break; 03113 03114 case NEBCALLBACK_RETENTION_DATA: 03115 03116 rdata=(nebstruct_retention_data *)data; 03117 03118 /* retained config was just read, so dump it */ 03119 if(rdata->type==NEBTYPE_RETENTIONDATA_ENDLOAD) 03120 idomod_write_config(IDOMOD_CONFIG_DUMP_RETAINED); 03121 03122 break; 03123 03124 default: 03125 break; 03126 } 03127 03128 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_broker_data() end\n"); 03129 03130 return 0; 03131 } 03132 03133 03134 03135 /****************************************************************************/ 03136 /* CONFIG OUTPUT FUNCTIONS */ 03137 /****************************************************************************/ 03138 03139 /* dumps all configuration data to sink */ 03140 int idomod_write_config(int config_type){ 03141 char temp_buffer[IDOMOD_MAX_BUFLEN]; 03142 struct timeval now; 03143 int result; 03144 03145 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_config() start\n"); 03146 03147 if(!(idomod_config_output_options & config_type)) 03148 return IDO_OK; 03149 03150 gettimeofday(&now,NULL); 03151 03152 /* record start of config dump */ 03153 snprintf(temp_buffer,sizeof(temp_buffer)-1 03154 ,"\n\n%d:\n%d=%s\n%d=%ld.%ld\n%d\n\n" 03155 ,IDO_API_STARTCONFIGDUMP 03156 ,IDO_DATA_CONFIGDUMPTYPE 03157 ,(config_type==IDOMOD_CONFIG_DUMP_ORIGINAL)?IDO_API_CONFIGDUMP_ORIGINAL:IDO_API_CONFIGDUMP_RETAINED 03158 ,IDO_DATA_TIMESTAMP 03159 ,now.tv_sec 03160 ,now.tv_usec 03161 ,IDO_API_ENDDATA 03162 ); 03163 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03164 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 03165 03166 /* dump object config info */ 03167 result=idomod_write_object_config(config_type); 03168 if(result!=IDO_OK) 03169 return result; 03170 03171 /* record end of config dump */ 03172 snprintf(temp_buffer,sizeof(temp_buffer)-1 03173 ,"\n\n%d:\n%d=%ld.%ld\n%d\n\n" 03174 ,IDO_API_ENDCONFIGDUMP 03175 ,IDO_DATA_TIMESTAMP 03176 ,now.tv_sec 03177 ,now.tv_usec 03178 ,IDO_API_ENDDATA 03179 ); 03180 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03181 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 03182 03183 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_config() end\n"); 03184 03185 return result; 03186 } 03187 03188 03189 #define OBJECTCONFIG_ES_ITEMS 16 03190 03191 /* dumps object configuration data to sink */ 03192 int idomod_write_object_config(int config_type){ 03193 char temp_buffer[IDOMOD_MAX_BUFLEN]; 03194 ido_dbuf dbuf; 03195 struct timeval now; 03196 int x=0; 03197 char *es[OBJECTCONFIG_ES_ITEMS]; 03198 command *temp_command=NULL; 03199 timeperiod *temp_timeperiod=NULL; 03200 timerange *temp_timerange=NULL; 03201 contact *temp_contact=NULL; 03202 commandsmember *temp_commandsmember=NULL; 03203 contactgroup *temp_contactgroup=NULL; 03204 host *temp_host=NULL; 03205 hostsmember *temp_hostsmember=NULL; 03206 contactgroupsmember *temp_contactgroupsmember=NULL; 03207 hostgroup *temp_hostgroup=NULL; 03208 service *temp_service=NULL; 03209 servicegroup *temp_servicegroup=NULL; 03210 hostescalation *temp_hostescalation=NULL; 03211 serviceescalation *temp_serviceescalation=NULL; 03212 hostdependency *temp_hostdependency=NULL; 03213 servicedependency *temp_servicedependency=NULL; 03214 int have_2d_coords=FALSE; 03215 int x_2d=0; 03216 int y_2d=0; 03217 int have_3d_coords=FALSE; 03218 double x_3d=0.0; 03219 double y_3d=0.0; 03220 double z_3d=0.0; 03221 double first_notification_delay=0.0; 03222 double retry_interval=0.0; 03223 int notify_on_host_downtime=0; 03224 int notify_on_service_downtime=0; 03225 int host_notifications_enabled=0; 03226 int service_notifications_enabled=0; 03227 int can_submit_commands=0; 03228 int flap_detection_on_up=0; 03229 int flap_detection_on_down=0; 03230 int flap_detection_on_unreachable=0; 03231 int flap_detection_on_ok=0; 03232 int flap_detection_on_warning=0; 03233 int flap_detection_on_unknown=0; 03234 int flap_detection_on_critical=0; 03235 customvariablesmember *temp_customvar=NULL; 03236 contactsmember *temp_contactsmember=NULL; 03237 servicesmember *temp_servicesmember=NULL; 03238 03239 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_object_config() start\n"); 03240 03241 if(!(idomod_process_options & IDOMOD_PROCESS_OBJECT_CONFIG_DATA)) 03242 return IDO_OK; 03243 03244 if(!(idomod_config_output_options & config_type)) 03245 return IDO_OK; 03246 03247 /* get current time */ 03248 gettimeofday(&now,NULL); 03249 03250 /* initialize dynamic buffer (2KB chunk size) */ 03251 ido_dbuf_init(&dbuf,2048); 03252 03253 /* initialize buffers */ 03254 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++) 03255 es[x]=NULL; 03256 03257 /****** dump command config ******/ 03258 for(temp_command=command_list;temp_command!=NULL;temp_command=temp_command->next){ 03259 03260 es[0]=ido_escape_buffer(temp_command->name); 03261 es[1]=ido_escape_buffer(temp_command->command_line); 03262 03263 snprintf(temp_buffer,sizeof(temp_buffer)-1 03264 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d\n\n" 03265 ,IDO_API_COMMANDDEFINITION 03266 ,IDO_DATA_TIMESTAMP 03267 ,now.tv_sec 03268 ,now.tv_usec 03269 ,IDO_DATA_COMMANDNAME 03270 ,(es[0]==NULL)?"":es[0] 03271 ,IDO_DATA_COMMANDLINE 03272 ,(es[1]==NULL)?"":es[1] 03273 ,IDO_API_ENDDATA 03274 ); 03275 03276 /* write data to sink */ 03277 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03278 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 03279 } 03280 03281 /* free buffers */ 03282 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 03283 free(es[x]); 03284 es[x]=NULL; 03285 } 03286 03287 /****** dump timeperiod config ******/ 03288 for(temp_timeperiod=timeperiod_list;temp_timeperiod!=NULL;temp_timeperiod=temp_timeperiod->next){ 03289 03290 es[0]=ido_escape_buffer(temp_timeperiod->name); 03291 es[1]=ido_escape_buffer(temp_timeperiod->alias); 03292 03293 snprintf(temp_buffer,sizeof(temp_buffer)-1 03294 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n" 03295 ,IDO_API_TIMEPERIODDEFINITION 03296 ,IDO_DATA_TIMESTAMP 03297 ,now.tv_sec 03298 ,now.tv_usec 03299 ,IDO_DATA_TIMEPERIODNAME 03300 ,(es[0]==NULL)?"":es[0] 03301 ,IDO_DATA_TIMEPERIODALIAS 03302 ,(es[1]==NULL)?"":es[1] 03303 ); 03304 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03305 ido_dbuf_strcat(&dbuf,temp_buffer); 03306 03307 /* dump timeranges for each day */ 03308 for(x=0;x<7;x++){ 03309 for(temp_timerange=temp_timeperiod->days[x];temp_timerange!=NULL;temp_timerange=temp_timerange->next){ 03310 03311 snprintf(temp_buffer,sizeof(temp_buffer)-1 03312 ,"%d=%d:%lu-%lu\n" 03313 ,IDO_DATA_TIMERANGE 03314 ,x 03315 ,temp_timerange->range_start 03316 ,temp_timerange->range_end 03317 ); 03318 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03319 ido_dbuf_strcat(&dbuf,temp_buffer); 03320 } 03321 } 03322 03323 snprintf(temp_buffer,sizeof(temp_buffer)-1 03324 ,"%d\n\n" 03325 ,IDO_API_ENDDATA 03326 ); 03327 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03328 ido_dbuf_strcat(&dbuf,temp_buffer); 03329 03330 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 03331 03332 ido_dbuf_free(&dbuf); 03333 } 03334 03335 03336 /* free buffers */ 03337 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 03338 free(es[x]); 03339 es[x]=NULL; 03340 } 03341 03342 /****** dump contact config ******/ 03343 for(temp_contact=contact_list;temp_contact!=NULL;temp_contact=temp_contact->next){ 03344 03345 es[0]=ido_escape_buffer(temp_contact->name); 03346 es[1]=ido_escape_buffer(temp_contact->alias); 03347 es[2]=ido_escape_buffer(temp_contact->email); 03348 es[3]=ido_escape_buffer(temp_contact->pager); 03349 es[4]=ido_escape_buffer(temp_contact->host_notification_period); 03350 es[5]=ido_escape_buffer(temp_contact->service_notification_period); 03351 03352 notify_on_service_downtime=temp_contact->notify_on_service_downtime; 03353 notify_on_host_downtime=temp_contact->notify_on_host_downtime; 03354 host_notifications_enabled=temp_contact->host_notifications_enabled; 03355 service_notifications_enabled=temp_contact->service_notifications_enabled; 03356 can_submit_commands=temp_contact->can_submit_commands; 03357 03358 snprintf(temp_buffer,sizeof(temp_buffer)-1 03359 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n" 03360 ,IDO_API_CONTACTDEFINITION 03361 ,IDO_DATA_TIMESTAMP 03362 ,now.tv_sec 03363 ,now.tv_usec 03364 ,IDO_DATA_CONTACTNAME 03365 ,(es[0]==NULL)?"":es[0] 03366 ,IDO_DATA_CONTACTALIAS 03367 ,(es[1]==NULL)?"":es[1] 03368 ,IDO_DATA_EMAILADDRESS 03369 ,(es[2]==NULL)?"":es[2] 03370 ,IDO_DATA_PAGERADDRESS 03371 ,(es[3]==NULL)?"":es[3] 03372 ,IDO_DATA_HOSTNOTIFICATIONPERIOD 03373 ,(es[4]==NULL)?"":es[4] 03374 ,IDO_DATA_SERVICENOTIFICATIONPERIOD 03375 ,(es[5]==NULL)?"":es[5] 03376 ,IDO_DATA_SERVICENOTIFICATIONSENABLED 03377 ,service_notifications_enabled 03378 ,IDO_DATA_HOSTNOTIFICATIONSENABLED 03379 ,host_notifications_enabled 03380 ,IDO_DATA_CANSUBMITCOMMANDS 03381 ,can_submit_commands 03382 ,IDO_DATA_NOTIFYSERVICEUNKNOWN 03383 ,temp_contact->notify_on_service_unknown 03384 ,IDO_DATA_NOTIFYSERVICEWARNING 03385 ,temp_contact->notify_on_service_warning 03386 ,IDO_DATA_NOTIFYSERVICECRITICAL 03387 ,temp_contact->notify_on_service_critical 03388 ,IDO_DATA_NOTIFYSERVICERECOVERY 03389 ,temp_contact->notify_on_service_recovery 03390 ,IDO_DATA_NOTIFYSERVICEFLAPPING 03391 ,temp_contact->notify_on_service_flapping 03392 ,IDO_DATA_NOTIFYSERVICEDOWNTIME 03393 ,notify_on_service_downtime 03394 ,IDO_DATA_NOTIFYHOSTDOWN 03395 ,temp_contact->notify_on_host_down 03396 ,IDO_DATA_NOTIFYHOSTUNREACHABLE 03397 ,temp_contact->notify_on_host_unreachable 03398 ,IDO_DATA_NOTIFYHOSTRECOVERY 03399 ,temp_contact->notify_on_host_recovery 03400 ,IDO_DATA_NOTIFYHOSTFLAPPING 03401 ,temp_contact->notify_on_host_flapping 03402 ,IDO_DATA_NOTIFYHOSTDOWNTIME 03403 ,notify_on_host_downtime 03404 ); 03405 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03406 ido_dbuf_strcat(&dbuf,temp_buffer); 03407 03408 free(es[0]); 03409 es[0]=NULL; 03410 03411 /* dump addresses for each contact */ 03412 for(x=0;x<MAX_CONTACT_ADDRESSES;x++){ 03413 03414 es[0]=ido_escape_buffer(temp_contact->address[x]); 03415 03416 snprintf(temp_buffer,sizeof(temp_buffer)-1 03417 ,"%d=%d:%s\n" 03418 ,IDO_DATA_CONTACTADDRESS 03419 ,x+1 03420 ,(es[0]==NULL)?"":es[0] 03421 ); 03422 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03423 ido_dbuf_strcat(&dbuf,temp_buffer); 03424 03425 free(es[0]); 03426 es[0]=NULL; 03427 } 03428 03429 /* dump host notification commands for each contact */ 03430 for(temp_commandsmember=temp_contact->host_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){ 03431 03432 es[0]=ido_escape_buffer(temp_commandsmember->command); 03433 03434 snprintf(temp_buffer,sizeof(temp_buffer)-1 03435 ,"%d=%s\n" 03436 ,IDO_DATA_HOSTNOTIFICATIONCOMMAND 03437 ,(es[0]==NULL)?"":es[0] 03438 ); 03439 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03440 ido_dbuf_strcat(&dbuf,temp_buffer); 03441 03442 free(es[0]); 03443 es[0]=NULL; 03444 } 03445 03446 /* dump service notification commands for each contact */ 03447 for(temp_commandsmember=temp_contact->service_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){ 03448 03449 es[0]=ido_escape_buffer(temp_commandsmember->command); 03450 03451 snprintf(temp_buffer,sizeof(temp_buffer)-1 03452 ,"%d=%s\n" 03453 ,IDO_DATA_SERVICENOTIFICATIONCOMMAND 03454 ,(es[0]==NULL)?"":es[0] 03455 ); 03456 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03457 ido_dbuf_strcat(&dbuf,temp_buffer); 03458 03459 free(es[0]); 03460 es[0]=NULL; 03461 } 03462 03463 /* dump customvars */ 03464 for(temp_customvar=temp_contact->custom_variables;temp_customvar!=NULL;temp_customvar=temp_customvar->next){ 03465 03466 es[0]=ido_escape_buffer(temp_customvar->variable_name); 03467 es[1]=ido_escape_buffer(temp_customvar->variable_value); 03468 03469 snprintf(temp_buffer,sizeof(temp_buffer)-1 03470 ,"%d=%s:%d:%s\n" 03471 ,IDO_DATA_CUSTOMVARIABLE 03472 ,(es[0]==NULL)?"":es[0] 03473 ,temp_customvar->has_been_modified 03474 ,(es[1]==NULL)?"":es[1] 03475 ); 03476 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03477 ido_dbuf_strcat(&dbuf,temp_buffer); 03478 03479 for(x=0;x<2;x++){ 03480 free(es[x]); 03481 es[x]=NULL; 03482 } 03483 } 03484 03485 snprintf(temp_buffer,sizeof(temp_buffer)-1 03486 ,"%d\n\n" 03487 ,IDO_API_ENDDATA 03488 ); 03489 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03490 ido_dbuf_strcat(&dbuf,temp_buffer); 03491 03492 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 03493 03494 ido_dbuf_free(&dbuf); 03495 } 03496 03497 03498 /* free buffers */ 03499 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 03500 free(es[x]); 03501 es[x]=NULL; 03502 } 03503 03504 /****** dump contactgroup config ******/ 03505 for(temp_contactgroup=contactgroup_list;temp_contactgroup!=NULL;temp_contactgroup=temp_contactgroup->next){ 03506 03507 es[0]=ido_escape_buffer(temp_contactgroup->group_name); 03508 es[1]=ido_escape_buffer(temp_contactgroup->alias); 03509 03510 snprintf(temp_buffer,sizeof(temp_buffer)-1 03511 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n" 03512 ,IDO_API_CONTACTGROUPDEFINITION 03513 ,IDO_DATA_TIMESTAMP 03514 ,now.tv_sec 03515 ,now.tv_usec 03516 ,IDO_DATA_CONTACTGROUPNAME 03517 ,(es[0]==NULL)?"":es[0] 03518 ,IDO_DATA_CONTACTGROUPALIAS 03519 ,(es[1]==NULL)?"":es[1] 03520 ); 03521 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03522 ido_dbuf_strcat(&dbuf,temp_buffer); 03523 03524 free(es[0]); 03525 es[0]=NULL; 03526 03527 /* dump members for each contactgroup */ 03528 for(temp_contactsmember=temp_contactgroup->members;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next) 03529 { 03530 03531 es[0]=ido_escape_buffer(temp_contactsmember->contact_name); 03532 03533 snprintf(temp_buffer,sizeof(temp_buffer)-1 03534 ,"%d=%s\n" 03535 ,IDO_DATA_CONTACTGROUPMEMBER 03536 ,(es[0]==NULL)?"":es[0] 03537 ); 03538 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03539 ido_dbuf_strcat(&dbuf,temp_buffer); 03540 03541 free(es[0]); 03542 es[0]=NULL; 03543 } 03544 03545 snprintf(temp_buffer,sizeof(temp_buffer)-1 03546 ,"%d\n\n" 03547 ,IDO_API_ENDDATA 03548 ); 03549 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03550 ido_dbuf_strcat(&dbuf,temp_buffer); 03551 03552 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 03553 03554 ido_dbuf_free(&dbuf); 03555 } 03556 03557 03558 /* free buffers */ 03559 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 03560 free(es[x]); 03561 es[x]=NULL; 03562 } 03563 03564 /****** dump host config ******/ 03565 for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){ 03566 03567 es[0]=ido_escape_buffer(temp_host->name); 03568 es[1]=ido_escape_buffer(temp_host->alias); 03569 es[2]=ido_escape_buffer(temp_host->address); 03570 es[3]=ido_escape_buffer(temp_host->host_check_command); 03571 es[4]=ido_escape_buffer(temp_host->event_handler); 03572 es[5]=ido_escape_buffer(temp_host->notification_period); 03573 es[6]=ido_escape_buffer(temp_host->check_period); 03574 es[7]=ido_escape_buffer(temp_host->failure_prediction_options); 03575 03576 es[7]=ido_escape_buffer(temp_host->notes); 03577 es[8]=ido_escape_buffer(temp_host->notes_url); 03578 es[9]=ido_escape_buffer(temp_host->action_url); 03579 es[10]=ido_escape_buffer(temp_host->icon_image); 03580 es[11]=ido_escape_buffer(temp_host->icon_image_alt); 03581 es[12]=ido_escape_buffer(temp_host->vrml_image); 03582 es[13]=ido_escape_buffer(temp_host->statusmap_image); 03583 have_2d_coords=temp_host->have_2d_coords; 03584 x_2d=temp_host->x_2d; 03585 y_2d=temp_host->y_2d; 03586 have_3d_coords=temp_host->have_3d_coords; 03587 x_3d=temp_host->x_3d; 03588 y_3d=temp_host->y_3d; 03589 z_3d=temp_host->z_3d; 03590 03591 first_notification_delay=temp_host->first_notification_delay; 03592 retry_interval=temp_host->retry_interval; 03593 notify_on_host_downtime=temp_host->notify_on_downtime; 03594 flap_detection_on_up=temp_host->flap_detection_on_up; 03595 flap_detection_on_down=temp_host->flap_detection_on_down; 03596 flap_detection_on_unreachable=temp_host->flap_detection_on_unreachable; 03597 es[14]=ido_escape_buffer(temp_host->display_name); 03598 es[15]=ido_escape_buffer(temp_host->address6); 03599 03600 snprintf(temp_buffer,sizeof(temp_buffer)-1 03601 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%d\n%d=%lf\n%d=%lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lf\n%d=%lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lf\n%d=%lf\n%d=%lf\n" 03602 ,IDO_API_HOSTDEFINITION 03603 ,IDO_DATA_TIMESTAMP 03604 ,now.tv_sec 03605 ,now.tv_usec 03606 ,IDO_DATA_HOSTNAME 03607 ,(es[0]==NULL)?"":es[0] 03608 ,IDO_DATA_DISPLAYNAME 03609 ,(es[14]==NULL)?"":es[14] 03610 ,IDO_DATA_HOSTALIAS 03611 ,(es[1]==NULL)?"":es[1] 03612 ,IDO_DATA_HOSTADDRESS 03613 ,(es[2]==NULL)?"":es[2] 03614 ,IDO_DATA_HOSTADDRESS6 03615 ,(es[15]==NULL)?"":es[15] 03616 ,IDO_DATA_HOSTCHECKCOMMAND 03617 ,(es[3]==NULL)?"":es[3] 03618 ,IDO_DATA_HOSTEVENTHANDLER 03619 ,(es[4]==NULL)?"":es[4] 03620 ,IDO_DATA_HOSTNOTIFICATIONPERIOD 03621 ,(es[5]==NULL)?"":es[5] 03622 ,IDO_DATA_HOSTCHECKPERIOD 03623 ,(es[6]==NULL)?"":es[6] 03624 ,IDO_DATA_HOSTFAILUREPREDICTIONOPTIONS 03625 ,(es[7]==NULL)?"":es[7] 03626 ,IDO_DATA_HOSTCHECKINTERVAL 03627 ,(double)temp_host->check_interval 03628 ,IDO_DATA_HOSTRETRYINTERVAL 03629 ,(double)retry_interval 03630 ,IDO_DATA_HOSTMAXCHECKATTEMPTS 03631 ,temp_host->max_attempts 03632 ,IDO_DATA_FIRSTNOTIFICATIONDELAY 03633 ,first_notification_delay 03634 ,IDO_DATA_HOSTNOTIFICATIONINTERVAL 03635 ,(double)temp_host->notification_interval 03636 ,IDO_DATA_NOTIFYHOSTDOWN 03637 ,temp_host->notify_on_down 03638 ,IDO_DATA_NOTIFYHOSTUNREACHABLE 03639 ,temp_host->notify_on_unreachable 03640 ,IDO_DATA_NOTIFYHOSTRECOVERY 03641 ,temp_host->notify_on_recovery 03642 ,IDO_DATA_NOTIFYHOSTFLAPPING 03643 ,temp_host->notify_on_flapping 03644 ,IDO_DATA_NOTIFYHOSTDOWNTIME 03645 ,notify_on_host_downtime 03646 ,IDO_DATA_HOSTFLAPDETECTIONENABLED 03647 ,temp_host->flap_detection_enabled 03648 ,IDO_DATA_FLAPDETECTIONONUP 03649 ,flap_detection_on_up 03650 ,IDO_DATA_FLAPDETECTIONOIDOWN 03651 ,flap_detection_on_down 03652 ,IDO_DATA_FLAPDETECTIONONUNREACHABLE 03653 ,flap_detection_on_unreachable 03654 ,IDO_DATA_LOWHOSTFLAPTHRESHOLD 03655 ,temp_host->low_flap_threshold 03656 ,IDO_DATA_HIGHHOSTFLAPTHRESHOLD 03657 ,temp_host->high_flap_threshold 03658 ,IDO_DATA_STALKHOSTONUP 03659 ,temp_host->stalk_on_up 03660 ,IDO_DATA_STALKHOSTOIDOWN 03661 ,temp_host->stalk_on_down 03662 ,IDO_DATA_STALKHOSTONUNREACHABLE 03663 ,temp_host->stalk_on_unreachable 03664 ,IDO_DATA_HOSTFRESHNESSCHECKSENABLED 03665 ,temp_host->check_freshness 03666 ,IDO_DATA_HOSTFRESHNESSTHRESHOLD 03667 ,temp_host->freshness_threshold 03668 ,IDO_DATA_PROCESSHOSTPERFORMANCEDATA 03669 ,temp_host->process_performance_data 03670 ,IDO_DATA_ACTIVEHOSTCHECKSENABLED 03671 ,temp_host->checks_enabled 03672 ,IDO_DATA_PASSIVEHOSTCHECKSENABLED 03673 ,temp_host->accept_passive_host_checks 03674 ,IDO_DATA_HOSTEVENTHANDLERENABLED 03675 ,temp_host->event_handler_enabled 03676 ,IDO_DATA_RETAINHOSTSTATUSINFORMATION 03677 ,temp_host->retain_status_information 03678 ,IDO_DATA_RETAINHOSTNONSTATUSINFORMATION 03679 ,temp_host->retain_nonstatus_information 03680 ,IDO_DATA_HOSTNOTIFICATIONSENABLED 03681 ,temp_host->notifications_enabled 03682 ,IDO_DATA_HOSTFAILUREPREDICTIONENABLED 03683 ,temp_host->failure_prediction_enabled 03684 ,IDO_DATA_OBSESSOVERHOST 03685 ,temp_host->obsess_over_host 03686 ,IDO_DATA_NOTES 03687 ,(es[7]==NULL)?"":es[7] 03688 ,IDO_DATA_NOTESURL 03689 ,(es[8]==NULL)?"":es[8] 03690 ,IDO_DATA_ACTIONURL 03691 ,(es[9]==NULL)?"":es[9] 03692 ,IDO_DATA_ICONIMAGE 03693 ,(es[10]==NULL)?"":es[10] 03694 ,IDO_DATA_ICONIMAGEALT 03695 ,(es[11]==NULL)?"":es[11] 03696 ,IDO_DATA_VRMLIMAGE 03697 ,(es[12]==NULL)?"":es[12] 03698 ,IDO_DATA_STATUSMAPIMAGE 03699 ,(es[13]==NULL)?"":es[13] 03700 ,IDO_DATA_HAVE2DCOORDS 03701 ,have_2d_coords 03702 ,IDO_DATA_X2D 03703 ,x_2d 03704 ,IDO_DATA_Y2D 03705 ,y_2d 03706 ,IDO_DATA_HAVE3DCOORDS 03707 ,have_3d_coords 03708 ,IDO_DATA_X3D 03709 ,x_3d 03710 ,IDO_DATA_Y3D 03711 ,y_3d 03712 ,IDO_DATA_Z3D 03713 ,z_3d 03714 ); 03715 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03716 ido_dbuf_strcat(&dbuf,temp_buffer); 03717 03718 free(es[0]); 03719 es[0]=NULL; 03720 03721 /* dump parent hosts */ 03722 for(temp_hostsmember=temp_host->parent_hosts;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){ 03723 03724 es[0]=ido_escape_buffer(temp_hostsmember->host_name); 03725 03726 snprintf(temp_buffer,sizeof(temp_buffer)-1 03727 ,"%d=%s\n" 03728 ,IDO_DATA_PARENTHOST 03729 ,(es[0]==NULL)?"":es[0] 03730 ); 03731 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03732 ido_dbuf_strcat(&dbuf,temp_buffer); 03733 03734 free(es[0]); 03735 es[0]=NULL; 03736 } 03737 03738 /* dump contactgroups */ 03739 for(temp_contactgroupsmember=temp_host->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ 03740 03741 es[0]=ido_escape_buffer(temp_contactgroupsmember->group_name); 03742 03743 snprintf(temp_buffer,sizeof(temp_buffer)-1 03744 ,"%d=%s\n" 03745 ,IDO_DATA_CONTACTGROUP 03746 ,(es[0]==NULL)?"":es[0] 03747 ); 03748 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03749 ido_dbuf_strcat(&dbuf,temp_buffer); 03750 03751 free(es[0]); 03752 es[0]=NULL; 03753 } 03754 03755 /* dump individual contacts */ 03756 for(temp_contactsmember=temp_host->contacts;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next){ 03757 03758 es[0]=ido_escape_buffer(temp_contactsmember->contact_name); 03759 03760 snprintf(temp_buffer,sizeof(temp_buffer)-1 03761 ,"%d=%s\n" 03762 ,IDO_DATA_CONTACT 03763 ,(es[0]==NULL)?"":es[0] 03764 ); 03765 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03766 ido_dbuf_strcat(&dbuf,temp_buffer); 03767 03768 free(es[0]); 03769 es[0]=NULL; 03770 } 03771 03772 03773 /* dump customvars */ 03774 for(temp_customvar=temp_host->custom_variables;temp_customvar!=NULL;temp_customvar=temp_customvar->next){ 03775 03776 es[0]=ido_escape_buffer(temp_customvar->variable_name); 03777 es[1]=ido_escape_buffer(temp_customvar->variable_value); 03778 03779 snprintf(temp_buffer,sizeof(temp_buffer)-1 03780 ,"%d=%s:%d:%s\n" 03781 ,IDO_DATA_CUSTOMVARIABLE 03782 ,(es[0]==NULL)?"":es[0] 03783 ,temp_customvar->has_been_modified 03784 ,(es[1]==NULL)?"":es[1] 03785 ); 03786 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03787 ido_dbuf_strcat(&dbuf,temp_buffer); 03788 03789 for(x=0;x<2;x++){ 03790 free(es[x]); 03791 es[x]=NULL; 03792 } 03793 } 03794 03795 snprintf(temp_buffer,sizeof(temp_buffer)-1 03796 ,"%d\n\n" 03797 ,IDO_API_ENDDATA 03798 ); 03799 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03800 ido_dbuf_strcat(&dbuf,temp_buffer); 03801 03802 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 03803 03804 ido_dbuf_free(&dbuf); 03805 } 03806 03807 03808 /* free buffers */ 03809 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 03810 free(es[x]); 03811 es[x]=NULL; 03812 } 03813 03814 /****** dump hostgroup config ******/ 03815 for(temp_hostgroup=hostgroup_list;temp_hostgroup!=NULL;temp_hostgroup=temp_hostgroup->next){ 03816 03817 es[0]=ido_escape_buffer(temp_hostgroup->group_name); 03818 es[1]=ido_escape_buffer(temp_hostgroup->alias); 03819 03820 snprintf(temp_buffer,sizeof(temp_buffer)-1 03821 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n" 03822 ,IDO_API_HOSTGROUPDEFINITION 03823 ,IDO_DATA_TIMESTAMP 03824 ,now.tv_sec 03825 ,now.tv_usec 03826 ,IDO_DATA_HOSTGROUPNAME 03827 ,(es[0]==NULL)?"":es[0] 03828 ,IDO_DATA_HOSTGROUPALIAS 03829 ,(es[1]==NULL)?"":es[1] 03830 ); 03831 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03832 ido_dbuf_strcat(&dbuf,temp_buffer); 03833 03834 free(es[0]); 03835 es[0]=NULL; 03836 03837 /* dump members for each hostgroup */ 03838 for(temp_hostsmember=temp_hostgroup->members;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next) 03839 { 03840 03841 es[0]=ido_escape_buffer(temp_hostsmember->host_name); 03842 03843 snprintf(temp_buffer,sizeof(temp_buffer)-1 03844 ,"%d=%s\n" 03845 ,IDO_DATA_HOSTGROUPMEMBER 03846 ,(es[0]==NULL)?"":es[0] 03847 ); 03848 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03849 ido_dbuf_strcat(&dbuf,temp_buffer); 03850 03851 free(es[0]); 03852 es[0]=NULL; 03853 } 03854 03855 snprintf(temp_buffer,sizeof(temp_buffer)-1 03856 ,"%d\n\n" 03857 ,IDO_API_ENDDATA 03858 ); 03859 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 03860 ido_dbuf_strcat(&dbuf,temp_buffer); 03861 03862 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 03863 03864 ido_dbuf_free(&dbuf); 03865 } 03866 03867 03868 /* free buffers */ 03869 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 03870 free(es[x]); 03871 es[x]=NULL; 03872 } 03873 03874 /****** dump service config ******/ 03875 for(temp_service=service_list;temp_service!=NULL;temp_service=temp_service->next){ 03876 03877 es[0]=ido_escape_buffer(temp_service->host_name); 03878 es[1]=ido_escape_buffer(temp_service->description); 03879 es[2]=ido_escape_buffer(temp_service->service_check_command); 03880 es[3]=ido_escape_buffer(temp_service->event_handler); 03881 es[4]=ido_escape_buffer(temp_service->notification_period); 03882 es[5]=ido_escape_buffer(temp_service->check_period); 03883 es[6]=ido_escape_buffer(temp_service->failure_prediction_options); 03884 es[7]=ido_escape_buffer(temp_service->notes); 03885 es[8]=ido_escape_buffer(temp_service->notes_url); 03886 es[9]=ido_escape_buffer(temp_service->action_url); 03887 es[10]=ido_escape_buffer(temp_service->icon_image); 03888 es[11]=ido_escape_buffer(temp_service->icon_image_alt); 03889 03890 first_notification_delay=temp_service->first_notification_delay; 03891 notify_on_service_downtime=temp_service->notify_on_downtime; 03892 flap_detection_on_ok=temp_service->flap_detection_on_ok; 03893 flap_detection_on_warning=temp_service->flap_detection_on_warning; 03894 flap_detection_on_unknown=temp_service->flap_detection_on_unknown; 03895 flap_detection_on_critical=temp_service->flap_detection_on_critical; 03896 es[12]=ido_escape_buffer(temp_service->display_name); 03897 03898 snprintf(temp_buffer,sizeof(temp_buffer)-1 03899 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%d\n%d=%lf\n%d=%lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lf\n%d=%lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n" 03900 ,IDO_API_SERVICEDEFINITION 03901 ,IDO_DATA_TIMESTAMP 03902 ,now.tv_sec 03903 ,now.tv_usec 03904 ,IDO_DATA_HOSTNAME 03905 ,(es[0]==NULL)?"":es[0] 03906 ,IDO_DATA_DISPLAYNAME 03907 ,(es[12]==NULL)?"":es[12] 03908 ,IDO_DATA_SERVICEDESCRIPTION 03909 ,(es[1]==NULL)?"":es[1] 03910 ,IDO_DATA_SERVICECHECKCOMMAND 03911 ,(es[2]==NULL)?"":es[2] 03912 ,IDO_DATA_SERVICEEVENTHANDLER 03913 ,(es[3]==NULL)?"":es[3] 03914 ,IDO_DATA_SERVICENOTIFICATIONPERIOD 03915 ,(es[4]==NULL)?"":es[4] 03916 ,IDO_DATA_SERVICECHECKPERIOD 03917 ,(es[5]==NULL)?"":es[5] 03918 ,IDO_DATA_SERVICEFAILUREPREDICTIONOPTIONS 03919 ,(es[6]==NULL)?"":es[6] 03920 ,IDO_DATA_SERVICECHECKINTERVAL 03921 ,(double)temp_service->check_interval 03922 ,IDO_DATA_SERVICERETRYINTERVAL 03923 ,(double)temp_service->retry_interval 03924 ,IDO_DATA_MAXSERVICECHECKATTEMPTS 03925 ,temp_service->max_attempts 03926 ,IDO_DATA_FIRSTNOTIFICATIONDELAY 03927 ,first_notification_delay 03928 ,IDO_DATA_SERVICENOTIFICATIONINTERVAL 03929 ,(double)temp_service->notification_interval 03930 ,IDO_DATA_NOTIFYSERVICEUNKNOWN 03931 ,temp_service->notify_on_unknown 03932 ,IDO_DATA_NOTIFYSERVICEWARNING 03933 ,temp_service->notify_on_warning 03934 ,IDO_DATA_NOTIFYSERVICECRITICAL 03935 ,temp_service->notify_on_critical 03936 ,IDO_DATA_NOTIFYSERVICERECOVERY 03937 ,temp_service->notify_on_recovery 03938 ,IDO_DATA_NOTIFYSERVICEFLAPPING 03939 ,temp_service->notify_on_flapping 03940 ,IDO_DATA_NOTIFYSERVICEDOWNTIME 03941 ,notify_on_service_downtime 03942 ,IDO_DATA_STALKSERVICEONOK 03943 ,temp_service->stalk_on_ok 03944 ,IDO_DATA_STALKSERVICEONWARNING 03945 ,temp_service->stalk_on_warning 03946 ,IDO_DATA_STALKSERVICEONUNKNOWN 03947 ,temp_service->stalk_on_unknown 03948 ,IDO_DATA_STALKSERVICEONCRITICAL 03949 ,temp_service->stalk_on_critical 03950 ,IDO_DATA_SERVICEISVOLATILE 03951 ,temp_service->is_volatile 03952 ,IDO_DATA_SERVICEFLAPDETECTIONENABLED 03953 ,temp_service->flap_detection_enabled 03954 ,IDO_DATA_FLAPDETECTIONONOK 03955 ,flap_detection_on_ok 03956 ,IDO_DATA_FLAPDETECTIONONWARNING 03957 ,flap_detection_on_warning 03958 ,IDO_DATA_FLAPDETECTIONONUNKNOWN 03959 ,flap_detection_on_unknown 03960 ,IDO_DATA_FLAPDETECTIONONCRITICAL 03961 ,flap_detection_on_critical 03962 ,IDO_DATA_LOWSERVICEFLAPTHRESHOLD 03963 ,temp_service->low_flap_threshold 03964 ,IDO_DATA_HIGHSERVICEFLAPTHRESHOLD 03965 ,temp_service->high_flap_threshold 03966 ,IDO_DATA_PROCESSSERVICEPERFORMANCEDATA 03967 ,temp_service->process_performance_data 03968 ,IDO_DATA_SERVICEFRESHNESSCHECKSENABLED 03969 ,temp_service->check_freshness 03970 ,IDO_DATA_SERVICEFRESHNESSTHRESHOLD 03971 ,temp_service->freshness_threshold 03972 ,IDO_DATA_PASSIVESERVICECHECKSENABLED 03973 ,temp_service->accept_passive_service_checks 03974 ,IDO_DATA_SERVICEEVENTHANDLERENABLED 03975 ,temp_service->event_handler_enabled 03976 ,IDO_DATA_ACTIVESERVICECHECKSENABLED 03977 ,temp_service->checks_enabled 03978 ,IDO_DATA_RETAINSERVICESTATUSINFORMATION 03979 ,temp_service->retain_status_information 03980 ,IDO_DATA_RETAINSERVICENONSTATUSINFORMATION 03981 ,temp_service->retain_nonstatus_information 03982 ,IDO_DATA_SERVICENOTIFICATIONSENABLED 03983 ,temp_service->notifications_enabled 03984 ,IDO_DATA_OBSESSOVERSERVICE 03985 ,temp_service->obsess_over_service 03986 ,IDO_DATA_SERVICEFAILUREPREDICTIONENABLED 03987 ,temp_service->failure_prediction_enabled 03988 ,IDO_DATA_NOTES 03989 ,(es[7]==NULL)?"":es[7] 03990 ,IDO_DATA_NOTESURL 03991 ,(es[8]==NULL)?"":es[8] 03992 ,IDO_DATA_ACTIONURL 03993 ,(es[9]==NULL)?"":es[9] 03994 ,IDO_DATA_ICONIMAGE 03995 ,(es[10]==NULL)?"":es[10] 03996 ,IDO_DATA_ICONIMAGEALT 03997 ,(es[11]==NULL)?"":es[11] 03998 ); 03999 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04000 ido_dbuf_strcat(&dbuf,temp_buffer); 04001 04002 free(es[0]); 04003 es[0]=NULL; 04004 04005 /* dump contactgroups */ 04006 for(temp_contactgroupsmember=temp_service->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ 04007 04008 es[0]=ido_escape_buffer(temp_contactgroupsmember->group_name); 04009 04010 snprintf(temp_buffer,sizeof(temp_buffer)-1 04011 ,"%d=%s\n" 04012 ,IDO_DATA_CONTACTGROUP 04013 ,(es[0]==NULL)?"":es[0] 04014 ); 04015 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04016 ido_dbuf_strcat(&dbuf,temp_buffer); 04017 04018 free(es[0]); 04019 es[0]=NULL; 04020 } 04021 04022 /* dump individual contacts */ 04023 for(temp_contactsmember=temp_service->contacts;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next){ 04024 04025 es[0]=ido_escape_buffer(temp_contactsmember->contact_name); 04026 04027 snprintf(temp_buffer,sizeof(temp_buffer)-1 04028 ,"%d=%s\n" 04029 ,IDO_DATA_CONTACT 04030 ,(es[0]==NULL)?"":es[0] 04031 ); 04032 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04033 ido_dbuf_strcat(&dbuf,temp_buffer); 04034 04035 free(es[0]); 04036 es[0]=NULL; 04037 } 04038 04039 /* dump customvars */ 04040 for(temp_customvar=temp_service->custom_variables;temp_customvar!=NULL;temp_customvar=temp_customvar->next){ 04041 04042 es[0]=ido_escape_buffer(temp_customvar->variable_name); 04043 es[1]=ido_escape_buffer(temp_customvar->variable_value); 04044 04045 snprintf(temp_buffer,sizeof(temp_buffer)-1 04046 ,"%d=%s:%d:%s\n" 04047 ,IDO_DATA_CUSTOMVARIABLE 04048 ,(es[0]==NULL)?"":es[0] 04049 ,temp_customvar->has_been_modified 04050 ,(es[1]==NULL)?"":es[1] 04051 ); 04052 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04053 ido_dbuf_strcat(&dbuf,temp_buffer); 04054 04055 for(x=0;x<2;x++){ 04056 free(es[x]); 04057 es[x]=NULL; 04058 } 04059 } 04060 04061 snprintf(temp_buffer,sizeof(temp_buffer)-1 04062 ,"%d\n\n" 04063 ,IDO_API_ENDDATA 04064 ); 04065 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04066 ido_dbuf_strcat(&dbuf,temp_buffer); 04067 04068 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 04069 04070 ido_dbuf_free(&dbuf); 04071 } 04072 04073 04074 /* free buffers */ 04075 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 04076 free(es[x]); 04077 es[x]=NULL; 04078 } 04079 04080 /****** dump servicegroup config ******/ 04081 for(temp_servicegroup=servicegroup_list;temp_servicegroup!=NULL;temp_servicegroup=temp_servicegroup->next){ 04082 04083 es[0]=ido_escape_buffer(temp_servicegroup->group_name); 04084 es[1]=ido_escape_buffer(temp_servicegroup->alias); 04085 04086 snprintf(temp_buffer,sizeof(temp_buffer)-1 04087 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n" 04088 ,IDO_API_SERVICEGROUPDEFINITION 04089 ,IDO_DATA_TIMESTAMP 04090 ,now.tv_sec 04091 ,now.tv_usec 04092 ,IDO_DATA_SERVICEGROUPNAME 04093 ,(es[0]==NULL)?"":es[0] 04094 ,IDO_DATA_SERVICEGROUPALIAS 04095 ,(es[1]==NULL)?"":es[1] 04096 ); 04097 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04098 ido_dbuf_strcat(&dbuf,temp_buffer); 04099 04100 free(es[0]); 04101 free(es[1]); 04102 es[0]=NULL; 04103 es[1]=NULL; 04104 04105 /* dump members for each servicegroup */ 04106 for(temp_servicesmember=temp_servicegroup->members;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next) 04107 { 04108 04109 es[0]=ido_escape_buffer(temp_servicesmember->host_name); 04110 es[1]=ido_escape_buffer(temp_servicesmember->service_description); 04111 04112 snprintf(temp_buffer,sizeof(temp_buffer)-1 04113 ,"%d=%s;%s\n" 04114 ,IDO_DATA_SERVICEGROUPMEMBER 04115 ,(es[0]==NULL)?"":es[0] 04116 ,(es[1]==NULL)?"":es[1] 04117 ); 04118 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04119 ido_dbuf_strcat(&dbuf,temp_buffer); 04120 04121 free(es[0]); 04122 free(es[1]); 04123 es[0]=NULL; 04124 es[1]=NULL; 04125 } 04126 04127 snprintf(temp_buffer,sizeof(temp_buffer)-1 04128 ,"%d\n\n" 04129 ,IDO_API_ENDDATA 04130 ); 04131 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04132 ido_dbuf_strcat(&dbuf,temp_buffer); 04133 04134 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 04135 04136 ido_dbuf_free(&dbuf); 04137 } 04138 04139 04140 /* free buffers */ 04141 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 04142 free(es[x]); 04143 es[x]=NULL; 04144 } 04145 04146 /****** dump host escalation config ******/ 04147 for(temp_hostescalation=hostescalation_list;temp_hostescalation!=NULL;temp_hostescalation=temp_hostescalation->next){ 04148 04149 es[0]=ido_escape_buffer(temp_hostescalation->host_name); 04150 es[1]=ido_escape_buffer(temp_hostescalation->escalation_period); 04151 04152 snprintf(temp_buffer,sizeof(temp_buffer)-1 04153 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%lf\n%d=%d\n%d=%d\n%d=%d\n" 04154 ,IDO_API_HOSTESCALATIONDEFINITION 04155 ,IDO_DATA_TIMESTAMP 04156 ,now.tv_sec 04157 ,now.tv_usec 04158 ,IDO_DATA_HOSTNAME 04159 ,(es[0]==NULL)?"":es[0] 04160 ,IDO_DATA_ESCALATIONPERIOD 04161 ,(es[1]==NULL)?"":es[1] 04162 ,IDO_DATA_FIRSTNOTIFICATION 04163 ,temp_hostescalation->first_notification 04164 ,IDO_DATA_LASTNOTIFICATION 04165 ,temp_hostescalation->last_notification 04166 ,IDO_DATA_NOTIFICATIONINTERVAL 04167 ,(double)temp_hostescalation->notification_interval 04168 ,IDO_DATA_ESCALATEONRECOVERY 04169 ,temp_hostescalation->escalate_on_recovery 04170 ,IDO_DATA_ESCALATEOIDOWN 04171 ,temp_hostescalation->escalate_on_down 04172 ,IDO_DATA_ESCALATEONUNREACHABLE 04173 ,temp_hostescalation->escalate_on_unreachable 04174 ); 04175 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04176 ido_dbuf_strcat(&dbuf,temp_buffer); 04177 04178 free(es[0]); 04179 es[0]=NULL; 04180 04181 /* dump contactgroups */ 04182 for(temp_contactgroupsmember=temp_hostescalation->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ 04183 04184 es[0]=ido_escape_buffer(temp_contactgroupsmember->group_name); 04185 04186 snprintf(temp_buffer,sizeof(temp_buffer)-1 04187 ,"%d=%s\n" 04188 ,IDO_DATA_CONTACTGROUP 04189 ,(es[0]==NULL)?"":es[0] 04190 ); 04191 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04192 ido_dbuf_strcat(&dbuf,temp_buffer); 04193 04194 free(es[0]); 04195 es[0]=NULL; 04196 } 04197 04198 /* dump individual contacts */ 04199 for(temp_contactsmember=temp_hostescalation->contacts;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next){ 04200 04201 es[0]=ido_escape_buffer(temp_contactsmember->contact_name); 04202 04203 snprintf(temp_buffer,sizeof(temp_buffer)-1 04204 ,"%d=%s\n" 04205 ,IDO_DATA_CONTACT 04206 ,(es[0]==NULL)?"":es[0] 04207 ); 04208 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04209 ido_dbuf_strcat(&dbuf,temp_buffer); 04210 04211 free(es[0]); 04212 es[0]=NULL; 04213 } 04214 04215 snprintf(temp_buffer,sizeof(temp_buffer)-1 04216 ,"%d\n\n" 04217 ,IDO_API_ENDDATA 04218 ); 04219 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04220 ido_dbuf_strcat(&dbuf,temp_buffer); 04221 04222 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 04223 04224 ido_dbuf_free(&dbuf); 04225 } 04226 04227 04228 /* free buffers */ 04229 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 04230 free(es[x]); 04231 es[x]=NULL; 04232 } 04233 04234 /****** dump service escalation config ******/ 04235 for(temp_serviceescalation=serviceescalation_list;temp_serviceescalation!=NULL;temp_serviceescalation=temp_serviceescalation->next){ 04236 04237 es[0]=ido_escape_buffer(temp_serviceescalation->host_name); 04238 es[1]=ido_escape_buffer(temp_serviceescalation->description); 04239 es[2]=ido_escape_buffer(temp_serviceescalation->escalation_period); 04240 04241 snprintf(temp_buffer,sizeof(temp_buffer)-1 04242 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n" 04243 ,IDO_API_SERVICEESCALATIONDEFINITION 04244 ,IDO_DATA_TIMESTAMP 04245 ,now.tv_sec 04246 ,now.tv_usec 04247 ,IDO_DATA_HOSTNAME 04248 ,(es[0]==NULL)?"":es[0] 04249 ,IDO_DATA_SERVICEDESCRIPTION 04250 ,(es[1]==NULL)?"":es[1] 04251 ,IDO_DATA_ESCALATIONPERIOD 04252 ,(es[2]==NULL)?"":es[2] 04253 ,IDO_DATA_FIRSTNOTIFICATION 04254 ,temp_serviceescalation->first_notification 04255 ,IDO_DATA_LASTNOTIFICATION 04256 ,temp_serviceescalation->last_notification 04257 ,IDO_DATA_NOTIFICATIONINTERVAL 04258 ,(double)temp_serviceescalation->notification_interval 04259 ,IDO_DATA_ESCALATEONRECOVERY 04260 ,temp_serviceescalation->escalate_on_recovery 04261 ,IDO_DATA_ESCALATEONWARNING 04262 ,temp_serviceescalation->escalate_on_warning 04263 ,IDO_DATA_ESCALATEONUNKNOWN 04264 ,temp_serviceescalation->escalate_on_unknown 04265 ,IDO_DATA_ESCALATEONCRITICAL 04266 ,temp_serviceescalation->escalate_on_critical 04267 ); 04268 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04269 ido_dbuf_strcat(&dbuf,temp_buffer); 04270 04271 free(es[0]); 04272 es[0]=NULL; 04273 04274 /* dump contactgroups */ 04275 for(temp_contactgroupsmember=temp_serviceescalation->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ 04276 04277 es[0]=ido_escape_buffer(temp_contactgroupsmember->group_name); 04278 04279 snprintf(temp_buffer,sizeof(temp_buffer)-1 04280 ,"%d=%s\n" 04281 ,IDO_DATA_CONTACTGROUP 04282 ,(es[0]==NULL)?"":es[0] 04283 ); 04284 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04285 ido_dbuf_strcat(&dbuf,temp_buffer); 04286 04287 free(es[0]); 04288 es[0]=NULL; 04289 } 04290 04291 /* dump individual contacts */ 04292 for(temp_contactsmember=temp_serviceescalation->contacts;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next){ 04293 04294 es[0]=ido_escape_buffer(temp_contactsmember->contact_name); 04295 04296 snprintf(temp_buffer,sizeof(temp_buffer)-1 04297 ,"%d=%s\n" 04298 ,IDO_DATA_CONTACT 04299 ,(es[0]==NULL)?"":es[0] 04300 ); 04301 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04302 ido_dbuf_strcat(&dbuf,temp_buffer); 04303 04304 free(es[0]); 04305 es[0]=NULL; 04306 } 04307 04308 snprintf(temp_buffer,sizeof(temp_buffer)-1 04309 ,"%d\n\n" 04310 ,IDO_API_ENDDATA 04311 ); 04312 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04313 ido_dbuf_strcat(&dbuf,temp_buffer); 04314 04315 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 04316 04317 ido_dbuf_free(&dbuf); 04318 } 04319 04320 04321 /* free buffers */ 04322 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 04323 free(es[x]); 04324 es[x]=NULL; 04325 } 04326 04327 /****** dump host dependency config ******/ 04328 for(temp_hostdependency=hostdependency_list;temp_hostdependency!=NULL;temp_hostdependency=temp_hostdependency->next){ 04329 04330 es[0]=ido_escape_buffer(temp_hostdependency->host_name); 04331 es[1]=ido_escape_buffer(temp_hostdependency->dependent_host_name); 04332 04333 es[2]=ido_escape_buffer(temp_hostdependency->dependency_period); 04334 04335 snprintf(temp_buffer,sizeof(temp_buffer)-1 04336 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n" 04337 ,IDO_API_HOSTDEPENDENCYDEFINITION 04338 ,IDO_DATA_TIMESTAMP 04339 ,now.tv_sec 04340 ,now.tv_usec 04341 ,IDO_DATA_HOSTNAME 04342 ,(es[0]==NULL)?"":es[0] 04343 ,IDO_DATA_DEPENDENTHOSTNAME 04344 ,(es[1]==NULL)?"":es[1] 04345 ,IDO_DATA_DEPENDENCYTYPE 04346 ,temp_hostdependency->dependency_type 04347 ,IDO_DATA_INHERITSPARENT 04348 ,temp_hostdependency->inherits_parent 04349 ,IDO_DATA_DEPENDENCYPERIOD 04350 ,(es[2]==NULL)?"":es[2] 04351 ,IDO_DATA_FAILONUP 04352 ,temp_hostdependency->fail_on_up 04353 ,IDO_DATA_FAILOIDOWN 04354 ,temp_hostdependency->fail_on_down 04355 ,IDO_DATA_FAILONUNREACHABLE 04356 ,temp_hostdependency->fail_on_unreachable 04357 ); 04358 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04359 ido_dbuf_strcat(&dbuf,temp_buffer); 04360 04361 snprintf(temp_buffer,sizeof(temp_buffer)-1 04362 ,"%d\n\n" 04363 ,IDO_API_ENDDATA 04364 ); 04365 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04366 ido_dbuf_strcat(&dbuf,temp_buffer); 04367 04368 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 04369 04370 ido_dbuf_free(&dbuf); 04371 } 04372 04373 04374 /* free buffers */ 04375 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 04376 free(es[x]); 04377 es[x]=NULL; 04378 } 04379 04380 /****** dump service dependency config ******/ 04381 for(temp_servicedependency=servicedependency_list;temp_servicedependency!=NULL;temp_servicedependency=temp_servicedependency->next){ 04382 04383 es[0]=ido_escape_buffer(temp_servicedependency->host_name); 04384 es[1]=ido_escape_buffer(temp_servicedependency->service_description); 04385 es[2]=ido_escape_buffer(temp_servicedependency->dependent_host_name); 04386 es[3]=ido_escape_buffer(temp_servicedependency->dependent_service_description); 04387 04388 es[4]=ido_escape_buffer(temp_servicedependency->dependency_period); 04389 04390 snprintf(temp_buffer,sizeof(temp_buffer)-1 04391 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n" 04392 ,IDO_API_SERVICEDEPENDENCYDEFINITION 04393 ,IDO_DATA_TIMESTAMP 04394 ,now.tv_sec 04395 ,now.tv_usec 04396 ,IDO_DATA_HOSTNAME 04397 ,(es[0]==NULL)?"":es[0] 04398 ,IDO_DATA_SERVICEDESCRIPTION 04399 ,(es[1]==NULL)?"":es[1] 04400 ,IDO_DATA_DEPENDENTHOSTNAME 04401 ,(es[2]==NULL)?"":es[2] 04402 ,IDO_DATA_DEPENDENTSERVICEDESCRIPTION 04403 ,(es[3]==NULL)?"":es[3] 04404 ,IDO_DATA_DEPENDENCYTYPE 04405 ,temp_servicedependency->dependency_type 04406 ,IDO_DATA_INHERITSPARENT 04407 ,temp_servicedependency->inherits_parent 04408 ,IDO_DATA_DEPENDENCYPERIOD 04409 ,(es[4]==NULL)?"":es[4] 04410 ,IDO_DATA_FAILONOK 04411 ,temp_servicedependency->fail_on_ok 04412 ,IDO_DATA_FAILONWARNING 04413 ,temp_servicedependency->fail_on_warning 04414 ,IDO_DATA_FAILONUNKNOWN 04415 ,temp_servicedependency->fail_on_unknown 04416 ,IDO_DATA_FAILONCRITICAL 04417 ,temp_servicedependency->fail_on_critical 04418 ); 04419 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04420 ido_dbuf_strcat(&dbuf,temp_buffer); 04421 04422 snprintf(temp_buffer,sizeof(temp_buffer)-1 04423 ,"%d\n\n" 04424 ,IDO_API_ENDDATA 04425 ); 04426 temp_buffer[sizeof(temp_buffer)-1]='\x0'; 04427 ido_dbuf_strcat(&dbuf,temp_buffer); 04428 04429 idomod_write_to_sink(dbuf.buf,IDO_TRUE,IDO_TRUE); 04430 04431 ido_dbuf_free(&dbuf); 04432 } 04433 04434 04435 /* free buffers */ 04436 for(x=0;x<OBJECTCONFIG_ES_ITEMS;x++){ 04437 free(es[x]); 04438 es[x]=NULL; 04439 } 04440 04441 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_object_config() end\n"); 04442 04443 return IDO_OK; 04444 } 04445 04446 04447 04448 /* dumps config files to data sink */ 04449 int idomod_write_config_files(void){ 04450 int result=IDO_OK; 04451 04452 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_config_files() start\n"); 04453 04454 if((result=idomod_write_main_config_file())==IDO_ERROR) 04455 return IDO_ERROR; 04456 04457 if((result=idomod_write_resource_config_files())==IDO_ERROR) 04458 return IDO_ERROR; 04459 04460 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_config_files() end\n"); 04461 04462 return result; 04463 } 04464 04465 04466 04467 /* dumps main config file data to sink */ 04468 int idomod_write_main_config_file(void){ 04469 char fbuf[IDOMOD_MAX_BUFLEN]; 04470 char *temp_buffer; 04471 struct timeval now; 04472 FILE *fp; 04473 char *var=NULL; 04474 char *val=NULL; 04475 04476 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_main_config_file() start\n"); 04477 04478 /* get current time */ 04479 gettimeofday(&now,NULL); 04480 04481 if(asprintf(&temp_buffer 04482 ,"\n%d:\n%d=%ld.%ld\n%d=%s\n" 04483 ,IDO_API_MAINCONFIGFILEVARIABLES 04484 ,IDO_DATA_TIMESTAMP 04485 ,now.tv_sec 04486 ,now.tv_usec 04487 ,IDO_DATA_CONFIGFILENAME 04488 ,config_file 04489 )==-1) 04490 temp_buffer=NULL; 04491 04492 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 04493 free(temp_buffer); 04494 temp_buffer=NULL; 04495 04496 /* write each var/val pair from config file */ 04497 if((fp=fopen(config_file,"r"))){ 04498 04499 while((fgets(fbuf,sizeof(fbuf),fp))){ 04500 04501 /* skip blank lines */ 04502 if(fbuf[0]=='\x0' || fbuf[0]=='\n' || fbuf[0]=='\r') 04503 continue; 04504 04505 strip(fbuf); 04506 04507 /* skip comments */ 04508 if(fbuf[0]=='#' || fbuf[0]==';') 04509 continue; 04510 04511 if((var=strtok(fbuf,"="))==NULL) 04512 continue; 04513 val=strtok(NULL,"\n"); 04514 04515 if(asprintf(&temp_buffer 04516 ,"%d=%s=%s\n" 04517 ,IDO_DATA_CONFIGFILEVARIABLE 04518 ,var 04519 ,(val==NULL)?"":val 04520 )==-1) 04521 temp_buffer=NULL; 04522 04523 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 04524 free(temp_buffer); 04525 temp_buffer=NULL; 04526 } 04527 04528 fclose(fp); 04529 } 04530 04531 if(asprintf(&temp_buffer 04532 ,"%d\n\n" 04533 ,IDO_API_ENDDATA 04534 )==-1) 04535 temp_buffer=NULL; 04536 04537 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 04538 free(temp_buffer); 04539 temp_buffer=NULL; 04540 04541 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_main_config_file() end\n"); 04542 04543 return IDO_OK; 04544 } 04545 04546 04547 04548 /* dumps all resource config files to sink */ 04549 int idomod_write_resource_config_files(void){ 04550 04551 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_resource_config_files() start\n"); 04552 04553 /* TODO */ 04554 /* loop through main config file to find all resource config files, and then process them */ 04555 /* this should probably NOT be done, as the resource file is supposed to remain private... */ 04556 04557 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_resource_config_files() end\n"); 04558 04559 return IDO_OK; 04560 } 04561 04562 04563 04564 /* dumps a single resource config file to sink */ 04565 int idomod_write_resource_config_file(char *filename){ 04566 04567 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_resource_config_file() start\n"); 04568 04569 /* TODO */ 04570 /* loop through main config file to find all resource config files, and then process them */ 04571 /* this should probably NOT be done, as the resource file is supposed to remain private... */ 04572 04573 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_resource_config_file() end\n"); 04574 04575 return IDO_OK; 04576 } 04577 04578 04579 04580 /* dumps runtime variables to sink */ 04581 int idomod_write_runtime_variables(void){ 04582 char *temp_buffer=NULL; 04583 struct timeval now; 04584 04585 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_runtime_variables() start\n"); 04586 04587 /* get current time */ 04588 gettimeofday(&now,NULL); 04589 04590 if(asprintf(&temp_buffer 04591 ,"\n%d:\n%d=%ld.%ld\n" 04592 ,IDO_API_RUNTIMEVARIABLES 04593 ,IDO_DATA_TIMESTAMP 04594 ,now.tv_sec 04595 ,now.tv_usec 04596 )==-1) 04597 temp_buffer=NULL; 04598 04599 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 04600 free(temp_buffer); 04601 temp_buffer=NULL; 04602 04603 /* write out main config file name */ 04604 if(asprintf(&temp_buffer 04605 ,"%d=%s=%s\n" 04606 ,IDO_DATA_RUNTIMEVARIABLE 04607 ,"config_file" 04608 ,config_file 04609 )==-1) 04610 temp_buffer=NULL; 04611 04612 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 04613 free(temp_buffer); 04614 temp_buffer=NULL; 04615 04616 /* write out vars determined after startup */ 04617 if(asprintf(&temp_buffer 04618 ,"%d=%s=%d\n%d=%s=%d\n%d=%s=%d\n%d=%s=%d\n%d=%s=%lf\n%d=%s=%lf\n%d=%s=%lu\n%d=%s=%lu\n%d=%s=%lf\n%d=%s=%lf\n%d=%s=%lf\n%d=%s=%lf\n%d=%s=%lf\n%d=%s=%lf\n%d=%s=%d\n%d=%s=%d\n%d=%s=%d\n" 04619 ,IDO_DATA_RUNTIMEVARIABLE 04620 ,"total_services" 04621 ,scheduling_info.total_services 04622 ,IDO_DATA_RUNTIMEVARIABLE 04623 ,"total_scheduled_services" 04624 ,scheduling_info.total_scheduled_services 04625 ,IDO_DATA_RUNTIMEVARIABLE 04626 ,"total_hosts" 04627 ,scheduling_info.total_hosts 04628 ,IDO_DATA_RUNTIMEVARIABLE 04629 ,"total_scheduled_hosts" 04630 ,scheduling_info.total_scheduled_hosts 04631 ,IDO_DATA_RUNTIMEVARIABLE 04632 ,"average_services_per_host" 04633 ,scheduling_info.average_services_per_host 04634 ,IDO_DATA_RUNTIMEVARIABLE 04635 ,"average_scheduled_services_per_host" 04636 ,scheduling_info.average_scheduled_services_per_host 04637 ,IDO_DATA_RUNTIMEVARIABLE 04638 ,"service_check_interval_total" 04639 ,scheduling_info.service_check_interval_total 04640 ,IDO_DATA_RUNTIMEVARIABLE 04641 ,"host_check_interval_total" 04642 ,scheduling_info.host_check_interval_total 04643 ,IDO_DATA_RUNTIMEVARIABLE 04644 ,"average_service_check_interval" 04645 ,scheduling_info.average_service_check_interval 04646 ,IDO_DATA_RUNTIMEVARIABLE 04647 ,"average_host_check_interval" 04648 ,scheduling_info.average_host_check_interval 04649 ,IDO_DATA_RUNTIMEVARIABLE 04650 ,"average_service_inter_check_delay" 04651 ,scheduling_info.average_service_inter_check_delay 04652 ,IDO_DATA_RUNTIMEVARIABLE 04653 ,"average_host_inter_check_delay" 04654 ,scheduling_info.average_host_inter_check_delay 04655 ,IDO_DATA_RUNTIMEVARIABLE 04656 ,"service_inter_check_delay" 04657 ,scheduling_info.service_inter_check_delay 04658 ,IDO_DATA_RUNTIMEVARIABLE 04659 ,"host_inter_check_delay" 04660 ,scheduling_info.host_inter_check_delay 04661 ,IDO_DATA_RUNTIMEVARIABLE 04662 ,"service_interleave_factor" 04663 ,scheduling_info.service_interleave_factor 04664 ,IDO_DATA_RUNTIMEVARIABLE 04665 ,"max_service_check_spread" 04666 ,scheduling_info.max_service_check_spread 04667 ,IDO_DATA_RUNTIMEVARIABLE 04668 ,"max_host_check_spread" 04669 ,scheduling_info.max_host_check_spread 04670 )==-1) 04671 temp_buffer=NULL; 04672 04673 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 04674 free(temp_buffer); 04675 temp_buffer=NULL; 04676 04677 if(asprintf(&temp_buffer 04678 ,"%d\n\n" 04679 ,IDO_API_ENDDATA 04680 )==-1) 04681 temp_buffer=NULL; 04682 04683 idomod_write_to_sink(temp_buffer,IDO_TRUE,IDO_TRUE); 04684 free(temp_buffer); 04685 temp_buffer=NULL; 04686 04687 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_write_runtime_variables() end\n"); 04688 04689 return IDO_OK; 04690 } 04691 04692 04693 /****************************************************************************/ 04694 /* LOGGING ROUTINES */ 04695 /****************************************************************************/ 04696 04697 /* opens the debug log for writing */ 04698 int idomod_open_debug_log(void){ 04699 04700 /* don't do anything if we're not debugging */ 04701 if(idomod_debug_level==IDOMOD_DEBUGL_NONE) 04702 return IDO_OK; 04703 04704 if((idomod_debug_file_fp=fopen(idomod_debug_file,"a+"))==NULL) { 04705 syslog(LOG_ERR, "Warning: Could not open debug file '%s' - '%s'", idomod_debug_file, strerror(errno)); 04706 return IDO_ERROR; 04707 } 04708 04709 idomod_log_debug_info(IDOMOD_DEBUGL_PROCESSINFO, 2, "idomod_open_debug_log()\n"); 04710 04711 return IDO_OK; 04712 } 04713 04714 04715 /* closes the debug log */ 04716 int idomod_close_debug_log(void){ 04717 04718 if(idomod_debug_file_fp!=NULL) 04719 fclose(idomod_debug_file_fp); 04720 04721 idomod_debug_file_fp=NULL; 04722 04723 return IDO_OK; 04724 } 04725 04726 04727 /* write to the debug log */ 04728 int idomod_log_debug_info(int level, int verbosity, const char *fmt, ...){ 04729 va_list ap; 04730 char *temp_path=NULL; 04731 struct timeval current_time; 04732 04733 if(!(idomod_debug_level==IDOMOD_DEBUGL_ALL || (level & idomod_debug_level))) 04734 return IDO_OK; 04735 04736 if(verbosity>idomod_debug_verbosity) 04737 return IDO_OK; 04738 04739 if(idomod_debug_file_fp==NULL) 04740 return IDO_ERROR; 04741 04742 /* write the timestamp */ 04743 gettimeofday(¤t_time,NULL); 04744 fprintf(idomod_debug_file_fp,"[%lu.%06lu] [%03d.%d] [pid=%lu] ",current_time.tv_sec,current_time.tv_usec,level,verbosity,(unsigned long)getpid()); 04745 04746 /* write the data */ 04747 va_start(ap,fmt); 04748 vfprintf(idomod_debug_file_fp,fmt,ap); 04749 va_end(ap); 04750 04751 /* flush, so we don't have problems tailing or when fork()ing */ 04752 fflush(idomod_debug_file_fp); 04753 04754 /* if file has grown beyond max, rotate it */ 04755 if((unsigned long)ftell(idomod_debug_file_fp)>idomod_max_debug_file_size && idomod_max_debug_file_size>0L){ 04756 04757 /* close the file */ 04758 idomod_close_debug_log(); 04759 04760 /* rotate the log file */ 04761 if(asprintf(&temp_path,"%s.old",idomod_debug_file)==-1) 04762 temp_path=NULL; 04763 04764 if(temp_path){ 04765 04766 /* unlink the old debug file */ 04767 unlink(temp_path); 04768 04769 /* rotate the debug file */ 04770 my_rename(idomod_debug_file,temp_path); 04771 04772 /* free memory */ 04773 my_free(temp_path); 04774 } 04775 04776 /* open a new file */ 04777 idomod_open_debug_log(); 04778 } 04779 04780 return IDO_OK; 04781 } 04782