Icinga-core 1.4.0
next gen monitoring
base/config.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * CONFIG.C - Configuration input and verification routines for Icinga
00004  *
00005  * Copyright (c) 1999-2008 Ethan Galstad (egalstad@nagios.org)
00006  * Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
00007  * Copyright (c) 2009-2011 Icinga Development Team
00008  *
00009  * License:
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License version 2 as
00013  * published by the Free Software Foundation.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00023  *
00024  *****************************************************************************/
00025 
00026 #include "../include/config.h"
00027 #include "../include/common.h"
00028 #include "../include/objects.h"
00029 #include "../include/macros.h"
00030 #include "../include/icinga.h"
00031 #include "../include/broker.h"
00032 #include "../include/nebmods.h"
00033 #include "../include/nebmodules.h"
00034 
00035 
00036 extern char     *log_file;
00037 extern char     *command_file;
00038 extern char     *temp_file;
00039 extern char     *temp_path;
00040 extern char     *check_result_path;
00041 extern char     *lock_file;
00042 extern char     *log_archive_path;
00043 extern char     *auth_file;
00044 extern char     *p1_file;
00045 
00046 extern char     *nagios_user;
00047 extern char     *nagios_group;
00048 
00049 extern char     *macro_user[MAX_USER_MACROS];
00050 
00051 extern char     *global_host_event_handler;
00052 extern char     *global_service_event_handler;
00053 extern command  *global_host_event_handler_ptr;
00054 extern command  *global_service_event_handler_ptr;
00055 
00056 extern char     *ocsp_command;
00057 extern char     *ochp_command;
00058 extern command  *ocsp_command_ptr;
00059 extern command  *ochp_command_ptr;
00060 
00061 extern char     *illegal_object_chars;
00062 extern char     *illegal_output_chars;
00063 
00064 extern int      use_regexp_matches;
00065 extern int      use_true_regexp_matching;
00066 
00067 extern int      use_daemon_log;
00068 extern int      use_syslog;
00069 extern int      use_syslog_local_facility;
00070 extern int      syslog_local_facility;
00071 extern int      log_notifications;
00072 extern int      log_service_retries;
00073 extern int      log_host_retries;
00074 extern int      log_event_handlers;
00075 extern int      log_external_commands;
00076 extern int      log_external_commands_user;
00077 extern int      log_passive_checks;
00078 extern int      log_long_plugin_output;
00079 
00080 extern int      service_check_timeout;
00081 extern int      service_check_timeout_state;
00082 extern int      host_check_timeout;
00083 extern int      event_handler_timeout;
00084 extern int      notification_timeout;
00085 extern int      ocsp_timeout;
00086 extern int      ochp_timeout;
00087 
00088 extern int      log_initial_states;
00089 extern int      log_current_states;
00090 
00091 extern int      daemon_mode;
00092 extern int      daemon_dumps_core;
00093 
00094 extern int      verify_config;
00095 extern int      verify_object_relationships;
00096 extern int      verify_circular_paths;
00097 extern int      test_scheduling;
00098 extern int      precache_objects;
00099 extern int      use_precached_objects;
00100 
00101 extern double   sleep_time;
00102 extern int      interval_length;
00103 extern int      service_inter_check_delay_method;
00104 extern int      host_inter_check_delay_method;
00105 extern int      service_interleave_factor_method;
00106 extern int      max_host_check_spread;
00107 extern int      max_service_check_spread;
00108 
00109 extern sched_info scheduling_info;
00110 
00111 extern int      max_child_process_time;
00112 
00113 extern int      max_parallel_service_checks;
00114 
00115 extern int      command_check_interval;
00116 extern int      check_reaper_interval;
00117 extern int      max_check_reaper_time;
00118 extern int      service_freshness_check_interval;
00119 extern int      host_freshness_check_interval;
00120 extern int      auto_rescheduling_interval;
00121 extern int      auto_rescheduling_window;
00122 
00123 extern int      check_external_commands;
00124 extern int      check_orphaned_services;
00125 extern int      check_orphaned_hosts;
00126 extern int      check_service_freshness;
00127 extern int      check_host_freshness;
00128 extern int      auto_reschedule_checks;
00129 
00130 extern int      additional_freshness_latency;
00131 
00132 extern int      use_aggressive_host_checking;
00133 extern unsigned long cached_host_check_horizon;
00134 extern unsigned long cached_service_check_horizon;
00135 extern int      enable_predictive_host_dependency_checks;
00136 extern int      enable_predictive_service_dependency_checks;
00137 
00138 extern int      soft_state_dependencies;
00139 
00140 extern int      retain_state_information;
00141 extern int      retention_update_interval;
00142 extern int      use_retained_program_state;
00143 extern int      use_retained_scheduling_info;
00144 extern int      retention_scheduling_horizon;
00145 extern unsigned long retained_host_attribute_mask;
00146 extern unsigned long retained_service_attribute_mask;
00147 extern unsigned long retained_contact_host_attribute_mask;
00148 extern unsigned long retained_contact_service_attribute_mask;
00149 extern unsigned long retained_process_host_attribute_mask;
00150 extern unsigned long retained_process_service_attribute_mask;
00151 
00152 extern int      log_rotation_method;
00153 
00154 extern int      enable_notifications;
00155 extern int      execute_service_checks;
00156 extern int      accept_passive_service_checks;
00157 extern int      execute_host_checks;
00158 extern int      accept_passive_host_checks;
00159 extern int      enable_event_handlers;
00160 extern int      obsess_over_services;
00161 extern int      obsess_over_hosts;
00162 extern int      enable_failure_prediction;
00163 
00164 extern int      translate_passive_host_checks;
00165 extern int      passive_host_checks_are_soft;
00166 
00167 extern int      aggregate_status_updates;
00168 extern int      status_update_interval;
00169 
00170 extern int      time_change_threshold;
00171 
00172 extern unsigned long event_broker_options;
00173 
00174 extern int      process_performance_data;
00175 
00176 extern int      enable_flap_detection;
00177 
00178 extern double   low_service_flap_threshold;
00179 extern double   high_service_flap_threshold;
00180 extern double   low_host_flap_threshold;
00181 extern double   high_host_flap_threshold;
00182 
00183 extern int      use_large_installation_tweaks;
00184 extern int      enable_environment_macros;
00185 extern int      free_child_process_memory;
00186 extern int      child_processes_fork_twice;
00187 
00188 extern int      enable_embedded_perl;
00189 extern int      use_embedded_perl_implicitly;
00190 
00191 extern int      stalking_event_handlers_for_hosts;
00192 extern int      stalking_event_handlers_for_services;
00193 
00194 extern int      date_format;
00195 extern char     *use_timezone;
00196 
00197 extern contact          *contact_list;
00198 extern contactgroup     *contactgroup_list;
00199 extern host             *host_list;
00200 extern hostgroup        *hostgroup_list;
00201 extern service          *service_list;
00202 extern servicegroup     *servicegroup_list;
00203 extern notification     *notification_list;
00204 extern command          *command_list;
00205 extern timeperiod       *timeperiod_list;
00206 extern serviceescalation *serviceescalation_list;
00207 extern servicedependency *servicedependency_list;
00208 extern hostdependency   *hostdependency_list;
00209 extern hostescalation   *hostescalation_list;
00210 extern module           *module_list;
00211 
00212 extern host             **host_hashlist;
00213 extern service          **service_hashlist;
00214 
00215 extern int              external_command_buffer_slots;
00216 
00217 extern unsigned long    max_check_result_file_age;
00218 
00219 extern char             *debug_file;
00220 extern int              debug_level;
00221 extern int              debug_verbosity;
00222 extern unsigned long    max_debug_file_size;
00223 
00224 extern int              allow_empty_hostgroup_assignment;
00225 
00226 /* make sure gcc3 won't hit here */
00227 #ifndef GCCTOOOLD
00228 extern int              event_profiling_enabled;
00229 #endif
00230 
00231 int dummy;      /* reduce compiler warnings */
00232 
00233 /******************************************************************/
00234 /************** CONFIGURATION INPUT FUNCTIONS *********************/
00235 /******************************************************************/
00236 
00237 /* read all configuration data */
00238 int read_all_object_data(char *main_config_file){
00239         int result=OK;
00240         int options=0;
00241         int cache=FALSE;
00242         int precache=FALSE;
00243 
00244         options=READ_ALL_OBJECT_DATA;
00245 
00246         /* cache object definitions if we're up and running */
00247         if(verify_config==FALSE && test_scheduling==FALSE)
00248                 cache=TRUE;
00249 
00250         /* precache object definitions */
00251         if(precache_objects==TRUE && (verify_config==TRUE || test_scheduling==TRUE))
00252                 precache=TRUE;
00253 
00254         /* read in all host configuration data from external sources */
00255         result=read_object_config_data(main_config_file,options,cache,precache);
00256         if(result!=OK)
00257                 return ERROR;
00258 
00259         return OK;
00260         }
00261 
00262 
00263 /* process the main configuration file */
00264 int read_main_config_file(char *main_config_file){
00265         char *input=NULL;
00266         char *variable=NULL;
00267         char *value=NULL;
00268         char *error_message=NULL;
00269         char *temp_ptr=NULL;
00270         mmapfile *thefile=NULL;
00271         int current_line=0;
00272         int error=FALSE;
00273         int command_check_interval_is_seconds=FALSE;
00274         char *modptr=NULL;
00275         char *argptr=NULL;
00276         DIR *tmpdir=NULL;
00277         icinga_macros *mac;
00278 
00279         mac = get_global_macros();
00280 
00281         /* open the config file for reading */
00282         if((thefile=mmap_fopen(main_config_file))==NULL){
00283                 logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Cannot open main configuration file '%s' for reading!",main_config_file);
00284                 return ERROR;
00285                 }
00286 
00287         /* save the main config file macro */
00288         my_free(mac->x[MACRO_MAINCONFIGFILE]);
00289         if((mac->x[MACRO_MAINCONFIGFILE]=(char *)strdup(main_config_file)))
00290                 strip(mac->x[MACRO_MAINCONFIGFILE]);
00291 
00292         /* process all lines in the config file */
00293         while(1){
00294 
00295                 /* free memory */
00296                 my_free(input);
00297                 my_free(variable);
00298                 my_free(value);
00299 
00300                 /* read the next line */
00301                 if((input=mmap_fgets_multiline(thefile))==NULL)
00302                         break;
00303 
00304                 current_line=thefile->current_line;
00305 
00306                 strip(input);
00307 
00308                 /* skip blank lines and comments */
00309                 if(input[0]=='\x0' || input[0]=='#')
00310                         continue;
00311 
00312                 /* get the variable name */
00313                 if((temp_ptr=my_strtok(input,"="))==NULL){
00314                         dummy=asprintf(&error_message,"NULL variable");
00315                         error=TRUE;
00316                         break;
00317                         }
00318                 if((variable=(char *)strdup(temp_ptr))==NULL){
00319                         dummy=asprintf(&error_message,"malloc() error");
00320                         error=TRUE;
00321                         break;
00322                         }
00323 
00324                 /* get the value */
00325                 if((temp_ptr=my_strtok(NULL,"\n"))==NULL){
00326                         dummy=asprintf(&error_message,"NULL value");
00327                         error=TRUE;
00328                         break;
00329                         }
00330                 if((value=(char *)strdup(temp_ptr))==NULL){
00331                         dummy=asprintf(&error_message,"malloc() error");
00332                         error=TRUE;
00333                         break;
00334                         }
00335                 strip(variable);
00336                 strip(value);
00337 
00338                 /* process the variable/value */
00339 
00340                 if(!strcmp(variable,"resource_file")){
00341 
00342                         /* save the macro */
00343                         my_free(mac->x[MACRO_RESOURCEFILE]);
00344                         mac->x[MACRO_RESOURCEFILE]=(char *)strdup(value);
00345 
00346                         /* process the resource file */
00347                         read_resource_file(value);
00348                         }
00349 
00350                 else if(!strcmp(variable,"log_file")){
00351 
00352                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
00353                                 dummy=asprintf(&error_message,"Log file is too long");
00354                                 error=TRUE;
00355                                 break;
00356                                 }
00357 
00358                         my_free(log_file);
00359                         log_file=(char *)strdup(value);
00360 
00361                         /* save the macro */
00362                         my_free(mac->x[MACRO_LOGFILE]);
00363                         mac->x[MACRO_LOGFILE]=(char *)strdup(log_file);
00364                         }
00365 
00366                 else if(!strcmp(variable,"debug_level"))
00367                         debug_level=atoi(value);
00368 
00369                 else if(!strcmp(variable,"debug_verbosity"))
00370                         debug_verbosity=atoi(value);
00371 
00372                 else if(!strcmp(variable,"debug_file")){
00373 
00374                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
00375                                 dummy=asprintf(&error_message,"Debug log file is too long");
00376                                 error=TRUE;
00377                                 break;
00378                                 }
00379 
00380                         my_free(debug_file);
00381                         debug_file=(char *)strdup(value);
00382                         }
00383 
00384                 else if(!strcmp(variable,"max_debug_file_size"))
00385                         max_debug_file_size=strtoul(value,NULL,0);
00386 
00387                 else if(!strcmp(variable,"command_file")){
00388 
00389                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
00390                                 dummy=asprintf(&error_message,"Command file is too long");
00391                                 error=TRUE;
00392                                 break;
00393                                 }
00394 
00395                         my_free(command_file);
00396                         command_file=(char *)strdup(value);
00397 
00398                         /* save the macro */
00399                         my_free(mac->x[MACRO_COMMANDFILE]);
00400                         mac->x[MACRO_COMMANDFILE]=(char *)strdup(value);
00401                         }
00402 
00403                 else if(!strcmp(variable,"temp_file")){
00404 
00405                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
00406                                 dummy=asprintf(&error_message,"Temp file is too long");
00407                                 error=TRUE;
00408                                 break;
00409                                 }
00410 
00411                         my_free(temp_file);
00412                         temp_file=(char *)strdup(value);
00413 
00414                         /* save the macro */
00415                         my_free(mac->x[MACRO_TEMPFILE]);
00416                         mac->x[MACRO_TEMPFILE]=(char *)strdup(temp_file);
00417                         }
00418 
00419                 else if(!strcmp(variable,"temp_path")){
00420 
00421                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
00422                                 dummy=asprintf(&error_message,"Temp path is too long");
00423                                 error=TRUE;
00424                                 break;
00425                                 }
00426 
00427                         if((tmpdir=opendir((char *)value))==NULL){
00428                                 dummy=asprintf(&error_message,"Temp path is not a valid directory");
00429                                 error=TRUE;
00430                                 break;
00431                                 }
00432                         closedir(tmpdir);
00433 
00434                         my_free(temp_path);
00435                         if((temp_path=(char *)strdup(value))){
00436                                 strip(temp_path);
00437                                 /* make sure we don't have a trailing slash */
00438                                 if(temp_path[strlen(temp_path)-1]=='/')
00439                                         temp_path[strlen(temp_path)-1]='\x0';
00440                                 }
00441 
00442                         /* save the macro */
00443                         my_free(mac->x[MACRO_TEMPPATH]);
00444                         mac->x[MACRO_TEMPPATH]=(char *)strdup(temp_path);
00445                         }
00446 
00447                 else if(!strcmp(variable,"check_result_path")){
00448 
00449                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
00450                                 dummy=asprintf(&error_message,"Check result path is too long");
00451                                 error=TRUE;
00452                                 break;
00453                                 }
00454 
00455                         if((tmpdir=opendir((char *)value))==NULL){
00456                                 dummy=asprintf(&error_message,"Check result path is not a valid directory");
00457                                 error=TRUE;
00458                                 break;
00459                                 }
00460                         closedir(tmpdir);
00461 
00462                         my_free(check_result_path);
00463                         if((check_result_path=(char *)strdup(value))){
00464                                 strip(check_result_path);
00465                                 /* make sure we don't have a trailing slash */
00466                                 if(check_result_path[strlen(check_result_path)-1]=='/')
00467                                         check_result_path[strlen(check_result_path)-1]='\x0';
00468                                 }
00469                         }
00470 
00471                 else if(!strcmp(variable,"max_check_result_file_age"))
00472                         max_check_result_file_age=strtoul(value,NULL,0);
00473 
00474                 else if(!strcmp(variable,"lock_file")){
00475 
00476                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
00477                                 dummy=asprintf(&error_message,"Lock file is too long");
00478                                 error=TRUE;
00479                                 break;
00480                                 }
00481 
00482                         my_free(lock_file);
00483                         lock_file=(char *)strdup(value);
00484                         }
00485 
00486                 else if(!strcmp(variable,"global_host_event_handler")){
00487                         my_free(global_host_event_handler);
00488                         global_host_event_handler=(char *)strdup(value);
00489                         }
00490 
00491                 else if(!strcmp(variable,"global_service_event_handler")){
00492                         my_free(global_service_event_handler);
00493                         global_service_event_handler=(char *)strdup(value);
00494                         }
00495 
00496                 else if(!strcmp(variable,"ocsp_command")){
00497                         my_free(ocsp_command);
00498                         ocsp_command=(char *)strdup(value);
00499                         }
00500 
00501                 else if(!strcmp(variable,"ochp_command")){
00502                         my_free(ochp_command);
00503                         ochp_command=(char *)strdup(value);
00504                         }
00505 
00506                 else if(!strcmp(variable, "icinga_user") || !strcmp(variable, "nagios_user")){
00507                         my_free(nagios_user);
00508                         nagios_user = (char *)strdup(value);
00509                         }
00510 
00511                 else if(!strcmp(variable, "icinga_group") || !strcmp(variable, "nagios_group")){
00512                         my_free(nagios_group);
00513                         nagios_group = (char *)strdup(value);
00514                         }
00515 
00516                 else if(!strcmp(variable,"admin_email")){
00517 
00518                         /* save the macro */
00519                         my_free(mac->x[MACRO_ADMINEMAIL]);
00520                         mac->x[MACRO_ADMINEMAIL]=(char *)strdup(value);
00521                         }
00522 
00523                 else if(!strcmp(variable,"admin_pager")){
00524 
00525                         /* save the macro */
00526                         my_free(mac->x[MACRO_ADMINPAGER]);
00527                         mac->x[MACRO_ADMINPAGER]=(char *)strdup(value);
00528                         }
00529 
00530         else if(!strcmp(variable,"use_daemon_log")){
00531 
00532                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00533                                 dummy=asprintf(&error_message,"Illegal value for use_daemon_log");
00534                                 error=TRUE;
00535                                 break;
00536                                 }
00537 
00538                         use_daemon_log=(atoi(value)>0)?TRUE:FALSE;
00539             }
00540 
00541                 else if(!strcmp(variable,"use_syslog")){
00542 
00543                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00544                                 dummy=asprintf(&error_message,"Illegal value for use_syslog");
00545                                 error=TRUE;
00546                                 break;
00547                                 }
00548 
00549                         use_syslog=(atoi(value)>0)?TRUE:FALSE;
00550                         }
00551 
00552                 else if(!strcmp(variable,"use_syslog_local_facility")){
00553 
00554                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00555                                 dummy=asprintf(&error_message,"Illegal value for use_syslog_local_facility");
00556                                 error=TRUE;
00557                                 break;
00558                                 }
00559 
00560                         use_syslog_local_facility=(atoi(value)>0)?TRUE:FALSE;
00561                         }
00562 
00563                 else if(!strcmp(variable,"syslog_local_facility")){
00564 
00565                         if(strlen(value)!=1||value[0]<'0'||value[0]>'7'){
00566                                 dummy=asprintf(&error_message,"Illegal value for syslog_local_facility");
00567                                 error=TRUE;
00568                                 break;
00569                                 }
00570 
00571                         syslog_local_facility=atoi(value);
00572                         }
00573 
00574                 else if(!strcmp(variable,"log_notifications")){
00575 
00576                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00577                                 dummy=asprintf(&error_message,"Illegal value for log_notifications");
00578                                 error=TRUE;
00579                                 break;
00580                                 }
00581 
00582                         log_notifications=(atoi(value)>0)?TRUE:FALSE;
00583                         }
00584 
00585                 else if(!strcmp(variable,"log_service_retries")){
00586 
00587                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00588                                 dummy=asprintf(&error_message,"Illegal value for log_service_retries");
00589                                 error=TRUE;
00590                                 break;
00591                                 }
00592 
00593                         log_service_retries=(atoi(value)>0)?TRUE:FALSE;
00594                         }
00595 
00596                 else if(!strcmp(variable,"log_host_retries")){
00597 
00598                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00599                                 dummy=asprintf(&error_message,"Illegal value for log_host_retries");
00600                                 error=TRUE;
00601                                 break;
00602                                 }
00603 
00604                         log_host_retries=(atoi(value)>0)?TRUE:FALSE;
00605                         }
00606 
00607                 else if(!strcmp(variable,"log_event_handlers")){
00608 
00609                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00610                                 dummy=asprintf(&error_message,"Illegal value for log_event_handlers");
00611                                 error=TRUE;
00612                                 break;
00613                                 }
00614 
00615                         log_event_handlers=(atoi(value)>0)?TRUE:FALSE;
00616                         }
00617 
00618                 else if(!strcmp(variable,"log_external_commands")){
00619 
00620                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00621                                 dummy=asprintf(&error_message,"Illegal value for log_external_commands");
00622                                 error=TRUE;
00623                                 break;
00624                                 }
00625 
00626                         log_external_commands=(atoi(value)>0)?TRUE:FALSE;
00627                         }
00628 
00629                 else if(!strcmp(variable,"log_external_commands_user")){
00630 
00631                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00632                                 dummy=asprintf(&error_message,"Illegal value for log_external_commands_user");
00633                                 error=TRUE;
00634                                 break;
00635                                 }
00636 
00637                         log_external_commands_user=(atoi(value)>0)?TRUE:FALSE;
00638                         }
00639 
00640                 else if(!strcmp(variable,"log_passive_checks")){
00641 
00642                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00643                                 dummy=asprintf(&error_message,"Illegal value for log_passive_checks");
00644                                 error=TRUE;
00645                                 break;
00646                                 }
00647 
00648                         log_passive_checks=(atoi(value)>0)?TRUE:FALSE;
00649                         }
00650 
00651                 else if(!strcmp(variable,"log_long_plugin_output")){
00652 
00653                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00654                                 dummy=asprintf(&error_message,"Illegal value for log_long_plugin_output");
00655                                 error=TRUE;
00656                                 break;
00657                                 }
00658 
00659                         log_long_plugin_output=(atoi(value)>0)?TRUE:FALSE;
00660                         }
00661 
00662                 else if(!strcmp(variable,"log_initial_states")){
00663 
00664                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00665                                 dummy=asprintf(&error_message,"Illegal value for log_initial_states");
00666                                 error=TRUE;
00667                                 break;
00668                                 }
00669 
00670                         log_initial_states=(atoi(value)>0)?TRUE:FALSE;
00671                         }
00672 
00673                 else if(!strcmp(variable,"log_current_states")){
00674 
00675                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00676                                 dummy=asprintf(&error_message,"Illegal value for log_current_states");
00677                                 error=TRUE;
00678                                 break;
00679                                 }
00680 
00681                         log_current_states=(atoi(value)>0)?TRUE:FALSE;
00682                         }
00683 
00684                 else if(!strcmp(variable,"retain_state_information")){
00685 
00686                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00687                                 dummy=asprintf(&error_message,"Illegal value for retain_state_information");
00688                                 error=TRUE;
00689                                 break;
00690                                 }
00691 
00692                         retain_state_information=(atoi(value)>0)?TRUE:FALSE;
00693                         }
00694 
00695                 else if(!strcmp(variable,"retention_update_interval")){
00696 
00697                         retention_update_interval=atoi(value);
00698                         if(retention_update_interval<0){
00699                                 dummy=asprintf(&error_message,"Illegal value for retention_update_interval");
00700                                 error=TRUE;
00701                                 break;
00702                                 }
00703                         }
00704 
00705                 else if(!strcmp(variable,"use_retained_program_state")){
00706 
00707                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00708                                 dummy=asprintf(&error_message,"Illegal value for use_retained_program_state");
00709                                 error=TRUE;
00710                                 break;
00711                                 }
00712 
00713                         use_retained_program_state=(atoi(value)>0)?TRUE:FALSE;
00714                         }
00715 
00716                 else if(!strcmp(variable,"use_retained_scheduling_info")){
00717 
00718                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00719                                 dummy=asprintf(&error_message,"Illegal value for use_retained_scheduling_info");
00720                                 error=TRUE;
00721                                 break;
00722                                 }
00723 
00724                         use_retained_scheduling_info=(atoi(value)>0)?TRUE:FALSE;
00725                         }
00726 
00727                 else if(!strcmp(variable,"retention_scheduling_horizon")){
00728 
00729                         retention_scheduling_horizon=atoi(value);
00730 
00731                         if(retention_scheduling_horizon<=0){
00732                                 dummy=asprintf(&error_message,"Illegal value for retention_scheduling_horizon");
00733                                 error=TRUE;
00734                                 break;
00735                                 }
00736                         }
00737 
00738                 else if(!strcmp(variable,"additional_freshness_latency"))
00739                         additional_freshness_latency=atoi(value);
00740 
00741                 else if(!strcmp(variable,"retained_host_attribute_mask"))
00742                         retained_host_attribute_mask=strtoul(value,NULL,0);
00743 
00744                 else if(!strcmp(variable,"retained_service_attribute_mask"))
00745                         retained_service_attribute_mask=strtoul(value,NULL,0);
00746 
00747                 else if(!strcmp(variable,"retained_process_host_attribute_mask"))
00748                         retained_process_host_attribute_mask=strtoul(value,NULL,0);
00749 
00750                 else if(!strcmp(variable,"retained_process_service_attribute_mask"))
00751                         retained_process_service_attribute_mask=strtoul(value,NULL,0);
00752 
00753                 else if(!strcmp(variable,"retained_contact_host_attribute_mask"))
00754                         retained_contact_host_attribute_mask=strtoul(value,NULL,0);
00755 
00756                 else if(!strcmp(variable,"retained_contact_service_attribute_mask"))
00757                         retained_contact_service_attribute_mask=strtoul(value,NULL,0);
00758 
00759                 else if(!strcmp(variable,"obsess_over_services")){
00760 
00761                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00762                                 dummy=asprintf(&error_message,"Illegal value for obsess_over_services");
00763                                 error=TRUE;
00764                                 break;
00765                                 }
00766 
00767                         obsess_over_services=(atoi(value)>0)?TRUE:FALSE;
00768                         }
00769 
00770                 else if(!strcmp(variable,"obsess_over_hosts")){
00771 
00772                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00773                                 dummy=asprintf(&error_message,"Illegal value for obsess_over_hosts");
00774                                 error=TRUE;
00775                                 break;
00776                                 }
00777 
00778                         obsess_over_hosts=(atoi(value)>0)?TRUE:FALSE;
00779                         }
00780 
00781                 else if(!strcmp(variable,"translate_passive_host_checks")){
00782 
00783                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00784                                 dummy=asprintf(&error_message,"Illegal value for translate_passive_host_checks");
00785                                 error=TRUE;
00786                                 break;
00787                                 }
00788 
00789                         translate_passive_host_checks=(atoi(value)>0)?TRUE:FALSE;
00790                         }
00791 
00792                 else if(!strcmp(variable,"passive_host_checks_are_soft"))
00793                         passive_host_checks_are_soft=(atoi(value)>0)?TRUE:FALSE;
00794 
00795                 else if(!strcmp(variable,"service_check_timeout")){
00796 
00797                         service_check_timeout=atoi(value);
00798 
00799                         if(service_check_timeout<=0){
00800                                 dummy=asprintf(&error_message,"Illegal value for service_check_timeout");
00801                                 error=TRUE;
00802                                 break;
00803                                 }
00804                         }
00805                 
00806                 else if(!strcmp(variable,"service_check_timeout_state")){
00807 
00808                         if(!strcmp(value,"o"))
00809                                 service_check_timeout_state=STATE_OK;
00810                         else if(!strcmp(value,"w"))
00811                                 service_check_timeout_state=STATE_WARNING;
00812                         else if(!strcmp(value,"c"))
00813                                 service_check_timeout_state=STATE_CRITICAL;
00814                         else if(!strcmp(value,"u"))
00815                                 service_check_timeout_state=STATE_UNKNOWN;
00816                         else{
00817                                 dummy=asprintf(&error_message,"Illegal value for service_check_timeout_state");
00818                                 error=TRUE;
00819                                 break;
00820                                 }
00821                         }
00822 
00823                 else if(!strcmp(variable,"host_check_timeout")){
00824 
00825                         host_check_timeout=atoi(value);
00826 
00827                         if(host_check_timeout<=0){
00828                                 dummy=asprintf(&error_message,"Illegal value for host_check_timeout");
00829                                 error=TRUE;
00830                                 break;
00831                                 }
00832                         }
00833 
00834                 else if(!strcmp(variable,"event_handler_timeout")){
00835 
00836                         event_handler_timeout=atoi(value);
00837 
00838                         if(event_handler_timeout<=0){
00839                                 dummy=asprintf(&error_message,"Illegal value for event_handler_timeout");
00840                                 error=TRUE;
00841                                 break;
00842                                 }
00843                         }
00844 
00845                 else if(!strcmp(variable,"notification_timeout")){
00846 
00847                         notification_timeout=atoi(value);
00848 
00849                         if(notification_timeout<=0){
00850                                 dummy=asprintf(&error_message,"Illegal value for notification_timeout");
00851                                 error=TRUE;
00852                                 break;
00853                                 }
00854                         }
00855 
00856                 else if(!strcmp(variable,"ocsp_timeout")){
00857 
00858                         ocsp_timeout=atoi(value);
00859 
00860                         if(ocsp_timeout<=0){
00861                                 dummy=asprintf(&error_message,"Illegal value for ocsp_timeout");
00862                                 error=TRUE;
00863                                 break;
00864                                 }
00865                         }
00866 
00867                 else if(!strcmp(variable,"ochp_timeout")){
00868 
00869                         ochp_timeout=atoi(value);
00870 
00871                         if(ochp_timeout<=0){
00872                                 dummy=asprintf(&error_message,"Illegal value for ochp_timeout");
00873                                 error=TRUE;
00874                                 break;
00875                                 }
00876                         }
00877 
00878                 else if(!strcmp(variable,"use_agressive_host_checking") || !strcmp(variable,"use_aggressive_host_checking")){
00879 
00880                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00881                                 dummy=asprintf(&error_message,"Illegal value for use_aggressive_host_checking");
00882                                 error=TRUE;
00883                                 break;
00884                                 }
00885 
00886                         use_aggressive_host_checking=(atoi(value)>0)?TRUE:FALSE;
00887                         }
00888 
00889                 else if(!strcmp(variable,"cached_host_check_horizon"))
00890                         cached_host_check_horizon=strtoul(value,NULL,0);
00891 
00892                 else if(!strcmp(variable,"enable_predictive_host_dependency_checks"))
00893                         enable_predictive_host_dependency_checks=(atoi(value)>0)?TRUE:FALSE;
00894 
00895                 else if(!strcmp(variable,"cached_service_check_horizon"))
00896                         cached_service_check_horizon=strtoul(value,NULL,0);
00897 
00898                 else if(!strcmp(variable,"enable_predictive_service_dependency_checks"))
00899                         enable_predictive_service_dependency_checks=(atoi(value)>0)?TRUE:FALSE;
00900 
00901                 else if(!strcmp(variable,"soft_state_dependencies")){
00902                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
00903                                 dummy=asprintf(&error_message,"Illegal value for soft_state_dependencies");
00904                                 error=TRUE;
00905                                 break;
00906                                 }
00907 
00908                         soft_state_dependencies=(atoi(value)>0)?TRUE:FALSE;
00909                         }
00910 
00911                 else if(!strcmp(variable,"log_rotation_method")){
00912                         if(!strcmp(value,"n"))
00913                                 log_rotation_method=LOG_ROTATION_NONE;
00914                         else if(!strcmp(value,"h"))
00915                                 log_rotation_method=LOG_ROTATION_HOURLY;
00916                         else if(!strcmp(value,"d"))
00917                                 log_rotation_method=LOG_ROTATION_DAILY;
00918                         else if(!strcmp(value,"w"))
00919                                 log_rotation_method=LOG_ROTATION_WEEKLY;
00920                         else if(!strcmp(value,"m"))
00921                                 log_rotation_method=LOG_ROTATION_MONTHLY;
00922                         else{
00923                                 dummy=asprintf(&error_message,"Illegal value for log_rotation_method");
00924                                 error=TRUE;
00925                                 break;
00926                                 }
00927                         }
00928 
00929                 else if(!strcmp(variable,"log_archive_path")){
00930 
00931                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
00932                                 dummy=asprintf(&error_message,"Log archive path too long");
00933                                 error=TRUE;
00934                                 break;
00935                                 }
00936 
00937                         my_free(log_archive_path);
00938                         log_archive_path=(char *)strdup(value);
00939                         }
00940 
00941                 else if(!strcmp(variable,"enable_event_handlers"))
00942                         enable_event_handlers=(atoi(value)>0)?TRUE:FALSE;
00943 
00944                 else if(!strcmp(variable,"enable_notifications"))
00945                         enable_notifications=(atoi(value)>0)?TRUE:FALSE;
00946 
00947                 else if(!strcmp(variable,"execute_service_checks"))
00948                         execute_service_checks=(atoi(value)>0)?TRUE:FALSE;
00949 
00950                 else if(!strcmp(variable,"accept_passive_service_checks"))
00951                         accept_passive_service_checks=(atoi(value)>0)?TRUE:FALSE;
00952 
00953                 else if(!strcmp(variable,"execute_host_checks"))
00954                         execute_host_checks=(atoi(value)>0)?TRUE:FALSE;
00955 
00956                 else if(!strcmp(variable,"accept_passive_host_checks"))
00957                         accept_passive_host_checks=(atoi(value)>0)?TRUE:FALSE;
00958 
00959                 else if(!strcmp(variable,"service_inter_check_delay_method")){
00960                         if(!strcmp(value,"n"))
00961                                 service_inter_check_delay_method=ICD_NONE;
00962                         else if(!strcmp(value,"d"))
00963                                 service_inter_check_delay_method=ICD_DUMB;
00964                         else if(!strcmp(value,"s"))
00965                                 service_inter_check_delay_method=ICD_SMART;
00966                         else{
00967                                 service_inter_check_delay_method=ICD_USER;
00968                                 scheduling_info.service_inter_check_delay=strtod(value,NULL);
00969                                 if(scheduling_info.service_inter_check_delay<=0.0){
00970                                         dummy=asprintf(&error_message,"Illegal value for service_inter_check_delay_method");
00971                                         error=TRUE;
00972                                         break;
00973                                         }
00974                                 }
00975                         }
00976 
00977                 else if(!strcmp(variable,"max_service_check_spread")){
00978                         strip(value);
00979                         max_service_check_spread=atoi(value);
00980                         if(max_service_check_spread<1){
00981                                 dummy=asprintf(&error_message,"Illegal value for max_service_check_spread");
00982                                 error=TRUE;
00983                                 break;
00984                                 }
00985                         }
00986 
00987                 else if(!strcmp(variable,"host_inter_check_delay_method")){
00988 
00989                         if(!strcmp(value,"n"))
00990                                 host_inter_check_delay_method=ICD_NONE;
00991                         else if(!strcmp(value,"d"))
00992                                 host_inter_check_delay_method=ICD_DUMB;
00993                         else if(!strcmp(value,"s"))
00994                                 host_inter_check_delay_method=ICD_SMART;
00995                         else{
00996                                 host_inter_check_delay_method=ICD_USER;
00997                                 scheduling_info.host_inter_check_delay=strtod(value,NULL);
00998                                 if(scheduling_info.host_inter_check_delay<=0.0){
00999                                         dummy=asprintf(&error_message,"Illegal value for host_inter_check_delay_method");
01000                                         error=TRUE;
01001                                         break;
01002                                         }
01003                                 }
01004                         }
01005 
01006                 else if(!strcmp(variable,"max_host_check_spread")){
01007 
01008                         max_host_check_spread=atoi(value);
01009                         if(max_host_check_spread<1){
01010                                 dummy=asprintf(&error_message,"Illegal value for max_host_check_spread");
01011                                 error=TRUE;
01012                                 break;
01013                                 }
01014                         }
01015 
01016                 else if(!strcmp(variable,"service_interleave_factor")){
01017                         if(!strcmp(value,"s"))
01018                                 service_interleave_factor_method=ILF_SMART;
01019                         else{
01020                                 service_interleave_factor_method=ILF_USER;
01021                                 scheduling_info.service_interleave_factor=atoi(value);
01022                                 if(scheduling_info.service_interleave_factor<1)
01023                                         scheduling_info.service_interleave_factor=1;
01024                                 }
01025                         }
01026 
01027                 else if(!strcmp(variable,"max_concurrent_checks")){
01028 
01029                         max_parallel_service_checks=atoi(value);
01030                         if(max_parallel_service_checks<0){
01031                                 dummy=asprintf(&error_message,"Illegal value for max_concurrent_checks");
01032                                 error=TRUE;
01033                                 break;
01034                                 }
01035                         }
01036 
01037                 else if(!strcmp(variable,"check_result_reaper_frequency") || !strcmp(variable,"service_reaper_frequency")){
01038 
01039                         check_reaper_interval=atoi(value);
01040                         if(check_reaper_interval<1){
01041                                 dummy=asprintf(&error_message,"Illegal value for check_result_reaper_frequency");
01042                                 error=TRUE;
01043                                 break;
01044                                 }
01045                         }
01046 
01047                 else if(!strcmp(variable,"max_check_result_reaper_time")){
01048 
01049                         max_check_reaper_time=atoi(value);
01050                         if(max_check_reaper_time<1){
01051                                 dummy=asprintf(&error_message,"Illegal value for max_check_result_reaper_time");
01052                                 error=TRUE;
01053                                 break;
01054                                 }
01055                         }
01056 
01057                 else if(!strcmp(variable,"sleep_time")){
01058 
01059                         sleep_time=atof(value);
01060                         if(sleep_time<=0.0){
01061                                 dummy=asprintf(&error_message,"Illegal value for sleep_time");
01062                                 error=TRUE;
01063                                 break;
01064                                 }
01065                         }
01066 
01067                 else if(!strcmp(variable,"interval_length")){
01068 
01069                         interval_length=atoi(value);
01070                         if(interval_length<1){
01071                                 dummy=asprintf(&error_message,"Illegal value for interval_length");
01072                                 error=TRUE;
01073                                 break;
01074                                 }
01075                         }
01076 
01077                 else if(!strcmp(variable,"check_external_commands")){
01078 
01079                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01080                                 dummy=asprintf(&error_message,"Illegal value for check_external_commands");
01081                                 error=TRUE;
01082                                 break;
01083                                 }
01084 
01085                         check_external_commands=(atoi(value)>0)?TRUE:FALSE;
01086                         }
01087 
01088                 else if(!strcmp(variable,"command_check_interval")){
01089 
01090                         command_check_interval_is_seconds=(strstr(value,"s"))?TRUE:FALSE;
01091                         command_check_interval=atoi(value);
01092                         if(command_check_interval<-1 || command_check_interval==0){
01093                                 dummy=asprintf(&error_message,"Illegal value for command_check_interval");
01094                                 error=TRUE;
01095                                 break;
01096                                 }
01097                         }
01098 
01099                 else if(!strcmp(variable,"check_for_orphaned_services")){
01100 
01101                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01102                                 dummy=asprintf(&error_message,"Illegal value for check_for_orphaned_services");
01103                                 error=TRUE;
01104                                 break;
01105                                 }
01106 
01107                         check_orphaned_services=(atoi(value)>0)?TRUE:FALSE;
01108                         }
01109 
01110                 else if(!strcmp(variable,"check_for_orphaned_hosts")){
01111 
01112                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01113                                 dummy=asprintf(&error_message,"Illegal value for check_for_orphaned_hosts");
01114                                 error=TRUE;
01115                                 break;
01116                                 }
01117 
01118                         check_orphaned_hosts=(atoi(value)>0)?TRUE:FALSE;
01119                         }
01120 
01121                 else if(!strcmp(variable,"check_service_freshness")){
01122 
01123                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01124                                 dummy=asprintf(&error_message,"Illegal value for check_service_freshness");
01125                                 error=TRUE;
01126                                 break;
01127                                 }
01128 
01129                         check_service_freshness=(atoi(value)>0)?TRUE:FALSE;
01130                         }
01131 
01132                 else if(!strcmp(variable,"check_host_freshness")){
01133 
01134                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01135                                 dummy=asprintf(&error_message,"Illegal value for check_host_freshness");
01136                                 error=TRUE;
01137                                 break;
01138                                 }
01139 
01140                         check_host_freshness=(atoi(value)>0)?TRUE:FALSE;
01141                         }
01142 
01143                 else if(!strcmp(variable,"service_freshness_check_interval") || !strcmp(variable,"freshness_check_interval")){
01144 
01145                         service_freshness_check_interval=atoi(value);
01146                         if(service_freshness_check_interval<=0){
01147                                 dummy=asprintf(&error_message,"Illegal value for service_freshness_check_interval");
01148                                 error=TRUE;
01149                                 break;
01150                                 }
01151                         }
01152 
01153                 else if(!strcmp(variable,"host_freshness_check_interval")){
01154 
01155                         host_freshness_check_interval=atoi(value);
01156                         if(host_freshness_check_interval<=0){
01157                                 dummy=asprintf(&error_message,"Illegal value for host_freshness_check_interval");
01158                                 error=TRUE;
01159                                 break;
01160                                 }
01161                         }
01162                 else if(!strcmp(variable,"auto_reschedule_checks")){
01163 
01164                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01165                                 dummy=asprintf(&error_message,"Illegal value for auto_reschedule_checks");
01166                                 error=TRUE;
01167                                 break;
01168                                 }
01169 
01170                         auto_reschedule_checks=(atoi(value)>0)?TRUE:FALSE;
01171                         }
01172 
01173                 else if(!strcmp(variable,"auto_rescheduling_interval")){
01174 
01175                         auto_rescheduling_interval=atoi(value);
01176                         if(auto_rescheduling_interval<=0){
01177                                 dummy=asprintf(&error_message,"Illegal value for auto_rescheduling_interval");
01178                                 error=TRUE;
01179                                 break;
01180                                 }
01181                         }
01182 
01183                 else if(!strcmp(variable,"auto_rescheduling_window")){
01184 
01185                         auto_rescheduling_window=atoi(value);
01186                         if(auto_rescheduling_window<=0){
01187                                 dummy=asprintf(&error_message,"Illegal value for auto_rescheduling_window");
01188                                 error=TRUE;
01189                                 break;
01190                                 }
01191                         }
01192 
01193                 else if(!strcmp(variable,"aggregate_status_updates")){
01194 
01195                         logit(NSLOG_CONFIG_WARNING,TRUE,"Warning: aggregate_status_updates directive ignored.  All status file updates are now aggregated.");
01196                         }
01197 
01198                 else if(!strcmp(variable,"status_update_interval")){
01199 
01200                         status_update_interval=atoi(value);
01201                         if(status_update_interval<=1){
01202                                 dummy=asprintf(&error_message,"Illegal value for status_update_interval");
01203                                 error=TRUE;
01204                                 break;
01205                                 }
01206                         }
01207 
01208                 else if(!strcmp(variable,"time_change_threshold")){
01209 
01210                         time_change_threshold=atoi(value);
01211 
01212                         if(time_change_threshold<=5){
01213                                 dummy=asprintf(&error_message,"Illegal value for time_change_threshold");
01214                                 error=TRUE;
01215                                 break;
01216                                 }
01217                         }
01218 
01219                 else if(!strcmp(variable,"process_performance_data"))
01220                         process_performance_data=(atoi(value)>0)?TRUE:FALSE;
01221 
01222                 else if(!strcmp(variable,"enable_flap_detection"))
01223                         enable_flap_detection=(atoi(value)>0)?TRUE:FALSE;
01224 
01225                 else if(!strcmp(variable,"enable_failure_prediction"))
01226                         enable_failure_prediction=(atoi(value)>0)?TRUE:FALSE;
01227 
01228                 else if(!strcmp(variable,"low_service_flap_threshold")){
01229 
01230                         low_service_flap_threshold=strtod(value,NULL);
01231                         if(low_service_flap_threshold<=0.0 || low_service_flap_threshold>=100.0){
01232                                 dummy=asprintf(&error_message,"Illegal value for low_service_flap_threshold");
01233                                 error=TRUE;
01234                                 break;
01235                                 }
01236                         }
01237 
01238                 else if(!strcmp(variable,"high_service_flap_threshold")){
01239 
01240                         high_service_flap_threshold=strtod(value,NULL);
01241                         if(high_service_flap_threshold<=0.0 ||  high_service_flap_threshold>100.0){
01242                                 dummy=asprintf(&error_message,"Illegal value for high_service_flap_threshold");
01243                                 error=TRUE;
01244                                 break;
01245                                 }
01246                         }
01247 
01248                 else if(!strcmp(variable,"low_host_flap_threshold")){
01249 
01250                         low_host_flap_threshold=strtod(value,NULL);
01251                         if(low_host_flap_threshold<=0.0 || low_host_flap_threshold>=100.0){
01252                                 dummy=asprintf(&error_message,"Illegal value for low_host_flap_threshold");
01253                                 error=TRUE;
01254                                 break;
01255                                 }
01256                         }
01257 
01258                 else if(!strcmp(variable,"high_host_flap_threshold")){
01259 
01260                         high_host_flap_threshold=strtod(value,NULL);
01261                         if(high_host_flap_threshold<=0.0 || high_host_flap_threshold>100.0){
01262                                 dummy=asprintf(&error_message,"Illegal value for high_host_flap_threshold");
01263                                 error=TRUE;
01264                                 break;
01265                                 }
01266                         }
01267 
01268                 else if(!strcmp(variable,"date_format")){
01269 
01270                         if(!strcmp(value,"euro"))
01271                                 date_format=DATE_FORMAT_EURO;
01272                         else if(!strcmp(value,"iso8601"))
01273                                 date_format=DATE_FORMAT_ISO8601;
01274                         else if(!strcmp(value,"strict-iso8601"))
01275                                 date_format=DATE_FORMAT_STRICT_ISO8601;
01276                         else
01277                                 date_format=DATE_FORMAT_US;
01278                         }
01279 
01280                 else if(!strcmp(variable,"use_timezone")){
01281                         my_free(use_timezone);
01282                         use_timezone=(char *)strdup(value);
01283                         }
01284 
01285                 else if(!strcmp(variable,"p1_file")){
01286 
01287                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
01288                                 dummy=asprintf(&error_message,"P1 file is too long");
01289                                 error=TRUE;
01290                                 break;
01291                                 }
01292 
01293                         my_free(p1_file);
01294                         p1_file=(char *)strdup(value);
01295                         }
01296 
01297                 else if(!strcmp(variable,"event_broker_options")){
01298 
01299                         if(!strcmp(value,"-1"))
01300                                 event_broker_options=BROKER_EVERYTHING;
01301                         else
01302                                 event_broker_options=strtoul(value,NULL,0);
01303                         }
01304 
01305                 else if(!strcmp(variable,"illegal_object_name_chars"))
01306                         illegal_object_chars=(char *)strdup(value);
01307 
01308                 else if(!strcmp(variable,"illegal_macro_output_chars"))
01309                         illegal_output_chars=(char *)strdup(value);
01310 
01311 
01312                 else if(!strcmp(variable,"broker_module")){
01313                         modptr=strtok(value," \n");
01314                         argptr=strtok(NULL,"\n");
01315 #ifdef USE_EVENT_BROKER
01316                         neb_add_module(modptr,argptr,TRUE);
01317 #endif
01318                         }
01319 
01320                 else if(!strcmp(variable,"use_regexp_matching"))
01321                         use_regexp_matches=(atoi(value)>0)?TRUE:FALSE;
01322 
01323                 else if(!strcmp(variable,"use_true_regexp_matching"))
01324                         use_true_regexp_matching=(atoi(value)>0)?TRUE:FALSE;
01325 
01326                 else if(!strcmp(variable,"daemon_dumps_core")){
01327 
01328                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01329                                 dummy=asprintf(&error_message,"Illegal value for daemon_dumps_core");
01330                                 error=TRUE;
01331                                 break;
01332                                 }
01333 
01334                         daemon_dumps_core=(atoi(value)>0)?TRUE:FALSE;
01335                         }
01336 
01337                 else if(!strcmp(variable,"use_large_installation_tweaks")){
01338 
01339                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01340                                 dummy=asprintf(&error_message,"Illegal value for use_large_installation_tweaks ");
01341                                 error=TRUE;
01342                                 break;
01343                                 }
01344 
01345                         use_large_installation_tweaks=(atoi(value)>0)?TRUE:FALSE;
01346                         }
01347 
01348                 else if(!strcmp(variable,"enable_environment_macros"))
01349                         enable_environment_macros=(atoi(value)>0)?TRUE:FALSE;
01350 
01351                 else if(!strcmp(variable,"free_child_process_memory"))
01352                         free_child_process_memory=(atoi(value)>0)?TRUE:FALSE;
01353 
01354                 else if(!strcmp(variable,"child_processes_fork_twice"))
01355                         child_processes_fork_twice=(atoi(value)>0)?TRUE:FALSE;
01356 
01357                 else if(!strcmp(variable,"enable_embedded_perl")){
01358 
01359                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01360                                 dummy=asprintf(&error_message,"Illegal value for enable_embedded_perl");
01361                                 error=TRUE;
01362                                 break;
01363                                 }
01364 
01365                         enable_embedded_perl=(atoi(value)>0)?TRUE:FALSE;
01366                         }
01367 
01368                 else if(!strcmp(variable,"use_embedded_perl_implicitly")){
01369 
01370                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01371                                 dummy=asprintf(&error_message,"Illegal value for use_embedded_perl_implicitly");
01372                                 error=TRUE;
01373                                 break;
01374                                 }
01375 
01376                         use_embedded_perl_implicitly=(atoi(value)>0)?TRUE:FALSE;
01377                         }
01378 
01379                 else if(!strcmp(variable,"stalking_event_handlers_for_hosts")){
01380 
01381                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01382                                 dummy=asprintf(&error_message,"stalking_event_handlers_for_hosts");
01383                                 error=TRUE;
01384                                 break;
01385                                 }
01386 
01387                         stalking_event_handlers_for_hosts=(atoi(value)>0)?TRUE:FALSE;
01388                         }
01389 
01390                 else if(!strcmp(variable,"stalking_event_handlers_for_services")){
01391 
01392                         if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
01393                                 dummy=asprintf(&error_message,"stalking_event_handlers_for_services");
01394                                 error=TRUE;
01395                                 break;
01396                                 }
01397 
01398                         stalking_event_handlers_for_services=(atoi(value)>0)?TRUE:FALSE;
01399                         }
01400 
01401                 else if(!strcmp(variable,"external_command_buffer_slots"))
01402                         external_command_buffer_slots=atoi(value);
01403 
01404                 else if(!strcmp(variable,"check_for_updates")){
01405                         /* ignore it for compatibility reasons */
01406                         logit(NSLOG_CONFIG_WARNING,TRUE,"Warning: check_for_updates variable ignored. Icinga Core does not support program update checking");
01407                         }
01408 
01409                 else if(!strcmp(variable,"bare_update_check")){
01410                         /* ignore it for compatibility reasons */
01411                         logit(NSLOG_CONFIG_WARNING,TRUE,"Warning: bare_update_check variable ignored. Icinga Core does not support program update checking");
01412                         }
01413 
01414                else if(!strcmp(variable,"event_profiling_enabled")){
01415 /* make sure gcc3 won't hit here */
01416 #ifndef GCCTOOOLD
01417                         event_profiling_enabled=(atoi(value)>0)?TRUE:FALSE;
01418 #endif
01419                         }
01420                 else if(!strcmp(variable,"allow_empty_hostgroup_assignment")){
01421                         allow_empty_hostgroup_assignment=(atoi(value)>0)?TRUE:FALSE;
01422                         }
01423 
01424                 /*** AUTH_FILE VARIABLE USED BY EMBEDDED PERL INTERPRETER ***/
01425                 else if(!strcmp(variable,"auth_file")){
01426 
01427                         if(strlen(value)>MAX_FILENAME_LENGTH-1){
01428                                 dummy=asprintf(&error_message,"Auth file is too long");
01429                                 error=TRUE;
01430                                 break;
01431                                 }
01432 
01433                         my_free(auth_file);
01434                         auth_file=(char *)strdup(value);
01435                         }
01436 
01437                 /* warn about old variables */
01438                 else if(!strcmp(variable,"comment_file") || !strcmp(variable,"xcddefault_comment_file")){
01439                         logit(NSLOG_CONFIG_WARNING,TRUE,"Warning: comment_file variable ignored.  Comments are now stored in the status and retention files.");
01440                         }
01441                 else if(!strcmp(variable,"downtime_file") || !strcmp(variable,"xdddefault_downtime_file")){
01442                         logit(NSLOG_CONFIG_WARNING,TRUE,"Warning: downtime_file variable ignored.  Downtime entries are now stored in the status and retention files.");
01443                         }
01444 
01445                 /* skip external data directives */
01446                 else if(strstr(input,"x")==input)
01447                         continue;
01448 
01449                 /* ignore external variables */
01450                 else if(!strcmp(variable,"status_file"))
01451                         continue;
01452                 else if(!strcmp(variable,"perfdata_timeout"))
01453                         continue;
01454                 else if(strstr(variable,"host_perfdata")==variable)
01455                         continue;
01456                 else if(strstr(variable,"service_perfdata")==variable)
01457                         continue;
01458                 else if(strstr(input,"cfg_file=")==input || strstr(input,"cfg_dir=")==input)
01459                         continue;
01460                 else if(strstr(input,"state_retention_file=")==input)
01461                         continue;
01462                 else if(strstr(input,"sync_retention_file=")==input)
01463                         continue;
01464                 else if(strstr(input,"object_cache_file=")==input)
01465                         continue;
01466                 else if(strstr(input,"precached_object_file=")==input)
01467                         continue;
01468 
01469                 /* we don't know what this variable is... */
01470                 else{
01471                         dummy=asprintf(&error_message,"UNKNOWN VARIABLE");
01472                         error=TRUE;
01473                         break;
01474                         }
01475 
01476                 }
01477 
01478         /* adjust timezone values */
01479         if(use_timezone!=NULL)
01480                 set_environment_var("TZ",use_timezone,1);
01481         tzset();
01482 
01483         /* adjust command check interval */
01484         if(command_check_interval_is_seconds==FALSE && command_check_interval!=-1)
01485                 command_check_interval*=interval_length;
01486 
01487         /* adjust tweaks */
01488         if(free_child_process_memory==-1)
01489                 free_child_process_memory=(use_large_installation_tweaks==TRUE)?FALSE:TRUE;
01490         if(child_processes_fork_twice==-1)
01491                 child_processes_fork_twice=(use_large_installation_tweaks==TRUE)?FALSE:TRUE;
01492 
01493 
01494         /* handle errors */
01495         if(error==TRUE){
01496                 logit(NSLOG_CONFIG_ERROR,TRUE,"Error in configuration file '%s' - Line %d (%s)",main_config_file,current_line,(error_message==NULL)?"NULL":error_message);
01497                 return ERROR;
01498                 }
01499 
01500         /* free leftover memory and close the file */
01501         my_free(input);
01502         mmap_fclose(thefile);
01503 
01504         /* free memory */
01505         my_free(error_message);
01506         my_free(input);
01507         my_free(variable);
01508         my_free(value);
01509 
01510         /* make sure a log file has been specified */
01511         strip(log_file);
01512         if(!strcmp(log_file,"")){
01513                 if(daemon_mode==FALSE)
01514                         printf("Error: Log file is not specified anywhere in main config file '%s'!\n",main_config_file);
01515                 return ERROR;
01516                 }
01517 
01518         return OK;
01519         }
01520 
01521 
01522 
01523 /* processes macros in resource file */
01524 int read_resource_file(char *resource_file){
01525         char *input=NULL;
01526         char *variable=NULL;
01527         char *value=NULL;
01528         char *temp_ptr=NULL;
01529         mmapfile *thefile=NULL;
01530         int current_line=1;
01531         int error=FALSE;
01532         int user_index=0;
01533 
01534         if((thefile=mmap_fopen(resource_file))==NULL){
01535                 logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Cannot open resource file '%s' for reading!",resource_file);
01536                 return ERROR;
01537                 }
01538 
01539         /* process all lines in the resource file */
01540         while(1){
01541 
01542                 /* free memory */
01543                 my_free(input);
01544                 my_free(variable);
01545                 my_free(value);
01546 
01547                 /* read the next line */
01548                 if((input=mmap_fgets_multiline(thefile))==NULL)
01549                         break;
01550 
01551                 current_line=thefile->current_line;
01552 
01553                 /* skip blank lines and comments */
01554                 if(input[0]=='#' || input[0]=='\x0' || input[0]=='\n' || input[0]=='\r')
01555                         continue;
01556 
01557                 strip(input);
01558 
01559                 /* get the variable name */
01560                 if((temp_ptr=my_strtok(input,"="))==NULL){
01561                         logit(NSLOG_CONFIG_ERROR,TRUE,"Error: NULL variable - Line %d of resource file '%s'",current_line,resource_file);
01562                         error=TRUE;
01563                         break;
01564                         }
01565                 if((variable=(char *)strdup(temp_ptr))==NULL){
01566                         error=TRUE;
01567                         break;
01568                         }
01569 
01570                 /* get the value */
01571                 if((temp_ptr=my_strtok(NULL,"\n"))==NULL){
01572                         logit(NSLOG_CONFIG_ERROR,TRUE,"Error: NULL variable value - Line %d of resource file '%s'",current_line,resource_file);
01573                         error=TRUE;
01574                         break;
01575                         }
01576                 if((value=(char *)strdup(temp_ptr))==NULL){
01577                         error=TRUE;
01578                         break;
01579                         }
01580 
01581                 /* what should we do with the variable/value pair? */
01582 
01583                 /* check for macro declarations */
01584                 if(variable[0]=='$' && variable[strlen(variable)-1]=='$'){
01585                         
01586                         /* $USERx$ macro declarations */
01587                         if(strstr(variable,"$USER")==variable  && strlen(variable)>5){
01588                                 user_index=atoi(variable+5)-1;
01589                                 if(user_index>=0 && user_index<MAX_USER_MACROS){
01590                                         my_free(macro_user[user_index]);
01591                                         macro_user[user_index]=(char *)strdup(value);
01592                                         }
01593                                 }
01594                         }
01595                 }
01596 
01597         /* free leftover memory and close the file */
01598         my_free(input);
01599         mmap_fclose(thefile);
01600 
01601         /* free memory */
01602         my_free(variable);
01603         my_free(value);
01604 
01605         if(error==TRUE)
01606                 return ERROR;
01607 
01608         return OK;
01609         }
01610 
01611 
01612 
01613 
01614 
01615 
01616 /****************************************************************/
01617 /**************** CONFIG VERIFICATION FUNCTIONS *****************/
01618 /****************************************************************/
01619 
01620 /* do a pre-flight check to make sure object relationships, etc. make sense */
01621 int pre_flight_check(void){
01622         host *temp_host=NULL;
01623         char *buf=NULL;
01624         service *temp_service=NULL;
01625         command *temp_command=NULL;
01626         char *temp_command_name="";
01627         int warnings=0;
01628         int errors=0;
01629         struct timeval tv[4];
01630         double runtime[4];
01631         int temp_path_fd=-1;
01632 
01633 
01634         if(test_scheduling==TRUE)
01635                 gettimeofday(&tv[0],NULL);
01636 
01637         /********************************************/
01638         /* check object relationships               */
01639         /********************************************/
01640         pre_flight_object_check(&warnings,&errors);
01641         if(test_scheduling==TRUE)
01642                 gettimeofday(&tv[1],NULL);
01643 
01644  
01645         /********************************************/
01646         /* check for circular paths between hosts   */
01647         /********************************************/
01648         pre_flight_circular_check(&warnings,&errors);
01649         if(test_scheduling==TRUE)
01650                 gettimeofday(&tv[2],NULL);
01651 
01652  
01653         /********************************************/
01654         /* check global event handler commands...   */
01655         /********************************************/
01656         if(verify_config==TRUE)
01657                 printf("Checking global event handlers...\n");
01658         if(global_host_event_handler!=NULL){
01659 
01660                 /* check the event handler command */
01661                 buf=(char *)strdup(global_host_event_handler);
01662 
01663                 /* get the command name, leave any arguments behind */
01664                 temp_command_name=my_strtok(buf,"!");
01665 
01666                 temp_command=find_command(temp_command_name);
01667                 if(temp_command==NULL){
01668                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Global host event handler command '%s' is not defined anywhere!",temp_command_name);
01669                         errors++;
01670                         }
01671 
01672                 /* save the pointer to the command for later */
01673                 global_host_event_handler_ptr=temp_command;
01674 
01675                 my_free(buf);
01676                 }
01677         if(global_service_event_handler!=NULL){
01678 
01679                 /* check the event handler command */
01680                 buf=(char *)strdup(global_service_event_handler);
01681 
01682                 /* get the command name, leave any arguments behind */
01683                 temp_command_name=my_strtok(buf,"!");
01684 
01685                 temp_command=find_command(temp_command_name);
01686                 if(temp_command==NULL){
01687                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Global service event handler command '%s' is not defined anywhere!",temp_command_name);
01688                         errors++;
01689                         }
01690 
01691                 /* save the pointer to the command for later */
01692                 global_service_event_handler_ptr=temp_command;
01693 
01694                 my_free(buf);
01695                 }
01696 
01697 
01698         /**************************************************/
01699         /* check obsessive processor commands...          */
01700         /**************************************************/
01701         if(verify_config==TRUE)
01702                 printf("Checking obsessive compulsive processor commands...\n");
01703         if(ocsp_command!=NULL){
01704 
01705                 buf=(char *)strdup(ocsp_command);
01706 
01707                 /* get the command name, leave any arguments behind */
01708                 temp_command_name=my_strtok(buf,"!");
01709 
01710                 temp_command=find_command(temp_command_name);
01711                 if(temp_command==NULL){
01712                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Obsessive compulsive service processor command '%s' is not defined anywhere!",temp_command_name);
01713                         errors++;
01714                         }
01715 
01716                 /* save the pointer to the command for later */
01717                 ocsp_command_ptr=temp_command;
01718 
01719                 my_free(buf);
01720                 }
01721         if(ochp_command!=NULL){
01722 
01723                 buf=(char *)strdup(ochp_command);
01724 
01725                 /* get the command name, leave any arguments behind */
01726                 temp_command_name=my_strtok(buf,"!");
01727 
01728                 temp_command=find_command(temp_command_name);
01729                 if(temp_command==NULL){
01730                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Obsessive compulsive host processor command '%s' is not defined anywhere!",temp_command_name);
01731                         errors++;
01732                         }
01733 
01734                 /* save the pointer to the command for later */
01735                 ochp_command_ptr=temp_command;
01736 
01737                 my_free(buf);
01738                 }
01739 
01740 
01741         /**************************************************/
01742         /* check various settings...                      */
01743         /**************************************************/
01744         if(verify_config==TRUE)
01745                 printf("Checking misc settings...\n");
01746 
01747         /* check if we can write to temp_path */
01748         dummy=asprintf(&buf,"%s/nagiosXXXXXX",temp_path);
01749         if((temp_path_fd=mkstemp(buf))==-1){
01750                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"\tError: Unable to write to temp_path ('%s') - %s\n",temp_path,strerror(errno));
01751                 errors++;
01752                 }
01753         else{
01754                 close(temp_path_fd);
01755                 remove(buf);
01756                 }
01757         my_free(buf);
01758 
01759         /* check if we can write to check_result_path */
01760         dummy=asprintf(&buf,"%s/nagiosXXXXXX",check_result_path);
01761         if((temp_path_fd=mkstemp(buf))==-1){
01762                 logit(NSLOG_VERIFICATION_WARNING,TRUE,"\tError: Unable to write to check_result_path ('%s') - %s\n",check_result_path,strerror(errno));
01763                 errors++;
01764                 }
01765         else{
01766                 close(temp_path_fd);
01767                 remove(buf);
01768                 }
01769         my_free(buf);
01770 
01771         /* warn if user didn't specify any illegal macro output chars */
01772         if(illegal_output_chars==NULL){
01773                 logit(NSLOG_VERIFICATION_WARNING,TRUE,"%s","Warning: Nothing specified for illegal_macro_output_chars variable!\n");
01774                 warnings++;
01775                 }
01776 
01777         /* count number of services associated with each host (we need this for flap detection)... */
01778         for(temp_service=service_list;temp_service!=NULL;temp_service=temp_service->next){
01779                 if((temp_host=find_host(temp_service->host_name))){
01780                         temp_host->total_services++;
01781                         temp_host->total_service_check_interval+=temp_service->check_interval;
01782                         }
01783                 }
01784 
01785         if(verify_config==TRUE){
01786                 printf("\n");
01787                 printf("Total Warnings: %d\n",warnings);
01788                 printf("Total Errors:   %d\n",errors);
01789                 }
01790 
01791         if(test_scheduling==TRUE)
01792                 gettimeofday(&tv[3],NULL);
01793 
01794         if(test_scheduling==TRUE){
01795 
01796                 if(verify_object_relationships==TRUE)
01797                         runtime[0]=(double)((double)(tv[1].tv_sec-tv[0].tv_sec)+(double)((tv[1].tv_usec-tv[0].tv_usec)/1000.0)/1000.0);
01798                 else
01799                         runtime[0]=0.0;
01800                 if(verify_circular_paths==TRUE)
01801                         runtime[1]=(double)((double)(tv[2].tv_sec-tv[1].tv_sec)+(double)((tv[2].tv_usec-tv[1].tv_usec)/1000.0)/1000.0);
01802                 else
01803                         runtime[1]=0.0;
01804                 runtime[2]=(double)((double)(tv[3].tv_sec-tv[2].tv_sec)+(double)((tv[3].tv_usec-tv[2].tv_usec)/1000.0)/1000.0);
01805                 runtime[3]=runtime[0]+runtime[1]+runtime[2];
01806 
01807                 printf("Timing information on configuration verification is listed below.\n\n");
01808 
01809                 printf("CONFIG VERIFICATION TIMES          (* = Potential for speedup with -x option)\n");
01810                 printf("----------------------------------\n");
01811                 printf("Object Relationships: %.6lf sec\n",runtime[0]);
01812                 printf("Circular Paths:       %.6lf sec  *\n",runtime[1]);
01813                 printf("Misc:                 %.6lf sec\n",runtime[2]);
01814                 printf("                      ============\n");
01815                 printf("TOTAL:                %.6lf sec  * = %.6lf sec (%.1f%%) estimated savings\n",runtime[3],runtime[1],(runtime[1]/runtime[3])*100.0);
01816                 printf("\n\n");
01817                 }
01818 
01819         return (errors>0)?ERROR:OK;
01820         }
01821 
01822 
01823 
01824 /* do a pre-flight check to make sure object relationships make sense */
01825 int pre_flight_object_check(int *w, int *e){
01826         contact *temp_contact=NULL;
01827         commandsmember *temp_commandsmember=NULL;
01828         contactgroup *temp_contactgroup=NULL;
01829         contactsmember *temp_contactsmember=NULL;
01830         contactgroupsmember *temp_contactgroupsmember=NULL;
01831         host *temp_host=NULL;
01832         host *temp_host2=NULL;
01833         hostsmember *temp_hostsmember=NULL;
01834         hostgroup *temp_hostgroup=NULL;
01835         servicegroup *temp_servicegroup=NULL;
01836         servicesmember *temp_servicesmember=NULL;
01837         service *temp_service=NULL;
01838         service *temp_service2=NULL;
01839         command *temp_command=NULL;
01840         timeperiod *temp_timeperiod=NULL;
01841         timeperiod *temp_timeperiod2=NULL;
01842         timeperiodexclusion *temp_timeperiodexclusion=NULL;
01843         serviceescalation *temp_se=NULL;
01844         hostescalation *temp_he=NULL;
01845         servicedependency *temp_sd=NULL;
01846         hostdependency *temp_hd=NULL;
01847         escalation_condition *temp_escalation_condition=NULL;
01848         module *temp_module=NULL;
01849         char *buf=NULL;
01850         char *temp_command_name="";
01851         int found=FALSE;
01852         int total_objects=0;
01853         int warnings=0;
01854         int errors=0;
01855 
01856 
01857 #ifdef TEST
01858         void *ptr=NULL;
01859         char *buf1="";
01860         char *buf2="";
01861         buf1="temptraxe1";
01862         buf2="Probe 2";
01863         for(temp_se=get_first_serviceescalation_by_service(buf1,buf2,&ptr);temp_se!=NULL;temp_se=get_next_serviceescalation_by_service(buf1,buf2,&ptr)){
01864                 printf("FOUND ESCALATION FOR SVC '%s'/'%s': %d-%d/%.3f, PTR=%p\n",buf1,buf2,temp_se->first_notification,temp_se->last_notification,temp_se->notification_interval,ptr);
01865                 }
01866         for(temp_he=get_first_hostescalation_by_host(buf1,&ptr);temp_he!=NULL;temp_he=get_next_hostescalation_by_host(buf1,&ptr)){
01867                 printf("FOUND ESCALATION FOR HOST '%s': %d-%d/%d, PTR=%p\n",buf1,temp_he->first_notification,temp_he->last_notification,temp_he->notification_interval,ptr);
01868                 }
01869 #endif
01870 
01871         /* bail out if we aren't supposed to verify object relationships */
01872         if(verify_object_relationships==FALSE)
01873                 return OK;
01874 
01875 
01876         /*****************************************/
01877         /* check each service...                 */
01878         /*****************************************/
01879         if(verify_config==TRUE)
01880                 printf("Checking services...\n");
01881         if(get_service_count()==0){
01882                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: There are no services defined!");
01883                 errors++;
01884                 }
01885         total_objects=0;
01886         for(temp_service=service_list;temp_service!=NULL;temp_service=temp_service->next){
01887 
01888                 total_objects++;
01889                 found=FALSE;
01890 
01891                 /* check for a valid host */
01892                 temp_host=find_host(temp_service->host_name);
01893 
01894                 /* we couldn't find an associated host! */
01895                 if(!temp_host){
01896                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host '%s' specified in service '%s' not defined anywhere!",temp_service->host_name,temp_service->description);
01897                         errors++;
01898                         }
01899 
01900                 /* save the host pointer for later */
01901                 temp_service->host_ptr=temp_host;
01902 
01903                 /* add a reverse link from the host to the service for faster lookups later */
01904                 add_service_link_to_host(temp_host,temp_service);
01905 
01906                 /* check the event handler command */
01907                 if(temp_service->event_handler!=NULL){
01908 
01909                         /* check the event handler command */
01910                         buf=(char *)strdup(temp_service->event_handler);
01911 
01912                         /* get the command name, leave any arguments behind */
01913                         temp_command_name=my_strtok(buf,"!");
01914 
01915                         temp_command=find_command(temp_command_name);
01916                         if(temp_command==NULL){
01917                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Event handler command '%s' specified in service '%s' for host '%s' not defined anywhere",temp_command_name,temp_service->description,temp_service->host_name);
01918                                 errors++;
01919                                 }
01920 
01921                         my_free(buf);
01922 
01923                         /* save the pointer to the event handler for later */
01924                         temp_service->event_handler_ptr=temp_command;
01925                         }
01926 
01927                 /* check the service check_command */
01928                 buf=(char *)strdup(temp_service->service_check_command);
01929 
01930                 /* get the command name, leave any arguments behind */
01931                 temp_command_name=my_strtok(buf,"!");
01932 
01933                 temp_command=find_command(temp_command_name);
01934                 if(temp_command==NULL){
01935                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Service check command '%s' specified in service '%s' for host '%s' not defined anywhere!",temp_command_name,temp_service->description,temp_service->host_name);
01936                         errors++;
01937                         }
01938 
01939                 my_free(buf);
01940 
01941                 /* save the pointer to the check command for later */
01942                 temp_service->check_command_ptr=temp_command;
01943 
01944                 /* check for sane recovery options */
01945                 if(temp_service->notify_on_recovery==TRUE && temp_service->notify_on_warning==FALSE && temp_service->notify_on_critical==FALSE){
01946                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Recovery notification option in service '%s' for host '%s' doesn't make any sense - specify warning and/or critical options as well",temp_service->description,temp_service->host_name);
01947                         warnings++;
01948                         }
01949 
01950                 /* reset the found flag */
01951                 found=FALSE;
01952 
01953                 /* check for valid contacts */
01954                 for(temp_contactsmember=temp_service->contacts;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next){
01955 
01956                         temp_contact=find_contact(temp_contactsmember->contact_name);
01957 
01958                         if(temp_contact==NULL){
01959                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact '%s' specified in service '%s' for host '%s' is not defined anywhere!",temp_contactsmember->contact_name,temp_service->description,temp_service->host_name);
01960                                 errors++;
01961                                 }
01962 
01963                         /* save the contact pointer for later */
01964                         temp_contactsmember->contact_ptr=temp_contact;
01965                         }
01966 
01967                 /* check all contact groupss */
01968                 for(temp_contactgroupsmember=temp_service->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){
01969 
01970                         temp_contactgroup=find_contactgroup(temp_contactgroupsmember->group_name);
01971 
01972                         if(temp_contactgroup==NULL){
01973                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact group '%s' specified in service '%s' for host '%s' is not defined anywhere!",temp_contactgroupsmember->group_name,temp_service->description,temp_service->host_name);
01974                                 errors++;
01975                                 }
01976 
01977                         /* save the contact group pointer for later */
01978                         temp_contactgroupsmember->group_ptr=temp_contactgroup;
01979                         }
01980 
01981                 /* check to see if there is at least one contact/group */
01982                 if(temp_service->contacts==NULL && temp_service->contact_groups==NULL){
01983                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Service '%s' on host '%s' has no default contacts or contactgroups defined!",temp_service->description,temp_service->host_name);
01984                         warnings++;
01985                         }
01986 
01987                 /* verify service check timeperiod */
01988                 if(temp_service->check_period==NULL){
01989                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Service '%s' on host '%s' has no check time period defined!",temp_service->description,temp_service->host_name);
01990                         warnings++;
01991                         }
01992                 else{
01993                         temp_timeperiod=find_timeperiod(temp_service->check_period);
01994                         if(temp_timeperiod==NULL){
01995                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Check period '%s' specified for service '%s' on host '%s' is not defined anywhere!",temp_service->check_period,temp_service->description,temp_service->host_name);
01996                                 errors++;
01997                                 }
01998 
01999                         /* save the pointer to the check timeperiod for later */
02000                         temp_service->check_period_ptr=temp_timeperiod;
02001                         }
02002 
02003                 /* check service notification timeperiod */
02004                 if(temp_service->notification_period==NULL){
02005                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Service '%s' on host '%s' has no notification time period defined!",temp_service->description,temp_service->host_name);
02006                         warnings++;
02007                         }
02008 
02009                 else{
02010                         temp_timeperiod=find_timeperiod(temp_service->notification_period);
02011                         if(temp_timeperiod==NULL){
02012                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Notification period '%s' specified for service '%s' on host '%s' is not defined anywhere!",temp_service->notification_period,temp_service->description,temp_service->host_name);
02013                                 errors++;
02014                                 }
02015 
02016                         /* save the pointer to the notification timeperiod for later */
02017                         temp_service->notification_period_ptr=temp_timeperiod;
02018                         }
02019 
02020                 /* see if the notification interval is less than the check interval */
02021                 if(temp_service->notification_interval<temp_service->check_interval && temp_service->notification_interval!=0){
02022                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Service '%s' on host '%s'  has a notification interval less than its check interval!  Notifications are only re-sent after checks are made, so the effective notification interval will be that of the check interval.",temp_service->description,temp_service->host_name);
02023                         warnings++;
02024                         }
02025 
02026                 /* check for illegal characters in service description */
02027                 if(use_precached_objects==FALSE){
02028                         if(contains_illegal_object_chars(temp_service->description)==TRUE){
02029                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The description string for service '%s' on host '%s' contains one or more illegal characters.",temp_service->description,temp_service->host_name);
02030                                 errors++;
02031                                 }
02032                         }
02033                 }
02034 
02035         if(verify_config==TRUE)
02036                 printf("\tChecked %d services.\n",total_objects);
02037 
02038 
02039 
02040         /*****************************************/
02041         /* check all hosts...                    */
02042         /*****************************************/
02043         if(verify_config==TRUE)
02044                 printf("Checking hosts...\n");
02045 
02046         if(get_host_count()==0){
02047                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: There are no hosts defined!");
02048                 errors++;
02049                 }
02050 
02051         total_objects=0;
02052         for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
02053 
02054                 total_objects++;
02055                 found=FALSE;
02056 
02057                 /* make sure each host has at least one service associated with it */
02058                 /* 02/21/08 NOTE: this is extremely inefficient */
02059                 if(use_precached_objects==FALSE && use_large_installation_tweaks==FALSE){
02060 
02061                         for(temp_service=service_list;temp_service!=NULL;temp_service=temp_service->next){
02062                                 if(!strcmp(temp_service->host_name,temp_host->name)){
02063                                         found=TRUE;
02064                                         break;
02065                                         }
02066                                 }
02067 
02068                         /* we couldn't find a service associated with this host! */
02069                         if(found==FALSE){
02070                                 logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Host '%s' has no services associated with it!",temp_host->name);
02071                                 warnings++;
02072                                 }
02073 
02074                         found=FALSE;
02075                         }
02076 
02077                 /* check the event handler command */
02078                 if(temp_host->event_handler!=NULL){
02079 
02080                         /* check the event handler command */
02081                         buf=(char *)strdup(temp_host->event_handler);
02082 
02083                         /* get the command name, leave any arguments behind */
02084                         temp_command_name=my_strtok(buf,"!");
02085 
02086                         temp_command=find_command(temp_command_name);
02087                         if(temp_command==NULL){
02088                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Event handler command '%s' specified for host '%s' not defined anywhere",temp_command_name,temp_host->name);
02089                                 errors++;
02090                                 }
02091 
02092                         my_free(buf);
02093 
02094                         /* save the pointer to the event handler command for later */
02095                         temp_host->event_handler_ptr=temp_command;
02096                         }
02097 
02098                 /* hosts that don't have check commands defined shouldn't ever be checked... */
02099                 if(temp_host->host_check_command!=NULL){
02100 
02101                         /* check the host check_command */
02102                         buf=(char *)strdup(temp_host->host_check_command);
02103 
02104                         /* get the command name, leave any arguments behind */
02105                         temp_command_name=my_strtok(buf,"!");
02106 
02107                         temp_command=find_command(temp_command_name);
02108                         if(temp_command==NULL){
02109                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host check command '%s' specified for host '%s' is not defined anywhere!",temp_command_name,temp_host->name);
02110                                 errors++;
02111                                 }
02112 
02113                         /* save the pointer to the check command for later */
02114                         temp_host->check_command_ptr=temp_command;
02115 
02116                         my_free(buf);
02117                         }
02118 
02119                 /* check host check timeperiod */
02120                 if(temp_host->check_period!=NULL){
02121                         temp_timeperiod=find_timeperiod(temp_host->check_period);
02122                         if(temp_timeperiod==NULL){
02123                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Check period '%s' specified for host '%s' is not defined anywhere!",temp_host->check_period,temp_host->name);
02124                                 errors++;
02125                                 }
02126 
02127                         /* save the pointer to the check timeperiod for later */
02128                         temp_host->check_period_ptr=temp_timeperiod;
02129                         }
02130 
02131                 /* check all contacts */
02132                 for(temp_contactsmember=temp_host->contacts;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next){
02133 
02134                         temp_contact=find_contact(temp_contactsmember->contact_name);
02135 
02136                         if(temp_contact==NULL){
02137                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact '%s' specified in host '%s' is not defined anywhere!",temp_contactsmember->contact_name,temp_host->name);
02138                                 errors++;
02139                                 }
02140 
02141                         /* save the contact pointer for later */
02142                         temp_contactsmember->contact_ptr=temp_contact;
02143                         }
02144 
02145                 /* check all contact groups */
02146                 for(temp_contactgroupsmember=temp_host->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){
02147 
02148                         temp_contactgroup=find_contactgroup(temp_contactgroupsmember->group_name);
02149 
02150                         if(temp_contactgroup==NULL){
02151                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact group '%s' specified in host '%s' is not defined anywhere!",temp_contactgroupsmember->group_name,temp_host->name);
02152                                 errors++;
02153                                 }
02154 
02155                         /* save the contact group pointer for later */
02156                         temp_contactgroupsmember->group_ptr=temp_contactgroup;
02157                         }
02158 
02159                 /* check to see if there is at least one contact/group */
02160                 if(temp_host->contacts==NULL && temp_host->contact_groups==NULL){
02161                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Host '%s' has no default contacts or contactgroups defined!",temp_host->name);
02162                         warnings++;
02163                         }
02164 
02165                 /* check notification timeperiod */
02166                 if(temp_host->notification_period!=NULL){
02167                         temp_timeperiod=find_timeperiod(temp_host->notification_period);
02168                         if(temp_timeperiod==NULL){
02169                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Notification period '%s' specified for host '%s' is not defined anywhere!",temp_host->notification_period,temp_host->name);
02170                                 errors++;
02171                                 }
02172 
02173                         /* save the pointer to the notification timeperiod for later */
02174                         temp_host->notification_period_ptr=temp_timeperiod;
02175                         }
02176 
02177                 /* check all parent parent host */
02178                 for(temp_hostsmember=temp_host->parent_hosts;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){
02179 
02180                         if((temp_host2=find_host(temp_hostsmember->host_name))==NULL){
02181                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: '%s' is not a valid parent for host '%s'!",temp_hostsmember->host_name,temp_host->name);
02182                                 errors++;
02183                                 }
02184 
02185                         /* save the parent host pointer for later */
02186                         temp_hostsmember->host_ptr=temp_host2;
02187 
02188                         /* add a reverse (child) link to make searches faster later on */
02189                         add_child_link_to_host(temp_host2,temp_host);
02190                         }
02191 
02192                 /* check for sane recovery options */
02193                 if(temp_host->notify_on_recovery==TRUE && temp_host->notify_on_down==FALSE && temp_host->notify_on_unreachable==FALSE){
02194                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Recovery notification option in host '%s' definition doesn't make any sense - specify down and/or unreachable options as well",temp_host->name);
02195                         warnings++;
02196                         }
02197 
02198                 /* check for illegal characters in host name */
02199                 if(use_precached_objects==FALSE){
02200                         if(contains_illegal_object_chars(temp_host->name)==TRUE){
02201                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The name of host '%s' contains one or more illegal characters.",temp_host->name);
02202                                 errors++;
02203                                 }
02204                         }
02205                 }
02206 
02207 
02208         if(verify_config==TRUE)
02209                 printf("\tChecked %d hosts.\n",total_objects);
02210 
02211 
02212         /*****************************************/
02213         /* check each host group...              */
02214         /*****************************************/
02215         if(verify_config==TRUE)
02216                 printf("Checking host groups...\n");
02217         for(temp_hostgroup=hostgroup_list,total_objects=0;temp_hostgroup!=NULL;temp_hostgroup=temp_hostgroup->next,total_objects++){
02218 
02219                 /* check all group members */
02220                 for(temp_hostsmember=temp_hostgroup->members;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){
02221 
02222                         temp_host=find_host(temp_hostsmember->host_name);
02223                         if(temp_host==NULL){
02224                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host '%s' specified in host group '%s' is not defined anywhere!",temp_hostsmember->host_name,temp_hostgroup->group_name);
02225                                 errors++;
02226                                 }
02227 
02228                         /* save a pointer to this hostgroup for faster host/group membership lookups later */
02229                         else
02230                                 add_object_to_objectlist(&temp_host->hostgroups_ptr,(void *)temp_hostgroup);
02231 
02232                         /* save host pointer for later */
02233                         temp_hostsmember->host_ptr=temp_host;
02234                         }
02235 
02236                 /* check for illegal characters in hostgroup name */
02237                 if(use_precached_objects==FALSE){
02238                         if(contains_illegal_object_chars(temp_hostgroup->group_name)==TRUE){
02239                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The name of hostgroup '%s' contains one or more illegal characters.",temp_hostgroup->group_name);
02240                                 errors++;
02241                                 }
02242                         }
02243                 }
02244 
02245         if(verify_config==TRUE)
02246                 printf("\tChecked %d host groups.\n",total_objects);
02247 
02248 
02249         /*****************************************/
02250         /* check each service group...           */
02251         /*****************************************/
02252         if(verify_config==TRUE)
02253                 printf("Checking service groups...\n");
02254         for(temp_servicegroup=servicegroup_list,total_objects=0;temp_servicegroup!=NULL;temp_servicegroup=temp_servicegroup->next,total_objects++){
02255 
02256                 /* check all group members */
02257                 for(temp_servicesmember=temp_servicegroup->members;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next){
02258 
02259                         temp_service=find_service(temp_servicesmember->host_name,temp_servicesmember->service_description);
02260                         if(temp_service==NULL){
02261                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Service '%s' on host '%s' specified in service group '%s' is not defined anywhere!",temp_servicesmember->service_description,temp_servicesmember->host_name,temp_servicegroup->group_name);
02262                                 errors++;
02263                                 }
02264 
02265                         /* save a pointer to this servicegroup for faster service/group membership lookups later */
02266                         else
02267                                 add_object_to_objectlist(&temp_service->servicegroups_ptr,(void *)temp_servicegroup);
02268 
02269                         /* save service pointer for later */
02270                         temp_servicesmember->service_ptr=temp_service;
02271                         }
02272 
02273                 /* check for illegal characters in servicegroup name */
02274                 if(use_precached_objects==FALSE){
02275                         if(contains_illegal_object_chars(temp_servicegroup->group_name)==TRUE){
02276                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The name of servicegroup '%s' contains one or more illegal characters.",temp_servicegroup->group_name);
02277                                 errors++;
02278                                 }
02279                         }
02280                 }
02281 
02282         if(verify_config==TRUE)
02283                 printf("\tChecked %d service groups.\n",total_objects);
02284 
02285 
02286 
02287         /*****************************************/
02288         /* check all contacts...                 */
02289         /*****************************************/
02290         if(verify_config==TRUE)
02291                 printf("Checking contacts...\n");
02292         if(contact_list==NULL){
02293                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: There are no contacts defined!");
02294                 errors++;
02295                 }
02296         for(temp_contact=contact_list,total_objects=0;temp_contact!=NULL;temp_contact=temp_contact->next,total_objects++){
02297 
02298                 /* check service notification commands */
02299                 if(temp_contact->service_notification_commands==NULL){
02300                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact '%s' has no service notification commands defined!",temp_contact->name);
02301                         errors++;
02302                         }
02303                 else for(temp_commandsmember=temp_contact->service_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){
02304 
02305                         /* check the host notification command */
02306                         buf=(char *)strdup(temp_commandsmember->command);
02307 
02308                         /* get the command name, leave any arguments behind */
02309                         temp_command_name=my_strtok(buf,"!");
02310 
02311                         temp_command=find_command(temp_command_name);
02312                         if(temp_command==NULL){
02313                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Service notification command '%s' specified for contact '%s' is not defined anywhere!",temp_command_name,temp_contact->name);
02314                                 errors++;
02315                                 }
02316 
02317                         /* save pointer to the command for later */
02318                         temp_commandsmember->command_ptr=temp_command;
02319 
02320                         my_free(buf);
02321                         }
02322 
02323                 /* check host notification commands */
02324                 if(temp_contact->host_notification_commands==NULL){
02325                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact '%s' has no host notification commands defined!",temp_contact->name);
02326                         errors++;
02327                         }
02328                 else for(temp_commandsmember=temp_contact->host_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){
02329 
02330                         /* check the host notification command */
02331                         buf=(char *)strdup(temp_commandsmember->command);
02332 
02333                         /* get the command name, leave any arguments behind */
02334                         temp_command_name=my_strtok(buf,"!");
02335 
02336                         temp_command=find_command(temp_command_name);
02337                         if(temp_command==NULL){
02338                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host notification command '%s' specified for contact '%s' is not defined anywhere!",temp_command_name,temp_contact->name);
02339                                 errors++;
02340                                 }
02341 
02342                         /* save pointer to the command for later */
02343                         temp_commandsmember->command_ptr=temp_command;
02344 
02345                         my_free(buf);
02346                         }
02347 
02348                 /* check service notification timeperiod */
02349                 if(temp_contact->service_notification_period==NULL){
02350                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Contact '%s' has no service notification time period defined!",temp_contact->name);
02351                         warnings++;
02352                         }
02353 
02354                 else{
02355                         temp_timeperiod=find_timeperiod(temp_contact->service_notification_period);
02356                         if(temp_timeperiod==NULL){
02357                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Service notification period '%s' specified for contact '%s' is not defined anywhere!",temp_contact->service_notification_period,temp_contact->name);
02358                                 errors++;
02359                                 }
02360 
02361                         /* save the pointer to the service notification timeperiod for later */
02362                         temp_contact->service_notification_period_ptr=temp_timeperiod;
02363                         }
02364 
02365                 /* check host notification timeperiod */
02366                 if(temp_contact->host_notification_period==NULL){
02367                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Contact '%s' has no host notification time period defined!",temp_contact->name);
02368                         warnings++;
02369                         }
02370 
02371                 else{
02372                         temp_timeperiod=find_timeperiod(temp_contact->host_notification_period);
02373                         if(temp_timeperiod==NULL){
02374                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host notification period '%s' specified for contact '%s' is not defined anywhere!",temp_contact->host_notification_period,temp_contact->name);
02375                                 errors++;
02376                                 }
02377 
02378                         /* save the pointer to the host notification timeperiod for later */
02379                         temp_contact->host_notification_period_ptr=temp_timeperiod;
02380                         }
02381 
02382                 /* check for sane host recovery options */
02383                 if(temp_contact->notify_on_host_recovery==TRUE && temp_contact->notify_on_host_down==FALSE && temp_contact->notify_on_host_unreachable==FALSE){
02384                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Host recovery notification option for contact '%s' doesn't make any sense - specify down and/or unreachable options as well",temp_contact->name);
02385                         warnings++;
02386                         }
02387 
02388                 /* check for sane service recovery options */
02389                 if(temp_contact->notify_on_service_recovery==TRUE && temp_contact->notify_on_service_critical==FALSE && temp_contact->notify_on_service_warning==FALSE){
02390                         logit(NSLOG_VERIFICATION_WARNING,TRUE,"Warning: Service recovery notification option for contact '%s' doesn't make any sense - specify critical and/or warning options as well",temp_contact->name);
02391                         warnings++;
02392                         }
02393 
02394                 /* check for illegal characters in contact name */
02395                 if(use_precached_objects==FALSE){
02396                         if(contains_illegal_object_chars(temp_contact->name)==TRUE){
02397                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The name of contact '%s' contains one or more illegal characters.",temp_contact->name);
02398                                 errors++;
02399                                 }
02400                         }
02401                 }
02402 
02403         if(verify_config==TRUE)
02404                 printf("\tChecked %d contacts.\n",total_objects);
02405 
02406  
02407 
02408         /*****************************************/
02409         /* check each contact group...           */
02410         /*****************************************/
02411         if(verify_config==TRUE)
02412                 printf("Checking contact groups...\n");
02413         for(temp_contactgroup=contactgroup_list,total_objects=0;temp_contactgroup!=NULL;temp_contactgroup=temp_contactgroup->next,total_objects++){
02414 
02415                 found=FALSE;
02416 
02417                 /* check all the group members */
02418                 for(temp_contactsmember=temp_contactgroup->members;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next){
02419 
02420                         temp_contact=find_contact(temp_contactsmember->contact_name);
02421                         if(temp_contact==NULL){
02422                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact '%s' specified in contact group '%s' is not defined anywhere!",temp_contactsmember->contact_name,temp_contactgroup->group_name);
02423                                 errors++;
02424                                 }
02425 
02426                         /* save a pointer to this contactgroup for faster contact/group membership lookups later */
02427                         else
02428                                 add_object_to_objectlist(&temp_contact->contactgroups_ptr,(void *)temp_contactgroup);
02429 
02430                         /* save the contact pointer for later */
02431                         temp_contactsmember->contact_ptr=temp_contact;
02432                         }
02433 
02434                 /* check for illegal characters in contactgroup name */
02435                 if(use_precached_objects==FALSE){
02436                         if(contains_illegal_object_chars(temp_contactgroup->group_name)==TRUE){
02437                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The name of contact group '%s' contains one or more illegal characters.",temp_contactgroup->group_name);
02438                                 errors++;
02439                                 }
02440                         }
02441                 }
02442 
02443         if(verify_config==TRUE)
02444                 printf("\tChecked %d contact groups.\n",total_objects);
02445 
02446 
02447 
02448         /*****************************************/
02449         /* check all service escalations...     */
02450         /*****************************************/
02451         if(verify_config==TRUE)
02452                 printf("Checking service escalations...\n");
02453 
02454         for(temp_se=serviceescalation_list,total_objects=0;temp_se!=NULL;temp_se=temp_se->next,total_objects++){
02455 
02456                 /* find the service */
02457                 temp_service=find_service(temp_se->host_name,temp_se->description);
02458                 if(temp_service==NULL){
02459                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Service '%s' on host '%s' specified in service escalation is not defined anywhere!",temp_se->description,temp_se->host_name);
02460                         errors++;
02461                         }
02462 
02463                 /* save the service pointer for later */
02464                 temp_se->service_ptr=temp_service;
02465 
02466                 /* find the timeperiod */
02467                 if(temp_se->escalation_period!=NULL){
02468                         temp_timeperiod=find_timeperiod(temp_se->escalation_period);
02469                         if(temp_timeperiod==NULL){
02470                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Escalation period '%s' specified in service escalation for service '%s' on host '%s' is not defined anywhere!",temp_se->escalation_period,temp_se->description,temp_se->host_name);
02471                                 errors++;
02472                                 }
02473 
02474                         /* save the timeperiod pointer for later */
02475                         temp_se->escalation_period_ptr=temp_timeperiod;
02476                         }
02477 
02478                 /* find the contacts */
02479                 for(temp_contactsmember=temp_se->contacts;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next){
02480                         
02481                         /* find the contact */
02482                         temp_contact=find_contact(temp_contactsmember->contact_name);
02483                         if(temp_contact==NULL){
02484                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact '%s' specified in service escalation for service '%s' on host '%s' is not defined anywhere!",temp_contactsmember->contact_name,temp_se->description,temp_se->host_name);
02485                                 errors++;
02486                                 }
02487 
02488                         /* save the contact pointer for later */
02489                         temp_contactsmember->contact_ptr=temp_contact;
02490                         }
02491 
02492                 /* check all contact groups */
02493                 for(temp_contactgroupsmember=temp_se->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){
02494 
02495                         temp_contactgroup=find_contactgroup(temp_contactgroupsmember->group_name);
02496 
02497                         if(temp_contactgroup==NULL){
02498                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact group '%s' specified in service escalation for service '%s' on host '%s' is not defined anywhere!",temp_contactgroupsmember->group_name,temp_se->description,temp_se->host_name);
02499                                 errors++;
02500                                 }
02501 
02502                         /* save the contact group pointer for later */
02503                         temp_contactgroupsmember->group_ptr=temp_contactgroup;
02504                         }
02505 
02506                /* check escalation conditions */
02507                for(temp_escalation_condition=temp_se->condition;temp_escalation_condition!=NULL;temp_escalation_condition=temp_escalation_condition->next){
02508                        
02509                        /* find the host */
02510                        temp_host=find_host(temp_escalation_condition->host_name);
02511                        if(temp_host==NULL){
02512                                logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host '%s' specified in service escalation condition is not defined anywhere!",temp_escalation_condition->host_name);
02513                                errors++;
02514                        }
02515                        
02516                        else if(temp_escalation_condition->service_description!=NULL){
02517                                /* find the service */
02518                                temp_service=find_service(temp_escalation_condition->host_name,temp_escalation_condition->service_description);
02519                                if(temp_service==NULL){
02520                                        logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Service '%s' on host '%s' specified in service escalation is not defined anywhere!",temp_escalation_condition->service_description,temp_escalation_condition->host_name);
02521                                        errors++;
02522                                        }
02523                                }
02524                        }
02525 
02526                 }
02527 
02528         if(verify_config==TRUE)
02529                 printf("\tChecked %d service escalations.\n",total_objects);
02530 
02531 
02532 
02533         /*****************************************/
02534         /* check all service dependencies...     */
02535         /*****************************************/
02536         if(verify_config==TRUE)
02537                 printf("Checking service dependencies...\n");
02538 
02539         for(temp_sd=servicedependency_list,total_objects=0;temp_sd!=NULL;temp_sd=temp_sd->next,total_objects++){
02540 
02541                 /* find the dependent service */
02542                 temp_service=find_service(temp_sd->dependent_host_name,temp_sd->dependent_service_description);
02543                 if(temp_service==NULL){
02544                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Dependent service '%s' on host '%s' specified in service dependency for service '%s' on host '%s' is not defined anywhere!",temp_sd->dependent_service_description,temp_sd->dependent_host_name,temp_sd->service_description,temp_sd->host_name);
02545                         errors++;
02546                         }
02547 
02548                 /* save pointer for later */
02549                 temp_sd->dependent_service_ptr=temp_service;
02550 
02551                 /* find the service we're depending on */
02552                 temp_service2=find_service(temp_sd->host_name,temp_sd->service_description);
02553                 if(temp_service2==NULL){
02554                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Service '%s' on host '%s' specified in service dependency for service '%s' on host '%s' is not defined anywhere!",temp_sd->service_description,temp_sd->host_name,temp_sd->dependent_service_description,temp_sd->dependent_host_name);
02555                         errors++;
02556                         }
02557 
02558                 /* save pointer for later */
02559                 temp_sd->master_service_ptr=temp_service2;
02560 
02561                 /* make sure they're not the same service */
02562                 if(temp_service==temp_service2){
02563                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Service dependency definition for service '%s' on host '%s' is circular (it depends on itself)!",temp_sd->dependent_service_description,temp_sd->dependent_host_name);
02564                         errors++;
02565                         }
02566 
02567                 /* find the timeperiod */
02568                 if(temp_sd->dependency_period!=NULL){
02569                         temp_timeperiod=find_timeperiod(temp_sd->dependency_period);
02570                         if(temp_timeperiod==NULL){
02571                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Dependency period '%s' specified in service dependency for service '%s' on host '%s' is not defined anywhere!",temp_sd->dependency_period,temp_sd->dependent_service_description,temp_sd->dependent_host_name);
02572                                 errors++;
02573                                 }
02574 
02575                         /* save the timeperiod pointer for later */
02576                         temp_sd->dependency_period_ptr=temp_timeperiod;
02577                         }
02578                 }
02579 
02580         if(verify_config==TRUE)
02581                 printf("\tChecked %d service dependencies.\n",total_objects);
02582 
02583 
02584 
02585         /*****************************************/
02586         /* check all host escalations...     */
02587         /*****************************************/
02588         if(verify_config==TRUE)
02589                 printf("Checking host escalations...\n");
02590 
02591         for(temp_he=hostescalation_list,total_objects=0;temp_he!=NULL;temp_he=temp_he->next,total_objects++){
02592 
02593                 /* find the host */
02594                 temp_host=find_host(temp_he->host_name);
02595                 if(temp_host==NULL){
02596                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host '%s' specified in host escalation is not defined anywhere!",temp_he->host_name);
02597                         errors++;
02598                         }
02599 
02600                 /* save the host pointer for later */
02601                 temp_he->host_ptr=temp_host;
02602 
02603                 /* find the timeperiod */
02604                 if(temp_he->escalation_period!=NULL){
02605                         temp_timeperiod=find_timeperiod(temp_he->escalation_period);
02606                         if(temp_timeperiod==NULL){
02607                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Escalation period '%s' specified in host escalation for host '%s' is not defined anywhere!",temp_he->escalation_period,temp_he->host_name);
02608                                 errors++;
02609                                 }
02610 
02611                         /* save the timeperiod pointer for later */
02612                         temp_he->escalation_period_ptr=temp_timeperiod;
02613                         }
02614 
02615                 /* find the contacts */
02616                 for(temp_contactsmember=temp_he->contacts;temp_contactsmember!=NULL;temp_contactsmember=temp_contactsmember->next){
02617                         
02618                         /* find the contact*/
02619                         temp_contact=find_contact(temp_contactsmember->contact_name);
02620                         if(temp_contact==NULL){
02621                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact '%s' specified in host escalation for host '%s' is not defined anywhere!",temp_contactsmember->contact_name,temp_he->host_name);
02622                                 errors++;
02623                                 }
02624 
02625                         /* save the contact pointer for later */
02626                         temp_contactsmember->contact_ptr=temp_contact;
02627                         }
02628 
02629                 /* check all contact groups */
02630                 for(temp_contactgroupsmember=temp_he->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){
02631 
02632                         temp_contactgroup=find_contactgroup(temp_contactgroupsmember->group_name);
02633 
02634                         if(temp_contactgroup==NULL){
02635                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Contact group '%s' specified in host escalation for host '%s' is not defined anywhere!",temp_contactgroupsmember->group_name,temp_he->host_name);
02636                                 errors++;
02637                                 }
02638 
02639                         /* save the contact group pointer for later */
02640                         temp_contactgroupsmember->group_ptr=temp_contactgroup;
02641                         }
02642                
02643                /* check escalation conditions */
02644                for(temp_escalation_condition=temp_he->condition;temp_escalation_condition!=NULL;temp_escalation_condition=temp_escalation_condition->next){
02645                        
02646                        /* find the host */
02647                        temp_host=find_host(temp_escalation_condition->host_name);
02648                        if(temp_host==NULL){
02649                                logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host '%s' specified in service escalation condition is not defined anywhere!",temp_escalation_condition->host_name);
02650                                errors++;
02651                        }
02652                        
02653                        else if(temp_escalation_condition->service_description!=NULL){
02654                                /* find the service */
02655                                temp_service=find_service(temp_escalation_condition->host_name,temp_escalation_condition->service_description);
02656                                if(temp_service==NULL){
02657                                        logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Service '%s' on host '%s' specified in service escalation is not defined anywhere!",temp_escalation_condition->service_description,temp_escalation_condition->host_name);
02658                                        errors++;
02659                                        }
02660                                }
02661                        }
02662 
02663                 }
02664 
02665         if(verify_config==TRUE)
02666                 printf("\tChecked %d host escalations.\n",total_objects);
02667 
02668 
02669 
02670         /*****************************************/
02671         /* check all host dependencies...     */
02672         /*****************************************/
02673         if(verify_config==TRUE)
02674                 printf("Checking host dependencies...\n");
02675 
02676         for(temp_hd=hostdependency_list,total_objects=0;temp_hd!=NULL;temp_hd=temp_hd->next,total_objects++){
02677 
02678                 /* find the dependent host */
02679                 temp_host=find_host(temp_hd->dependent_host_name);
02680                 if(temp_host==NULL){
02681                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Dependent host specified in host dependency for host '%s' is not defined anywhere!",temp_hd->dependent_host_name);
02682                         errors++;
02683                         }
02684 
02685                 /* save pointer for later */
02686                 temp_hd->dependent_host_ptr=temp_host;
02687 
02688                 /* find the host we're depending on */
02689                 temp_host2=find_host(temp_hd->host_name);
02690                 if(temp_host2==NULL){
02691                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host specified in host dependency for host '%s' is not defined anywhere!",temp_hd->dependent_host_name);
02692                         errors++;
02693                         }
02694 
02695                 /* save pointer for later */
02696                 temp_hd->master_host_ptr=temp_host2;
02697 
02698                 /* make sure they're not the same host */
02699                 if(temp_host==temp_host2){
02700                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Host dependency definition for host '%s' is circular (it depends on itself)!",temp_hd->dependent_host_name);
02701                         errors++;
02702                         }
02703 
02704                 /* find the timeperiod */
02705                 if(temp_hd->dependency_period!=NULL){
02706                         temp_timeperiod=find_timeperiod(temp_hd->dependency_period);
02707                         if(temp_timeperiod==NULL){
02708                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Dependency period '%s' specified in host dependency for host '%s' is not defined anywhere!",temp_hd->dependency_period,temp_hd->dependent_host_name);
02709                                 errors++;
02710                                 }
02711 
02712                         /* save the timeperiod pointer for later */
02713                         temp_hd->dependency_period_ptr=temp_timeperiod;
02714                         }
02715                 }
02716 
02717         if(verify_config==TRUE)
02718                 printf("\tChecked %d host dependencies.\n",total_objects);
02719 
02720 
02721 
02722         /*****************************************/
02723         /* check all commands...                 */
02724         /*****************************************/
02725         if(verify_config==TRUE)
02726                 printf("Checking commands...\n");
02727 
02728         for(temp_command=command_list,total_objects=0;temp_command!=NULL;temp_command=temp_command->next,total_objects++){
02729 
02730                 /* check for illegal characters in command name */
02731                 if(use_precached_objects==FALSE){
02732                         if(contains_illegal_object_chars(temp_command->name)==TRUE){
02733                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The name of command '%s' contains one or more illegal characters.",temp_command->name);
02734                                 errors++;
02735                                 }
02736                         }
02737                 }
02738 
02739         if(verify_config==TRUE)
02740                 printf("\tChecked %d commands.\n",total_objects);
02741 
02742 
02743 
02744         /*****************************************/
02745         /* check all timeperiods...              */
02746         /*****************************************/
02747         if(verify_config==TRUE)
02748                 printf("Checking time periods...\n");
02749 
02750         for(temp_timeperiod=timeperiod_list,total_objects=0;temp_timeperiod!=NULL;temp_timeperiod=temp_timeperiod->next,total_objects++){
02751 
02752                 /* check for illegal characters in timeperiod name */
02753                 if(use_precached_objects==FALSE){
02754                         if(contains_illegal_object_chars(temp_timeperiod->name)==TRUE){
02755                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The name of time period '%s' contains one or more illegal characters.",temp_timeperiod->name);
02756                                 errors++;
02757                                 }
02758                         }
02759 
02760                 /* check for valid timeperiod names in exclusion list */
02761                 for(temp_timeperiodexclusion=temp_timeperiod->exclusions;temp_timeperiodexclusion!=NULL;temp_timeperiodexclusion=temp_timeperiodexclusion->next){
02762 
02763                         temp_timeperiod2=find_timeperiod(temp_timeperiodexclusion->timeperiod_name);
02764                         if(temp_timeperiod2==NULL){
02765                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: Excluded time period '%s' specified in timeperiod '%s' is not defined anywhere!",temp_timeperiodexclusion->timeperiod_name,temp_timeperiod->name);
02766                                 errors++;
02767                                 }
02768 
02769                         /* save the timeperiod pointer for later */
02770                         temp_timeperiodexclusion->timeperiod_ptr=temp_timeperiod2;
02771                         }
02772                 }
02773 
02774         if(verify_config==TRUE)
02775                 printf("\tChecked %d time periods.\n",total_objects);
02776 
02777 
02778         /*****************************************/
02779         /* check all modules...                  */
02780         /*****************************************/
02781         if(verify_config==TRUE)
02782                 printf("Checking modules...\n");
02783 
02784         for(temp_module=module_list,total_objects=0;temp_module!=NULL;temp_module=temp_module->next,total_objects++){
02785 
02786                 /* check for illegal characters in module name */
02787                 if(use_precached_objects==FALSE){
02788                         if(contains_illegal_object_chars(temp_module->name)==TRUE){
02789                                 logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The name of module '%s' contains one or more illegal characters.",temp_module->name);
02790                                 errors++;
02791                                 }
02792                         }
02793                 }
02794 
02795         if(verify_config==TRUE)
02796                 printf("\tChecked %d modules.\n",total_objects);
02797 
02798 
02799        /* update warning and error count */
02800         *w+=warnings;
02801         *e+=errors;
02802  
02803         return (errors>0)?ERROR:OK;
02804         }
02805 
02806 
02807 /* dfs status values */
02808 #define DFS_UNCHECKED                    0  /* default value */
02809 #define DFS_TEMP_CHECKED                 1  /* check just one time */
02810 #define DFS_OK                           2  /* no problem */
02811 #define DFS_NEAR_LOOP                    3  /* has trouble sons */
02812 #define DFS_LOOPY                        4  /* is a part of a loop */
02813 
02814 #define dfs_get_status(h) h->circular_path_checked
02815 #define dfs_unset_status(h) h->circular_path_checked = 0
02816 #define dfs_set_status(h, flag) h->circular_path_checked = (flag)
02817 #define dfs_host_status(h) (h ? dfs_get_status(h) : DFS_OK)
02818 
02823 static int dfs_host_path(host *root)
02824 {
02825         hostsmember *child = NULL;
02826 
02827         if (!root)
02828                 return DFS_NEAR_LOOP;
02829 
02830         if (dfs_get_status(root) != DFS_UNCHECKED)
02831                 return dfs_get_status(root);
02832 
02833         /* Mark the root temporary checked */
02834         dfs_set_status(root, DFS_TEMP_CHECKED);
02835 
02836         /* We are scanning the children */
02837         for (child = root->child_hosts; child!=NULL; child=child->next){
02838                 int child_status = dfs_get_status(child->host_ptr);
02839 
02840                 /* If a child is not checked, check it */
02841                 if (child_status == DFS_UNCHECKED)
02842                         child_status = dfs_host_path(child->host_ptr);
02843 
02844                 /* If a child already temporary checked, its a problem,
02845                  * loop inside, and its a acked status */
02846                 if (child_status == DFS_TEMP_CHECKED) {
02847                         dfs_set_status(child->host_ptr, DFS_LOOPY);
02848                         dfs_set_status(root, DFS_LOOPY);
02849                 }
02850 
02851                 /* If a child already temporary checked, its a problem, loop inside */
02852                 if (child_status == DFS_NEAR_LOOP || child_status == DFS_LOOPY) {
02853                         /* if a node is know to be part of a loop, do not let it be less */
02854                         if (dfs_get_status(root) != DFS_LOOPY)
02855                                 dfs_set_status(root, DFS_NEAR_LOOP);
02856 
02857                         /* we already saw this child, it's a problem */
02858                         dfs_set_status(child->host_ptr, DFS_LOOPY);
02859                 }
02860         }
02861 
02862         /*
02863          * If root have been modified, do not set it OK
02864          * A node is OK if and only if all of his children are OK
02865          * If it does not have child, goes ok
02866          */
02867         if(dfs_get_status(root) == DFS_TEMP_CHECKED)
02868                 dfs_set_status(root, DFS_OK);
02869         return dfs_get_status(root);
02870 }
02871 
02872 
02873 /* check for circular paths and dependencies */
02874 int pre_flight_circular_check(int *w, int *e){
02875         host *temp_host=NULL;
02876         servicedependency *temp_sd=NULL;
02877         servicedependency *temp_sd2=NULL;
02878         hostdependency *temp_hd=NULL;
02879         hostdependency *temp_hd2=NULL;
02880         int found=FALSE;
02881         int result=OK;
02882         int warnings=0;
02883         int errors=0;
02884 
02885 
02886         /* bail out if we aren't supposed to verify circular paths */
02887         if(verify_circular_paths==FALSE)
02888                 return OK;
02889 
02890 
02891         /********************************************/
02892         /* check for circular paths between hosts   */
02893         /********************************************/
02894         if(verify_config==TRUE)
02895                 printf("Checking for circular paths between hosts...\n");
02896 
02897         /* check routes between all hosts */
02898         found=FALSE;
02899         result=OK;
02900 
02901 
02902         /* We clean the dsf status from previous check */
02903         for (temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
02904                 dfs_set_status(temp_host, DFS_UNCHECKED);
02905         }
02906 
02907         for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
02908                 if (dfs_host_path(temp_host) == DFS_LOOPY)
02909                         errors = 1;
02910         }
02911 
02912         for (temp_host = host_list; temp_host != NULL; temp_host = temp_host->next){
02913                 if (dfs_get_status(temp_host) == DFS_LOOPY)
02914                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: The host '%s' is part of a circular parent/child chain!", temp_host->name);
02915                 /* clean DFS status */
02916                 dfs_set_status(temp_host, DFS_UNCHECKED);
02917         }
02918 
02919 
02920         /********************************************/
02921         /* check for circular dependencies         */
02922         /********************************************/
02923         if(verify_config==TRUE)
02924                 printf("Checking for circular host and service dependencies...\n");
02925 
02926         /* check execution dependencies between all services */
02927         for(temp_sd=servicedependency_list;temp_sd!=NULL;temp_sd=temp_sd->next){
02928 
02929                 /* clear checked flag for all dependencies */
02930                 for(temp_sd2=servicedependency_list;temp_sd2!=NULL;temp_sd2=temp_sd2->next)
02931                         temp_sd2->circular_path_checked=FALSE;
02932 
02933                 found=check_for_circular_servicedependency_path(temp_sd,temp_sd,EXECUTION_DEPENDENCY);
02934                 if(found==TRUE){
02935                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: A circular execution dependency (which could result in a deadlock) exists for service '%s' on host '%s'!",temp_sd->service_description,temp_sd->host_name);
02936                         errors++;
02937                         }
02938                 }
02939 
02940         /* check notification dependencies between all services */
02941         for(temp_sd=servicedependency_list;temp_sd!=NULL;temp_sd=temp_sd->next){
02942 
02943                 /* clear checked flag for all dependencies */
02944                 for(temp_sd2=servicedependency_list;temp_sd2!=NULL;temp_sd2=temp_sd2->next)
02945                         temp_sd2->circular_path_checked=FALSE;
02946 
02947                 found=check_for_circular_servicedependency_path(temp_sd,temp_sd,NOTIFICATION_DEPENDENCY);
02948                 if(found==TRUE){
02949                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: A circular notification dependency (which could result in a deadlock) exists for service '%s' on host '%s'!",temp_sd->service_description,temp_sd->host_name);
02950                         errors++;
02951                         }
02952                 }
02953 
02954         /* check execution dependencies between all hosts */
02955         for(temp_hd=hostdependency_list;temp_hd!=NULL;temp_hd=temp_hd->next){
02956 
02957                 /* clear checked flag for all dependencies */
02958                 for(temp_hd2=hostdependency_list;temp_hd2!=NULL;temp_hd2=temp_hd2->next)
02959                         temp_hd2->circular_path_checked=FALSE;
02960 
02961                 found=check_for_circular_hostdependency_path(temp_hd,temp_hd,EXECUTION_DEPENDENCY);
02962                 if(found==TRUE){
02963                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: A circular execution dependency (which could result in a deadlock) exists for host '%s'!",temp_hd->host_name);
02964                         errors++;
02965                         }
02966                 }
02967 
02968         /* check notification dependencies between all hosts */
02969         for(temp_hd=hostdependency_list;temp_hd!=NULL;temp_hd=temp_hd->next){
02970 
02971                 /* clear checked flag for all dependencies */
02972                 for(temp_hd2=hostdependency_list;temp_hd2!=NULL;temp_hd2=temp_hd2->next)
02973                         temp_hd2->circular_path_checked=FALSE;
02974 
02975                 found=check_for_circular_hostdependency_path(temp_hd,temp_hd,NOTIFICATION_DEPENDENCY);
02976                 if(found==TRUE){
02977                         logit(NSLOG_VERIFICATION_ERROR,TRUE,"Error: A circular notification dependency (which could result in a deadlock) exists for host '%s'!",temp_hd->host_name);
02978                         errors++;
02979                         }
02980                 }
02981 
02982 
02983         /* update warning and error count */
02984         *w+=warnings;
02985         *e+=errors;
02986  
02987         return (errors>0)?ERROR:OK;
02988         }
02989 
 All Data Structures Files Functions Variables Typedefs Defines