--- nagios-2.8.orig/include/cgiutils.h.in 2006-01-20 09:34:53.000000000 -0800 +++ nagios-2.8/include/cgiutils.h.in 2007-03-28 14:18:31.000000000 -0700 @@ -95,6 +95,11 @@ #define STATUS_ICON_WIDTH 20 #define STATUS_ICON_HEIGHT 20 +#ifdef SUPPORT_GROUPEXTINFO +#define TINY_ICON_WIDTH 12 +#define TINY_ICON_HEIGHT 12 +#endif /* SUPPORT_GROUPEXTINFO */ + #define INFO_ICON "info.png" #define INFO_ICON_ALT "Informational Message" #define START_ICON "start.gif" @@ -388,6 +393,10 @@ #define CONTEXTHELP_CONFIG_HOSTEXTINFO "L14" #define CONTEXTHELP_CONFIG_SERVICEEXTINFO "L15" #define CONTEXTHELP_CONFIG_SERVICEGROUPS "L16" +#ifdef SUPPORT_GROUPEXTINFO +#define CONTEXTHELP_CONFIG_HOSTGROUPEXTINFO "L17" +#define CONTEXTHELP_CONFIG_SERVICEGROUPEXTINFO "L18" +#endif /* SUPPORT_GROUPEXTINFO */ #define CONTEXTHELP_HISTOGRAM_MENU1 "M1" #define CONTEXTHELP_HISTOGRAM_MENU2 "M2" --- nagios-2.8.orig/include/objects.h 2006-03-21 14:21:51.000000000 -0800 +++ nagios-2.8/include/objects.h 2007-03-28 14:18:31.000000000 -0700 @@ -66,6 +66,11 @@ #define HOSTEXTINFO_HASHSLOTS 1024 #define SERVICEEXTINFO_HASHSLOTS 1024 +#ifdef SUPPORT_GROUPEXTINFO +#define HOSTGROUPEXTINFO_HASHSLOTS 128 +#define SERVICEGROUPEXTINFO_HASHSLOTS 128 +#endif // SUPPORT_GROUPEXTINFO + #define HOSTDEPENDENCY_HASHSLOTS 1024 #define SERVICEDEPENDENCY_HASHSLOTS 1024 #define HOSTESCALATION_HASHSLOTS 1024 @@ -459,7 +464,16 @@ char *notes; char *notes_url; char *action_url; - char *icon_image; +#ifdef SUPPORT_GROUPEXTINFO + char *target_frame; + char *notes_textinfo; + char *action_textinfo; + char *notes_icon; + char *notes_icon_alt; + char *action_icon; + char *action_icon_alt; +#endif // SUPPORT_GROUPEXTINFO + char *icon_image; char *vrml_image; char *statusmap_image; char *icon_image_alt; @@ -483,13 +497,60 @@ char *notes; char *notes_url; char *action_url; +#ifdef SUPPORT_GROUPEXTINFO + char *target_frame; + char *notes_textinfo; + char *action_textinfo; + char *notes_icon; + char *notes_icon_alt; + char *action_icon; + char *action_icon_alt; +#endif // SUPPORT_GROUPEXTINFO char *icon_image; char *icon_image_alt; struct serviceextinfo_struct *next; struct serviceextinfo_struct *nexthash; }serviceextinfo; - +#ifdef SUPPORT_GROUPEXTINFO +/* EXTENDED HOSTGROUP INFO structure */ +typedef struct hostgroupextinfo_struct{ + char *hostgroup_name; + char *notes; + char *notes_url; + char *action_url; + char *target_frame; + char *notes_textinfo; + char *action_textinfo; + char *notes_icon; + char *notes_icon_alt; + char *action_icon; + char *action_icon_alt; + char *icon_image; + char *icon_image_alt; + struct hostgroupextinfo_struct *next; + struct hostgroupextinfo_struct *nexthash; + }hostgroupextinfo; + +/* EXTENDED SERVICEGROUP INFO structure */ +typedef struct servicegroupextinfo_struct{ + char *servicegroup_name; + char *notes; + char *notes_url; + char *action_url; + char *target_frame; + char *notes_textinfo; + char *action_textinfo; + char *notes_icon; + char *notes_icon_alt; + char *action_icon; + char *action_icon_alt; + char *icon_image; + char *icon_image_alt; + struct servicegroupextinfo_struct *next; + struct servicegroupextinfo_struct *nexthash; + }servicegroupextinfo; +#endif // SUPPORT_GROUPEXTINFO /****************** HASH STRUCTURES ********************/ @@ -526,7 +587,11 @@ /**** Top-level input functions ****/ +#ifndef SUPPORT_GROUPEXTINFO int read_object_config_data(char *,int,int); /* reads all external configuration data of specific types */ +#else +int read_object_config_data(char *,unsigned long,int); /* reads all external configuration data of specific types */ +#endif // SUPPORT_GROUPEXTINFO /**** Object Creation Functions ****/ contact *add_contact(char *,char *,char *,char *,char **,char *,char *,int,int,int,int,int,int,int,int,int); /* adds a contact definition */ @@ -552,9 +617,15 @@ hostdependency *add_host_dependency(char *,char *,int,int,int,int,int,int); /* adds a host dependency definition */ hostescalation *add_hostescalation(char *,int,int,int,char *,int,int,int); /* adds a host escalation definition */ contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *,char *); /* adds a contact group to a host escalation definition */ +#ifndef SUPPORT_GROUPEXTINFO hostextinfo *add_hostextinfo(char *,char *,char *,char *,char *,char *,char *,char *,int,int,double,double,double,int,int); /* adds an extended host info definition */ -serviceextinfo *add_serviceextinfo(char *,char *,char *,char *,char *,char *,char *); /* add an extended service info definition */ - +serviceextinfo *add_serviceextinfo(char *,char *,char *,char *,char *,char *,char *); /* add an extended service info definition */ +#else // SUPPORT_GROUPEXTINFO +hostextinfo *add_hostextinfo(char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,int,int,double,double,double,int,int); /* adds an extended host info definition */ +serviceextinfo *add_serviceextinfo(char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *); /* add an extended service info definition */ +hostgroupextinfo *add_hostgroupextinfo(char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *); /* add an extended hostgroup info definition */ +servicegroupextinfo *add_servicegroupextinfo(char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *,char *); /* add an extended servicegroup info definition */ +#endif // SUPPORT_GROUPEXTINFO /**** Object Hash Functions ****/ int add_host_to_hashlist(host *); @@ -572,6 +643,10 @@ int add_hostextinfo_to_hashlist(hostextinfo *); int add_serviceextinfo_to_hashlist(serviceextinfo *); +#ifdef SUPPORT_GROUPEXTINFO +int add_hostgroupextinfo_to_hashlist(hostgroupextinfo *); +int add_servicegroupextinfo_to_hashlist(servicegroupextinfo *); +#endif // SUPPORT_GROUPEXTINFO /**** Object Search Functions ****/ timeperiod * find_timeperiod(char *); /* finds a timeperiod object */ @@ -586,6 +661,11 @@ hostextinfo *find_hostextinfo(char *); /* find an extended host info object */ serviceextinfo *find_serviceextinfo(char *,char *); /* find an extended service info object */ +#ifdef SUPPORT_GROUPEXTINFO +hostgroupextinfo *find_hostgroupextinfo(char *); /* find an extended hostgroup info object */ +servicegroupextinfo *find_servicegroupextinfo(char*);; /* find an extended servicegroup info object */ +#endif // SUPPORT_GROUPEXTINFO + /**** Object Traversal Functions ****/ void move_first_service(void); /* sets up the static memory area for get_next_service */ @@ -642,6 +722,13 @@ int free_object_data(void); /* frees all allocated memory for the object definitions */ int free_extended_data(void); /* frees memory allocated to the extended host/service information */ +#ifdef SUPPORT_GROUPEXTINFO +void freedata_hostextinfo(hostextinfo*); +void freedata_serviceextinfo(serviceextinfo*); +void freedata_hostgroupextinfo(hostgroupextinfo*); +void freedata_servicegroupextinfo(servicegroupextinfo*); +#endif // SUPPORT_GROUPEXTINFO + #ifdef __cplusplus } #endif --- nagios-2.8.orig/include/statusdata.h 2005-11-25 19:52:07.000000000 -0800 +++ nagios-2.8/include/statusdata.h 2007-03-28 14:18:31.000000000 -0700 @@ -165,7 +165,12 @@ /**************************** FUNCTIONS ******************************/ +#ifndef SUPPORT_GROUPEXTINFO int read_status_data(char *,int); /* reads all status data */ +#else +int read_status_data(char *,unsigned long); /* reads all status data */ +#endif + int add_host_status(hoststatus *); /* adds a host status entry to the list in memory */ int add_service_status(servicestatus *); /* adds a service status entry to the list in memory */ --- nagios-2.8.orig/base/config.c 2007-01-19 14:02:00.000000000 -0800 +++ nagios-2.8/base/config.c 2007-03-28 14:18:31.000000000 -0700 @@ -162,6 +162,12 @@ extern hostescalation *hostescalation_list; extern hostextinfo *hostextinfo_list; extern serviceextinfo *serviceextinfo_list; +#ifdef SUPPORT_GROUPEXTINFO +extern hostgroupextinfo *hostgroupextinfo_list; +extern servicegroupextinfo *servicegroupextinfo_list; +extern int allow_duplicate_extinfo; +extern int allow_extinfo_missingconfig; +#endif // SUPPORT_GROUPEXTINFO extern host **host_hashlist; extern service **service_hashlist; @@ -178,7 +184,11 @@ /* read all configuration data */ int read_all_object_data(char *main_config_file){ int result=OK; +#ifndef SUPPORT_GROUPEXTINFO int options; +#else // SUPPORT_GROUPEXTINFO + unsigned long options; +#endif // SUPPORT_GROUPEXTINFO int cache=FALSE; #ifdef DEBUG0 @@ -1388,6 +1398,22 @@ printf("\t\tuse_true_regexp_matching to %s\n",(use_true_regexp_matching==TRUE)?"TRUE":"FALSE"); #endif } +#ifdef SUPPORT_GROUPEXTINFO + else if(!strcmp(variable,"allow_duplicate_extinfo")){ + strip(value); + allow_duplicate_extinfo=(atoi(value)>0)?TRUE:FALSE; +#ifdef DEBUG1 + printf("\t\tallow_duplicate_extinfo to %s\n",(allow_duplicate_extinfo==TRUE)?"TRUE":"FALSE"); +#endif + } + else if(!strcmp(variable,"allow_extinfo_missingconfig")){ + strip(value); + allow_extinfo_missingconfig=(atoi(value)>0)?TRUE:FALSE; +#ifdef DEBUG1 + printf("\t\tallow_extinfo_missingconfig to %s\n",(allow_extinfo_missingconfig==TRUE)?"TRUE":"FALSE"); +#endif + } +#endif /* SUPPORT_GROUPEXTINFO */ else if(!strcmp(variable,"daemon_dumps_core")){ if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){ strcpy(error_message,"Illegal value for daemon_dumps_core"); @@ -1637,6 +1663,10 @@ hostdependency *temp_hd2=NULL; hostextinfo *temp_hostextinfo=NULL; serviceextinfo *temp_serviceextinfo=NULL; +#ifdef SUPPORT_GROUPEXTINFO + hostgroupextinfo *temp_hostgroupextinfo=NULL; + servicegroupextinfo *temp_servicegroupextinfo=NULL; +#endif // SUPPORT_GROUPEXTINFO char temp_buffer[MAX_INPUT_BUFFER]; char *temp_command_name=""; int found; @@ -2571,10 +2601,22 @@ /* find the host */ temp_host=find_host(temp_hostextinfo->host_name); if(temp_host==NULL){ - snprintf(temp_buffer,sizeof(temp_buffer),"Error: Host '%s' specified in extended host information is not defined anywhere!",temp_hostextinfo->host_name); - temp_buffer[sizeof(temp_buffer)-1]='\x0'; - write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE); - errors++; +#ifdef SUPPORT_GROUPEXTINFO + if (allow_extinfo_missingconfig) { + snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Host '%s' specified in extended host information is not defined anywhere!",temp_hostextinfo->host_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_WARNING,TRUE); + warnings++; + } + else { +#endif /* SUPPORT_GROUPEXTINFO */ + snprintf(temp_buffer,sizeof(temp_buffer),"Error: Host '%s' specified in extended host information is not defined anywhere!",temp_hostextinfo->host_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE); + errors++; +#ifdef SUPPORT_GROUPEXTINFO + } +#endif /* SUPPORT_GROUPEXTINFO */ } } @@ -2597,10 +2639,22 @@ /* find the service */ temp_service=find_service(temp_serviceextinfo->host_name,temp_serviceextinfo->description); if(temp_service==NULL){ - snprintf(temp_buffer,sizeof(temp_buffer),"Error: Service '%s' on host '%s' specified in extended service information is not defined anywhere!",temp_serviceextinfo->description,temp_serviceextinfo->host_name); - temp_buffer[sizeof(temp_buffer)-1]='\x0'; - write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE); - errors++; +#ifdef SUPPORT_GROUPEXTINFO + if (allow_extinfo_missingconfig) { + snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Service '%s' on host '%s' specified in extended service information is not defined anywhere!",temp_serviceextinfo->description,temp_serviceextinfo->host_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_WARNING,TRUE); + warnings++; + } + else { +#endif /* SUPPORT_GROUPEXTINFO */ + snprintf(temp_buffer,sizeof(temp_buffer),"Error: Service '%s' on host '%s' specified in extended service information is not defined anywhere!",temp_serviceextinfo->description,temp_serviceextinfo->host_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE); + errors++; +#ifdef SUPPORT_GROUPEXTINFO + } +#endif /* SUPPORT_GROUPEXTINFO */ } } @@ -2611,6 +2665,75 @@ printf("\tCompleted extended service info checks\n"); #endif +#ifdef SUPPORT_GROUPEXTINFO + + /*****************************************/ + /* check extended hostgroup information... */ + /*****************************************/ + if(verify_config==TRUE) + printf("Checking extended hostgroup info definitions...\n"); + + for(temp_hostgroupextinfo=hostgroupextinfo_list,total_objects=0;temp_hostgroupextinfo!=NULL;temp_hostgroupextinfo=temp_hostgroupextinfo->next,total_objects++){ + + /* find the hostgroup */ + temp_hostgroup=find_hostgroup(temp_hostgroupextinfo->hostgroup_name); + if(temp_hostgroup==NULL){ + if (allow_extinfo_missingconfig) { + snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Hostgroup '%s' specified in extended service information is not defined anywhere!",temp_hostgroupextinfo->hostgroup_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_WARNING,TRUE); + warnings++; + } + else { + snprintf(temp_buffer,sizeof(temp_buffer),"Error: Hostgroup '%s' specified in extended service information is not defined anywhere!",temp_hostgroupextinfo->hostgroup_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE); + errors++; + } + } + } + + if(verify_config==TRUE) + printf("\tChecked %d extended hostgroup info definitions.\n",total_objects); + +#ifdef DEBUG1 + printf("\tCompleted extended hostgroup info checks\n"); +#endif + + /*****************************************/ + /* check extended servicegroup information... */ + /*****************************************/ + if(verify_config==TRUE) + printf("Checking extended servicegroup info definitions...\n"); + + for(temp_servicegroupextinfo=servicegroupextinfo_list,total_objects=0;temp_servicegroupextinfo!=NULL;temp_servicegroupextinfo=temp_servicegroupextinfo->next,total_objects++){ + + /* find the servicegroup */ + temp_servicegroup=find_servicegroup(temp_servicegroupextinfo->servicegroup_name); + if(temp_servicegroup==NULL){ + if (allow_extinfo_missingconfig) { + snprintf(temp_buffer,sizeof(temp_buffer),"Error: Servicegroup '%s' specified in extended service information is not defined anywhere!",temp_servicegroupextinfo->servicegroup_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_WARNING,TRUE); + warnings++; + } + else { + snprintf(temp_buffer,sizeof(temp_buffer),"Error: Servicegroup '%s' specified in extended service information is not defined anywhere!",temp_servicegroupextinfo->servicegroup_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE); + errors++; + } + } + } + + if(verify_config==TRUE) + printf("\tChecked %d extended servicegroup info definitions.\n",total_objects); + +#ifdef DEBUG1 + printf("\tCompleted extended servicegroup info checks\n"); +#endif + +#endif // SUPPORT_GROUPEXTINFO /********************************************/ /* check for circular paths between hosts */ @@ -2833,4 +2956,3 @@ return (errors>0)?ERROR:OK; } - --- nagios-2.8.orig/base/nagios.c 2007-03-08 08:12:05.000000000 -0800 +++ nagios-2.8/base/nagios.c 2007-03-28 14:18:31.000000000 -0700 @@ -171,6 +171,11 @@ int obsess_over_hosts=FALSE; int enable_failure_prediction=TRUE; +#ifdef SUPPORT_GROUPEXTINFO +int allow_duplicate_extinfo=FALSE; +int allow_extinfo_missingconfig=FALSE; +#endif /* SUPPORT_GROUPEXTINFO */ + int aggregate_status_updates=TRUE; int status_update_interval=DEFAULT_STATUS_UPDATE_INTERVAL; --- nagios-2.8.orig/common/objects.c 2006-02-24 16:16:57.000000000 -0800 +++ nagios-2.8/common/objects.c 2007-03-28 14:18:31.000000000 -0700 @@ -55,6 +55,10 @@ hostescalation *hostescalation_list=NULL,*hostescalation_list_tail=NULL; hostextinfo *hostextinfo_list=NULL,*hostextinfo_list_tail=NULL; serviceextinfo *serviceextinfo_list=NULL,*serviceextinfo_list_tail=NULL; +#ifdef SUPPORT_GROUPEXTINFO +hostgroupextinfo *hostgroupextinfo_list=NULL,*hostgroupextinfo_list_tail=NULL; +servicegroupextinfo *servicegroupextinfo_list=NULL,*servicegroupextinfo_list_tail=NULL; +#endif // SUPPORT_GROUPEXTINFO host **host_hashlist=NULL; service **service_hashlist=NULL; @@ -70,7 +74,15 @@ servicedependency **servicedependency_hashlist=NULL; hostescalation **hostescalation_hashlist=NULL; serviceescalation **serviceescalation_hashlist=NULL; +#ifdef SUPPORT_GROUPEXTINFO +hostgroupextinfo **hostgroupextinfo_hashlist=NULL; +servicegroupextinfo **servicegroupextinfo_hashlist=NULL; +extern int allow_duplicate_extinfo; +#ifdef NSCORE +char error_temp_buffer[MAX_INPUT_BUFFER]; +#endif +#endif // SUPPORT_GROUPEXTINFO #ifdef NSCORE int __nagios_object_structure_version=CURRENT_OBJECT_STRUCTURE_VERSION; @@ -82,9 +94,12 @@ /******* TOP-LEVEL HOST CONFIGURATION DATA INPUT FUNCTION *********/ /******************************************************************/ - /* read all host configuration data from external source */ +#ifndef SUPPORT_GROUPEXTINFO int read_object_config_data(char *main_config_file,int options,int cache){ +#else // SUPPORT_GROUPEXTINFO +int read_object_config_data(char *main_config_file,unsigned long options,int cache){ +#endif // SUPPORT_GROUPEXTINFO int result=OK; #ifdef DEBUG0 @@ -515,10 +530,15 @@ hashslot=hashfunc1(new_hostextinfo->host_name,HOSTEXTINFO_HASHSLOTS); lastpointer=NULL; - for(temp_hostextinfo=hostextinfo_hashlist[hashslot];temp_hostextinfo && compare_hashdata1(temp_hostextinfo->host_name,new_hostextinfo->host_name)<0;temp_hostextinfo=temp_hostextinfo->nexthash) + + for(temp_hostextinfo=hostextinfo_hashlist[hashslot];temp_hostextinfo!=NULL && compare_hashdata1(temp_hostextinfo->host_name,new_hostextinfo->host_name)<0;temp_hostextinfo=temp_hostextinfo->nexthash) lastpointer=temp_hostextinfo; +#ifndef SUPPORT_GROUPEXTINFO if(!temp_hostextinfo || (compare_hashdata1(temp_hostextinfo->host_name,new_hostextinfo->host_name)!=0)){ +#else /* SUPPORT_GROUPEXTINFO */ + if(allow_duplicate_extinfo==TRUE || !temp_hostextinfo || compare_hashdata1(temp_hostextinfo->host_name,new_hostextinfo->host_name)!=0){ +#endif /* SUPPORT_GROUPEXTINFO */ if(lastpointer) lastpointer->nexthash=new_hostextinfo; else @@ -562,17 +582,21 @@ hashslot=hashfunc2(new_serviceextinfo->host_name,new_serviceextinfo->description,SERVICEEXTINFO_HASHSLOTS); lastpointer=NULL; - for(temp_serviceextinfo=serviceextinfo_hashlist[hashslot];temp_serviceextinfo && compare_hashdata2(temp_serviceextinfo->host_name,temp_serviceextinfo->description,new_serviceextinfo->host_name,new_serviceextinfo->description)<0;temp_serviceextinfo=temp_serviceextinfo->nexthash) + + for(temp_serviceextinfo=serviceextinfo_hashlist[hashslot];temp_serviceextinfo && compare_hashdata2(temp_serviceextinfo->host_name,temp_serviceextinfo->description,new_serviceextinfo->host_name,new_serviceextinfo->description)<0;temp_serviceextinfo=temp_serviceextinfo->nexthash) lastpointer=temp_serviceextinfo; +#ifndef SUPPORT_GROUPEXTINFO if(!temp_serviceextinfo || (compare_hashdata2(temp_serviceextinfo->host_name,temp_serviceextinfo->description,new_serviceextinfo->host_name,new_serviceextinfo->description)!=0)){ +#else /* SUPPORT_GROUPEXTINFO */ + if(allow_duplicate_extinfo==FALSE || !temp_serviceextinfo || compare_hashdata2(temp_serviceextinfo->host_name,temp_serviceextinfo->description,new_serviceextinfo->host_name,new_serviceextinfo->description)!=0){ +#endif /* SUPPORT_GROUPEXTINFO */ if(lastpointer) lastpointer->nexthash=new_serviceextinfo; else serviceextinfo_hashlist[hashslot]=new_serviceextinfo; new_serviceextinfo->nexthash=temp_serviceextinfo; - return 1; } @@ -586,6 +610,116 @@ } +#ifdef SUPPORT_GROUPEXTINFO + +/* adds hostgroupextinfo to hash list in memory */ +int add_hostgroupextinfo_to_hashlist(hostgroupextinfo *new_hostgroupextinfo) { + hostgroupextinfo *temp_hostgroupextinfo, *lastpointer; + int hashslot; +#ifdef NSCORE + char temp_buffer[MAX_INPUT_BUFFER]; +#endif + + /* initialize hash list */ + if(hostgroupextinfo_hashlist==NULL){ + int i; + + hostgroupextinfo_hashlist=(hostgroupextinfo **)malloc(sizeof(hostgroupextinfo *)*HOSTGROUPEXTINFO_HASHSLOTS); + if(hostgroupextinfo_hashlist==NULL) + return 0; + + for(i=0;ihostgroup_name,HOSTGROUPEXTINFO_HASHSLOTS); + lastpointer=NULL; + + for(temp_hostgroupextinfo=hostgroupextinfo_hashlist[hashslot];temp_hostgroupextinfo && compare_hashdata1(temp_hostgroupextinfo->hostgroup_name,new_hostgroupextinfo->hostgroup_name)<0;temp_hostgroupextinfo=temp_hostgroupextinfo->nexthash) + lastpointer=temp_hostgroupextinfo; + +#ifndef SUPPORT_GROUPEXTINFO + if(!temp_hostgroupextinfo || (compare_hashdata1(temp_hostgroupextinfo->hostgroup_name,new_hostgroupextinfo->hostgroup_name)!=0)){ +#else /* SUPPORT_GROUPEXTINFO */ + if(allow_duplicate_extinfo==FALSE || !temp_hostgroupextinfo || compare_hashdata1(temp_hostgroupextinfo->hostgroup_name,new_hostgroupextinfo->hostgroup_name)!=0){ +#endif /* SUPPORT_GROUPEXTINFO */ + if(lastpointer) + lastpointer->nexthash=new_hostgroupextinfo; + else + hostgroupextinfo_hashlist[hashslot]=new_hostgroupextinfo; + new_hostgroupextinfo->nexthash=temp_hostgroupextinfo; + + return 1; + } + + /* else already exists */ +#ifdef NSCORE + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not add duplicate hostgroupextinfo entry for hostgroup '%s'.\n",new_hostgroupextinfo->hostgroup_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return 0; + } + + +/* adds servicegroupextinfo to hash list in memory */ +int add_servicegroupextinfo_to_hashlist(servicegroupextinfo *new_servicegroupextinfo) { + servicegroupextinfo *temp_servicegroupextinfo, *lastpointer; + int hashslot; +#ifdef NSCORE + char temp_buffer[MAX_INPUT_BUFFER]; +#endif + + /* initialize hash list */ + if(servicegroupextinfo_hashlist==NULL){ + int i; + + servicegroupextinfo_hashlist=(servicegroupextinfo **)malloc(sizeof(servicegroupextinfo *)*SERVICEGROUPEXTINFO_HASHSLOTS); + if(servicegroupextinfo_hashlist==NULL) + return 0; + + for(i=0;iservicegroup_name,SERVICEGROUPEXTINFO_HASHSLOTS); + lastpointer=NULL; + + for(temp_servicegroupextinfo=servicegroupextinfo_hashlist[hashslot];temp_servicegroupextinfo && compare_hashdata1(temp_servicegroupextinfo->servicegroup_name,new_servicegroupextinfo->servicegroup_name)<0;temp_servicegroupextinfo=temp_servicegroupextinfo->nexthash) + lastpointer=temp_servicegroupextinfo; + +#ifndef SUPPORT_GROUPEXTINFO + if(!temp_servicegroupextinfo || (compare_hashdata1(temp_servicegroupextinfo->servicegroup_name,new_servicegroupextinfo->servicegroup_name)!=0)){ +#else /* SUPPORT_GROUPEXTINFO */ + if(allow_duplicate_extinfo || !temp_servicegroupextinfo || (compare_hashdata1(temp_servicegroupextinfo->servicegroup_name,new_servicegroupextinfo->servicegroup_name)!=0)){ +#endif /* SUPPORT_GROUPEXTINFO */ + if(lastpointer) + lastpointer->nexthash=new_servicegroupextinfo; + else + servicegroupextinfo_hashlist[hashslot]=new_servicegroupextinfo; + new_servicegroupextinfo->nexthash=temp_servicegroupextinfo; + + return 1; + } + + /* else already exists */ +#ifdef NSCORE + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not add duplicate servicegroupextinfo entry for servicegroup '%s'.\n",new_servicegroupextinfo->servicegroup_name); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return 0; + } + +#endif // SUPPORT_GROUPEXTINFO + + /* adds hostdependency to hash list in memory */ int add_hostdependency_to_hashlist(hostdependency *new_hostdependency){ hostdependency *temp_hostdependency, *lastpointer; @@ -4289,8 +4423,7 @@ return new_contactgroupsmember; } - - +#ifndef SUPPORT_GROUPEXTINFO /* adds an extended host info structure to the list in memory */ hostextinfo * add_hostextinfo(char *host_name, char *notes, char *notes_url, char *action_url, char *icon_image, char *vrml_image, char *statusmap_image, char *icon_image_alt, int x_2d, int y_2d, double x_3d, double y_3d, double z_3d, int have_2d_coords, int have_3d_coords){ @@ -4723,9 +4856,491 @@ return new_serviceextinfo; } + +#else /* ifdef SUPPORT_GROUPEXTINFO */ + +#define STRDUP_ERRORCHECK(strdata_out, strdata_in, error_object) if(error_object != NULL && strdata_in != NULL && *strdata_in!='\0') { strdata_out=strdup(strdata_in); if (strdata_out == NULL) error_object=NULL; } + +/* adds an extended host info structure to the list in memory */ +hostextinfo * add_hostextinfo(char *host_name, char *notes, char *notes_url, char *action_url, char* target_frame, char* notes_textinfo, char* action_textinfo, char* notes_icon, char* notes_icon_alt, char* action_icon, char* action_icon_alt, char *icon_image, char *vrml_image, char *statusmap_image, char *icon_image_alt, int x_2d, int y_2d, double x_3d, double y_3d, double z_3d, int have_2d_coords, int have_3d_coords){ + hostextinfo *new_hostextinfo; + hostextinfo *return_data; + +#ifdef DEBUG0 + printf("add_hostextinfo() start\n"); +#endif + + /* make sure we have what we need */ + if(host_name==NULL || !strcmp(host_name,"")){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Host name is NULL\n"); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return NULL; + } + + /* allocate memory for a new data structure */ + new_hostextinfo=(hostextinfo *)malloc(sizeof(hostextinfo)); + if(new_hostextinfo==NULL){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for host '%s' extended info.\n",host_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return NULL; + } + + /* Initialize all hostext data to NULL first */ + new_hostextinfo->next=NULL; + new_hostextinfo->nexthash=NULL; + new_hostextinfo->host_name = NULL; + new_hostextinfo->notes = NULL; + new_hostextinfo->notes_url = NULL; + new_hostextinfo->action_url = NULL; + new_hostextinfo->icon_image = NULL; + new_hostextinfo->icon_image_alt = NULL; + new_hostextinfo->vrml_image = NULL; + new_hostextinfo->statusmap_image = NULL; + new_hostextinfo->target_frame = NULL; + new_hostextinfo->action_textinfo = NULL; + new_hostextinfo->notes_textinfo = NULL; + new_hostextinfo->action_icon = NULL; + new_hostextinfo->action_icon_alt = NULL; + new_hostextinfo->notes_icon = NULL; + new_hostextinfo->notes_icon_alt = NULL; + return_data = new_hostextinfo; + + /* And now actually copy real data in the structure variables */ + STRDUP_ERRORCHECK(new_hostextinfo->host_name, host_name, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->notes, notes, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->notes_url, notes_url, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->action_url, action_url, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->icon_image, icon_image, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->icon_image_alt, icon_image_alt, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->vrml_image, vrml_image, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->statusmap_image, statusmap_image, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->target_frame, target_frame, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->notes_textinfo, notes_textinfo, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->action_textinfo, action_textinfo, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->notes_icon, notes_icon, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->notes_icon_alt, notes_icon_alt, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->action_icon, action_icon, return_data); + STRDUP_ERRORCHECK(new_hostextinfo->action_icon_alt, action_icon_alt, return_data); + + /* If there was problem with any above, then return_data is set to NULL and we report an error */ + if (return_data == NULL) { +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for host '%s' extended info.\n",host_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + freedata_hostextinfo(new_hostextinfo); + free(new_hostextinfo); + } + else { + /* 2-D coordinates */ + new_hostextinfo->x_2d=x_2d; + new_hostextinfo->y_2d=y_2d; + new_hostextinfo->have_2d_coords=have_2d_coords; + + /* 3-D coordinates */ + new_hostextinfo->x_3d=x_3d; + new_hostextinfo->y_3d=y_3d; + new_hostextinfo->z_3d=z_3d; + new_hostextinfo->have_3d_coords=have_3d_coords; + + /* default is to not draw this item */ + new_hostextinfo->should_be_drawn=FALSE; + + new_hostextinfo->next=NULL; + new_hostextinfo->nexthash=NULL; + } + + /* add new hostextinfo to hostextinfo chained hash list */ + if(return_data != NULL && !add_hostextinfo_to_hashlist(new_hostextinfo)){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for hostextinfo list to add extended info for host '%s'.\n",host_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + freedata_hostextinfo(new_hostextinfo); + free(new_hostextinfo); + return_data = NULL; + } + + if(return_data != NULL){ +#ifdef NSCORE + /* hostextinfo entries are sorted alphabetically for daemon, so add new items to tail of list */ + if(hostextinfo_list==NULL){ + hostextinfo_list=new_hostextinfo; + hostextinfo_list_tail=hostextinfo_list; + } + else{ + hostextinfo_list_tail->next=new_hostextinfo; + hostextinfo_list_tail=new_hostextinfo; + } +#else + /* hostextinfo entries are sorted in reverse for CGIs, so add new items to head of list */ + new_hostextinfo->next=hostextinfo_list; + hostextinfo_list=new_hostextinfo; +#endif + } + +#ifdef DEBUG0 + printf("add_hostextinfo() end\n"); +#endif + return return_data; + } +/* adds an extended service info structure to the list in memory */ +serviceextinfo * add_serviceextinfo(char *host_name, char *description, char *notes, char *notes_url, char *action_url, char* target_frame, char* notes_textinfo, char* action_textinfo, char* notes_icon, char* notes_icon_alt, char* action_icon, char* action_icon_alt, char *icon_image, char *icon_image_alt) { + serviceextinfo *new_serviceextinfo; + serviceextinfo *return_data; +#ifdef DEBUG0 + printf("add_serviceextinfo() start\n"); +#endif + + /* make sure we have what we need */ + if((host_name==NULL || !strcmp(host_name,"")) || (description==NULL || !strcmp(description,""))){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Host name or service description is NULL\n"); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return NULL; + } + + /* allocate memory for a new data structure */ + new_serviceextinfo=(serviceextinfo *)malloc(sizeof(serviceextinfo)); + if(new_serviceextinfo==NULL){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for service '%s' on host '%s' extended info.\n",description,host_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return NULL; + } + + /* Initialize all servicext data to NULL first */ + new_serviceextinfo->next=NULL; + new_serviceextinfo->nexthash=NULL; + new_serviceextinfo->host_name = NULL; + new_serviceextinfo->description = NULL; + new_serviceextinfo->notes = NULL; + new_serviceextinfo->notes_url = NULL; + new_serviceextinfo->action_url = NULL; + new_serviceextinfo->icon_image = NULL; + new_serviceextinfo->icon_image_alt = NULL; + new_serviceextinfo->target_frame = NULL; + new_serviceextinfo->action_textinfo = NULL; + new_serviceextinfo->notes_textinfo = NULL; + new_serviceextinfo->action_icon = NULL; + new_serviceextinfo->action_icon_alt = NULL; + new_serviceextinfo->notes_icon = NULL; + new_serviceextinfo->notes_icon_alt = NULL; + return_data = new_serviceextinfo; + + /* And now actually copy real data in the structure variables */ + STRDUP_ERRORCHECK(new_serviceextinfo->host_name, host_name, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->description, description, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->notes, notes, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->notes_url, notes_url, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->action_url, action_url, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->icon_image, icon_image, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->icon_image_alt, icon_image_alt, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->target_frame, target_frame, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->notes_textinfo, notes_textinfo, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->action_textinfo, action_textinfo, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->notes_icon, notes_icon, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->notes_icon_alt, notes_icon_alt, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->action_icon, action_icon, return_data); + STRDUP_ERRORCHECK(new_serviceextinfo->action_icon_alt, action_icon_alt, return_data); + + /* If there was problem with any above, then return_data is set to NULL and we report an error */ + if (return_data == NULL) { +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for service '%s' on host '%s' extended info.\n",description,host_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + freedata_serviceextinfo(new_serviceextinfo); + free(new_serviceextinfo); + } + else { + new_serviceextinfo->next=NULL; + new_serviceextinfo->nexthash=NULL; + } + + /* add new serviceextinfo to serviceextinfo chained hash list */ + if(return_data != NULL && !add_serviceextinfo_to_hashlist(new_serviceextinfo)){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for serviceextinfo list to add extended info for service '%s' on host '%s'.\n",description,host_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + freedata_serviceextinfo(new_serviceextinfo); + free(new_serviceextinfo); + return_data = NULL; + } + + if(return_data != NULL){ +#ifdef NSCORE + /* serviceextinfo entries are sorted alphabetically for daemon, so add new items to tail of list */ + if(serviceextinfo_list==NULL){ + serviceextinfo_list=new_serviceextinfo; + serviceextinfo_list_tail=serviceextinfo_list; + } + else{ + serviceextinfo_list_tail->next=new_serviceextinfo; + serviceextinfo_list_tail=new_serviceextinfo; + } +#else + /* serviceextinfo entries are sorted in reverse for CGIs, so add new items to head of list */ + new_serviceextinfo->next=serviceextinfo_list; + serviceextinfo_list=new_serviceextinfo; +#endif + } + +#ifdef DEBUG0 + printf("add_serviceextinfo() end\n"); +#endif + + return return_data; + } + + +/* adds an extended hostgroup info structure to the list in memory */ +hostgroupextinfo * add_hostgroupextinfo(char *hostgroup_name, char *notes, char *notes_url, char *action_url, char* target_frame, char* notes_textinfo, char* action_textinfo, char* notes_icon, char* notes_icon_alt, char* action_icon, char* action_icon_alt, char *icon_image, char *icon_image_alt){ + hostgroupextinfo *new_hostgroupextinfo; + hostgroupextinfo *return_data; + +#ifdef DEBUG0 + printf("add_hostgroupextinfo() start\n"); +#endif + + /* make sure we have what we need */ + if(hostgroup_name==NULL || !strcmp(hostgroup_name,"")){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Hostgroup name is NULL\n"); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return NULL; + } + + /* allocate memory for a new data structure */ + new_hostgroupextinfo=(hostgroupextinfo *)malloc(sizeof(hostgroupextinfo)); + if(new_hostgroupextinfo==NULL){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for hostgroup '%s' extended info.\n",hostgroup_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return NULL; + } + + /* Initialize all hostgroupext data to NULL first */ + new_hostgroupextinfo->hostgroup_name = NULL; + new_hostgroupextinfo->notes = NULL; + new_hostgroupextinfo->notes_url = NULL; + new_hostgroupextinfo->action_url = NULL; + new_hostgroupextinfo->icon_image = NULL; + new_hostgroupextinfo->icon_image_alt = NULL; + new_hostgroupextinfo->target_frame = NULL; + new_hostgroupextinfo->action_textinfo = NULL; + new_hostgroupextinfo->notes_textinfo = NULL; + new_hostgroupextinfo->action_icon = NULL; + new_hostgroupextinfo->action_icon_alt = NULL; + new_hostgroupextinfo->notes_icon = NULL; + new_hostgroupextinfo->notes_icon_alt = NULL; + return_data = new_hostgroupextinfo; + + /* And now actually copy real data in the structure variables */ + STRDUP_ERRORCHECK(new_hostgroupextinfo->hostgroup_name, hostgroup_name, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->notes, notes, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->notes_url, notes_url, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->action_url, action_url, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->icon_image, icon_image, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->icon_image_alt, icon_image_alt, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->target_frame, target_frame, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->notes_textinfo, notes_textinfo, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->action_textinfo, action_textinfo, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->notes_icon, notes_icon, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->notes_icon_alt, notes_icon_alt, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->action_icon, action_icon, return_data); + STRDUP_ERRORCHECK(new_hostgroupextinfo->action_icon_alt, action_icon_alt, return_data); + + /* If there was problem with any above, then return_data is set to NULL and we report an error */ + if (return_data == NULL) { +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for hostgroup '%s' extended info.\n",hostgroup_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + freedata_hostgroupextinfo(new_hostgroupextinfo); + free(new_hostgroupextinfo); + } + else { + new_hostgroupextinfo->next=NULL; + new_hostgroupextinfo->nexthash=NULL; + } + + /* add new hostgroupextinfo to hostgroupextinfo chained hash list */ + if(return_data!=NULL && !add_hostgroupextinfo_to_hashlist(new_hostgroupextinfo)){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for hostgroupextinfo list to add extended info for hostgroup '%s'.\n",hostgroup_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + freedata_hostgroupextinfo(new_hostgroupextinfo); + free(new_hostgroupextinfo); + return_data = NULL; + } + + if(return_data != NULL){ +#ifdef NSCORE + /* extinfo entries are sorted alphabetically for daemon, so add new items to tail of list */ + if(hostgroupextinfo_list==NULL){ + hostgroupextinfo_list=new_hostgroupextinfo; + hostgroupextinfo_list_tail=hostgroupextinfo_list; + } + else{ + hostgroupextinfo_list_tail->next=new_hostgroupextinfo; + hostgroupextinfo_list_tail=new_hostgroupextinfo; + } +#else + /* extinfo entries are sorted in reverse for CGIs, so add new items to head of list */ + new_hostgroupextinfo->next=hostgroupextinfo_list; + hostgroupextinfo_list=new_hostgroupextinfo; +#endif + } + +#ifdef DEBUG0 + printf("add_hostgroupextinfo() end\n"); +#endif + + return return_data; + } + + +/* adds an extended servicegroup info structure to the list in memory */ +servicegroupextinfo * add_servicegroupextinfo(char *servicegroup_name, char *notes, char *notes_url, char *action_url, char* target_frame, char* notes_textinfo, char* action_textinfo, char* notes_icon, char* notes_icon_alt, char* action_icon, char* action_icon_alt, char *icon_image, char *icon_image_alt){ + servicegroupextinfo *new_servicegroupextinfo; + servicegroupextinfo *return_data; + +#ifdef DEBUG0 + printf("add_servicegroupextinfo() start\n"); +#endif + + /* make sure we have what we need */ + if(servicegroup_name==NULL || !strcmp(servicegroup_name,"")){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Servicegroup name is NULL\n"); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return NULL; + } + + /* allocate memory for a new data structure */ + new_servicegroupextinfo=(servicegroupextinfo *)malloc(sizeof(servicegroupextinfo)); + if(new_servicegroupextinfo==NULL){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for servicegroup '%s' extended info.\n",servicegroup_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return NULL; + } + + /* Initialize all servicegroupext data to NULL first */ + new_servicegroupextinfo->servicegroup_name = NULL; + new_servicegroupextinfo->notes = NULL; + new_servicegroupextinfo->notes_url = NULL; + new_servicegroupextinfo->action_url = NULL; + new_servicegroupextinfo->icon_image = NULL; + new_servicegroupextinfo->icon_image_alt = NULL; + new_servicegroupextinfo->target_frame = NULL; + new_servicegroupextinfo->action_textinfo = NULL; + new_servicegroupextinfo->notes_textinfo = NULL; + new_servicegroupextinfo->action_icon = NULL; + new_servicegroupextinfo->action_icon_alt = NULL; + new_servicegroupextinfo->notes_icon = NULL; + new_servicegroupextinfo->notes_icon_alt = NULL; + return_data = new_servicegroupextinfo; + + /* And now actually copy real data in the structure variables */ + STRDUP_ERRORCHECK(new_servicegroupextinfo->servicegroup_name, servicegroup_name, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->notes, notes, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->notes_url, notes_url, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->action_url, action_url, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->icon_image, icon_image, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->icon_image_alt, icon_image_alt, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->target_frame, target_frame, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->notes_textinfo, notes_textinfo, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->action_textinfo, action_textinfo, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->notes_icon, notes_icon, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->notes_icon_alt, notes_icon_alt, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->action_icon, action_icon, return_data); + STRDUP_ERRORCHECK(new_servicegroupextinfo->action_icon_alt, action_icon_alt, return_data); + + /* If there was problem with any above, then return_data is set to NULL and we report an error */ + if (return_data == NULL) { +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for servicegroup '%s' extended info.\n",servicegroup_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + freedata_servicegroupextinfo(new_servicegroupextinfo); + free(new_servicegroupextinfo); + } + else { + new_servicegroupextinfo->next=NULL; + new_servicegroupextinfo->nexthash=NULL; + } + + /* add new servicegroupextinfo to servicegroupextinfo chained hash list */ + if(return_data!=NULL && !add_servicegroupextinfo_to_hashlist(new_servicegroupextinfo)){ +#ifdef NSCORE + snprintf(error_temp_buffer,sizeof(error_temp_buffer)-1,"Error: Could not allocate memory for servicegroupextinfo list to add extended info for servicegroup '%s'.\n",servicegroup_name); + error_temp_buffer[sizeof(error_temp_buffer)-1]='\x0'; + write_to_logs_and_console(error_temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + freedata_servicegroupextinfo(new_servicegroupextinfo); + free(new_servicegroupextinfo); + return_data = NULL; + } + + + if(return_data != NULL){ +#ifdef NSCORE + /* extinfo entries are sorted alphabetically for daemon, so add new items to tail of list */ + if(servicegroupextinfo_list==NULL){ + servicegroupextinfo_list=new_servicegroupextinfo; + servicegroupextinfo_list_tail=servicegroupextinfo_list; + } + else{ + servicegroupextinfo_list_tail->next=new_servicegroupextinfo; + servicegroupextinfo_list_tail=new_servicegroupextinfo; + } +#else + /* extinfo entries are sorted in reverse for CGIs, so add new items to head of list */ + new_servicegroupextinfo->next=servicegroupextinfo_list; + servicegroupextinfo_list=new_servicegroupextinfo; +#endif + } + +#ifdef DEBUG0 + printf("add_servicegroupextinfo() end\n"); +#endif + + return return_data; + } + +#endif // SUPPORT_GROUPEXTINFO /******************************************************************/ /******************** OBJECT SEARCH FUNCTIONS *********************/ @@ -4806,6 +5421,7 @@ } + #ifdef REMOVED_061803 /* find a member of a host group */ hostgroupmember * find_hostgroupmember(char *name,hostgroup *grp){ @@ -5078,6 +5694,57 @@ } +#ifdef SUPPORT_GROUPEXTINFO + +/* find the extended information for a given hostgroup */ +hostgroupextinfo * find_hostgroupextinfo(char *hostgroup_name){ + hostgroupextinfo *temp_hostgroupextinfo; + +#ifdef DEBUG0 + printf("find_hostgroupextinfo() start\n"); +#endif + + if(hostgroup_name==NULL || hostgroupextinfo_hashlist==NULL) + return NULL; + + for(temp_hostgroupextinfo=hostgroupextinfo_hashlist[hashfunc1(hostgroup_name,HOSTGROUPEXTINFO_HASHSLOTS)];temp_hostgroupextinfo && compare_hashdata1(temp_hostgroupextinfo->hostgroup_name,hostgroup_name)<0;temp_hostgroupextinfo=temp_hostgroupextinfo->nexthash); + + if(temp_hostgroupextinfo && (compare_hashdata1(temp_hostgroupextinfo->hostgroup_name,hostgroup_name)==0)) + return temp_hostgroupextinfo; + +#ifdef DEBUG0 + printf("find_hostgroupextinfo() end\n"); +#endif + + /* we couldn't find a matching extended hostgroup info object */ + return NULL; + } + +/* find the extended information for a given servicegroup */ +servicegroupextinfo * find_servicegroupextinfo(char *servicegroup_name){ + servicegroupextinfo *temp_servicegroupextinfo; + +#ifdef DEBUG0 + printf("find_servicegroupextinfo() start\n"); +#endif + + if(servicegroup_name==NULL || servicegroupextinfo_hashlist==NULL) + return NULL; + + for(temp_servicegroupextinfo=servicegroupextinfo_hashlist[hashfunc1(servicegroup_name,SERVICEGROUPEXTINFO_HASHSLOTS)];temp_servicegroupextinfo && compare_hashdata1(temp_servicegroupextinfo->servicegroup_name,servicegroup_name)<0;temp_servicegroupextinfo=temp_servicegroupextinfo->nexthash); + + if(temp_servicegroupextinfo && (compare_hashdata1(temp_servicegroupextinfo->servicegroup_name,servicegroup_name)==0)) + return temp_servicegroupextinfo; + +#ifdef DEBUG0 + printf("find_servicegroupextinfo() end\n"); +#endif + + /* we couldn't find a matching extended servicegroup info object */ + return NULL; + } + +#endif // SUPPORT_GROUPEXTINFO /******************************************************************/ @@ -6102,6 +6769,7 @@ return OK; } +#ifndef SUPPORT_GROUPEXTINFO /* free all allocated memory for extended info objects */ int free_extended_data(void){ @@ -6159,6 +6827,169 @@ serviceextinfo_hashlist=NULL; serviceextinfo_list=NULL; +#ifdef DEBUG0 + printf("free_extended_data() end\n"); +#endif + + return OK; + } + +#else /* #ifdef SUPPORT_GROUPEXTINFO */ + +/* free all allocated memory for extended info objects */ + +void freedata_hostextinfo(hostextinfo* hostextinfo_object) { + if (hostextinfo_object != NULL) { + if (hostextinfo_object->host_name!=NULL) free(hostextinfo_object->host_name); + if (hostextinfo_object->notes!=NULL) free(hostextinfo_object->notes); + if (hostextinfo_object->notes_url!=NULL) free(hostextinfo_object->notes_url); + if (hostextinfo_object->action_url!=NULL) free(hostextinfo_object->action_url); + if (hostextinfo_object->icon_image!=NULL) free(hostextinfo_object->icon_image); + if (hostextinfo_object->vrml_image!=NULL) free(hostextinfo_object->vrml_image); + if (hostextinfo_object->statusmap_image!=NULL) free(hostextinfo_object->statusmap_image); + if (hostextinfo_object->icon_image_alt!=NULL) free(hostextinfo_object->icon_image_alt); + if (hostextinfo_object->target_frame!=NULL) free(hostextinfo_object->target_frame); + if (hostextinfo_object->notes_textinfo!=NULL) free(hostextinfo_object->notes_textinfo); + if (hostextinfo_object->action_textinfo!=NULL) free(hostextinfo_object->action_textinfo); + if (hostextinfo_object->notes_icon!=NULL) free(hostextinfo_object->notes_icon); + if (hostextinfo_object->notes_icon_alt!=NULL) free(hostextinfo_object->notes_icon_alt); + if (hostextinfo_object->action_icon!=NULL) free(hostextinfo_object->action_icon); + if (hostextinfo_object->action_icon_alt!=NULL) free(hostextinfo_object->action_icon_alt); + } + } + +void freedata_serviceextinfo(serviceextinfo* serviceextinfo_object) { + if (serviceextinfo_object != NULL) { + if (serviceextinfo_object->host_name!=NULL) free(serviceextinfo_object->host_name); + if (serviceextinfo_object->description!=NULL) free(serviceextinfo_object->description); + if (serviceextinfo_object->notes!=NULL) free(serviceextinfo_object->notes); + if (serviceextinfo_object->notes_url!=NULL) free(serviceextinfo_object->notes_url); + if (serviceextinfo_object->action_url!=NULL) free(serviceextinfo_object->action_url); + if (serviceextinfo_object->icon_image!=NULL) free(serviceextinfo_object->icon_image); + if (serviceextinfo_object->icon_image_alt!=NULL) free(serviceextinfo_object->icon_image_alt); + if (serviceextinfo_object->target_frame!=NULL) free(serviceextinfo_object->target_frame); + if (serviceextinfo_object->notes_textinfo!=NULL) free(serviceextinfo_object->notes_textinfo); + if (serviceextinfo_object->action_textinfo!=NULL) free(serviceextinfo_object->action_textinfo); + if (serviceextinfo_object->notes_icon!=NULL) free(serviceextinfo_object->notes_icon); + if (serviceextinfo_object->notes_icon_alt!=NULL) free(serviceextinfo_object->notes_icon_alt); + if (serviceextinfo_object->action_icon!=NULL) free(serviceextinfo_object->action_icon); + if (serviceextinfo_object->action_icon_alt!=NULL) free(serviceextinfo_object->action_icon_alt); + } + } + +void freedata_hostgroupextinfo(hostgroupextinfo* hostgroupextinfo_object) { + if (hostgroupextinfo_object != NULL) { + if (hostgroupextinfo_object->hostgroup_name!=NULL) free(hostgroupextinfo_object->hostgroup_name); + if (hostgroupextinfo_object->notes!=NULL) free(hostgroupextinfo_object->notes); + if (hostgroupextinfo_object->notes_url!=NULL) free(hostgroupextinfo_object->notes_url); + if (hostgroupextinfo_object->action_url!=NULL) free(hostgroupextinfo_object->action_url); + if (hostgroupextinfo_object->icon_image!=NULL) free(hostgroupextinfo_object->icon_image); + if (hostgroupextinfo_object->icon_image_alt!=NULL) free(hostgroupextinfo_object->icon_image_alt); + if (hostgroupextinfo_object->target_frame!=NULL) free(hostgroupextinfo_object->target_frame); + if (hostgroupextinfo_object->notes_textinfo!=NULL) free(hostgroupextinfo_object->notes_textinfo); + if (hostgroupextinfo_object->action_textinfo!=NULL) free(hostgroupextinfo_object->action_textinfo); + if (hostgroupextinfo_object->notes_icon!=NULL) free(hostgroupextinfo_object->notes_icon); + if (hostgroupextinfo_object->notes_icon_alt!=NULL) free(hostgroupextinfo_object->notes_icon_alt); + if (hostgroupextinfo_object->action_icon!=NULL) free(hostgroupextinfo_object->action_icon); + if (hostgroupextinfo_object->action_icon_alt!=NULL) free(hostgroupextinfo_object->action_icon_alt); + } + } + +void freedata_servicegroupextinfo(servicegroupextinfo* servicegroupextinfo_object) { + if (servicegroupextinfo_object != NULL) { + if (servicegroupextinfo_object->servicegroup_name!=NULL) free(servicegroupextinfo_object->servicegroup_name); + if (servicegroupextinfo_object->notes!=NULL) free(servicegroupextinfo_object->notes); + if (servicegroupextinfo_object->notes_url!=NULL) free(servicegroupextinfo_object->notes_url); + if (servicegroupextinfo_object->action_url!=NULL) free(servicegroupextinfo_object->action_url); + if (servicegroupextinfo_object->icon_image!=NULL) free(servicegroupextinfo_object->icon_image); + if (servicegroupextinfo_object->icon_image_alt!=NULL) free(servicegroupextinfo_object->icon_image_alt); + if (servicegroupextinfo_object->target_frame!=NULL) free(servicegroupextinfo_object->target_frame); + if (servicegroupextinfo_object->notes_textinfo!=NULL) free(servicegroupextinfo_object->notes_textinfo); + if (servicegroupextinfo_object->action_textinfo!=NULL) free(servicegroupextinfo_object->action_textinfo); + if (servicegroupextinfo_object->notes_icon!=NULL) free(servicegroupextinfo_object->notes_icon); + if (servicegroupextinfo_object->notes_icon_alt!=NULL) free(servicegroupextinfo_object->notes_icon_alt); + if (servicegroupextinfo_object->action_icon!=NULL) free(servicegroupextinfo_object->action_icon); + if (servicegroupextinfo_object->action_icon_alt!=NULL) free(servicegroupextinfo_object->action_icon_alt); + } + } + +int free_extended_data(void){ + hostextinfo *this_hostextinfo=NULL; + hostextinfo *next_hostextinfo=NULL; + serviceextinfo *this_serviceextinfo=NULL; + serviceextinfo *next_serviceextinfo=NULL; + hostgroupextinfo *this_hostgroupextinfo=NULL; + hostgroupextinfo *next_hostgroupextinfo=NULL; + servicegroupextinfo *this_servicegroupextinfo=NULL; + servicegroupextinfo *next_servicegroupextinfo=NULL; + +#ifdef DEBUG0 + printf("free_extended_data() start\n"); +#endif + + /* free memory for the extended host info list */ + for(this_hostextinfo=hostextinfo_list;this_hostextinfo!=NULL;this_hostextinfo=next_hostextinfo){ + next_hostextinfo=this_hostextinfo->next; + freedata_hostextinfo(this_hostextinfo); + free(this_hostextinfo); + } + +#ifdef DEBUG1 + printf("\thostextinfo_list freed\n"); +#endif + + /* free hashlist and reset pointers */ + free(hostextinfo_hashlist); + hostextinfo_hashlist=NULL; + hostextinfo_list=NULL; + + /* free memory for the extended service info list */ + for(this_serviceextinfo=serviceextinfo_list;this_serviceextinfo!=NULL;this_serviceextinfo=next_serviceextinfo){ + next_serviceextinfo=this_serviceextinfo->next; + freedata_serviceextinfo(this_serviceextinfo); + free(this_serviceextinfo); + } + +#ifdef DEBUG1 + printf("\tserviceextinfo_list freed\n"); +#endif + + /* free hashlist and reset pointers */ + free(serviceextinfo_hashlist); + serviceextinfo_hashlist=NULL; + serviceextinfo_list=NULL; + + /* free memory for the extended hostgroup info list */ + for(this_hostgroupextinfo=hostgroupextinfo_list;this_hostgroupextinfo!=NULL;this_hostgroupextinfo=next_hostgroupextinfo){ + next_hostgroupextinfo=this_hostgroupextinfo->next; + freedata_hostgroupextinfo(this_hostgroupextinfo); + free(this_hostgroupextinfo); + } + +#ifdef DEBUG1 + printf("\thostgroupextinfo_list freed\n"); +#endif + + /* free hashlist and reset pointers */ + free(hostgroupextinfo_hashlist); + hostgroupextinfo_hashlist=NULL; + hostgroupextinfo_list=NULL; + + /* free memory for the extended servicegroup info list */ + for(this_servicegroupextinfo=servicegroupextinfo_list;this_servicegroupextinfo!=NULL;this_servicegroupextinfo=next_servicegroupextinfo){ + next_servicegroupextinfo=this_servicegroupextinfo->next; + freedata_servicegroupextinfo(this_servicegroupextinfo); + free(this_servicegroupextinfo); + } + +#ifdef DEBUG1 + printf("\tservicegroupextinfo_list freed\n"); +#endif + + /* free hashlist and reset pointers */ + free(servicegroupextinfo_hashlist); + servicegroupextinfo_hashlist=NULL; + servicegroupextinfo_list=NULL; #ifdef DEBUG0 printf("free_extended_data() end\n"); @@ -6167,3 +6998,4 @@ return OK; } +#endif /* SUPPORT_GROUPEXTINFO */ --- nagios-2.8.orig/common/statusdata.c 2005-11-16 00:49:35.000000000 -0800 +++ nagios-2.8/common/statusdata.c 2007-03-28 14:18:31.000000000 -0700 @@ -191,7 +191,12 @@ /* reads in all status data */ +#ifndef SUPPORT_GROUPEXTINFO int read_status_data(char *config_file,int options){ +#else +int read_status_data(char* config_file,unsigned long options){ +#endif // SUPPORT_GROUPEXTINFO + int result=OK; /**** IMPLEMENTATION-SPECIFIC CALLS ****/ --- nagios-2.8.orig/xdata/xodtemplate.h 2005-11-16 00:49:35.000000000 -0800 +++ nagios-2.8/xdata/xodtemplate.h 2007-03-28 14:18:31.000000000 -0700 @@ -1,3 +1,4 @@ + /***************************************************************************** * * XODTEMPLATE.H - Template-based object configuration data header file @@ -51,6 +52,10 @@ #define XODTEMPLATE_SERVICEEXTINFO 14 #define XODTEMPLATE_SERVICEGROUP 15 +#ifdef SUPPORT_GROUPEXTINFO +#define XODTEMPLATE_HOSTGROUPEXTINFO 16 +#define XODTEMPLATE_SERVICEGROUPEXTINFO 17 +#endif // SUPPORT_GROUPEXTINFO /********** STRUCTURE DEFINITIONS **********/ @@ -462,6 +467,15 @@ char *notes; char *notes_url; char *action_url; +#ifdef SUPPORT_GROUPEXTINFO + char *target_frame; + char *notes_textinfo; + char *action_textinfo; + char *notes_icon; + char *notes_icon_alt; + char *action_icon; + char *action_icon_alt; +#endif // SUPPORT_GROUPEXTINFO char *icon_image; char *icon_image_alt; char *vrml_image; @@ -494,6 +508,15 @@ char *notes; char *notes_url; char *action_url; +#ifdef SUPPORT_GROUPEXTINFO + char *target_frame; + char *notes_textinfo; + char *action_textinfo; + char *notes_icon; + char *notes_icon_alt; + char *action_icon; + char *action_icon_alt; +#endif // SUPPORT_GROUPEXTINFO char *icon_image; char *icon_image_alt; @@ -502,6 +525,61 @@ struct xodtemplate_serviceextinfo_struct *next; }xodtemplate_serviceextinfo; +#ifdef SUPPORT_GROUPEXTINFO + +/* HOSTGROUPEXTINFO TEMPLATE STRUCTURE */ +typedef struct xodtemplate_hostgroupextinfo_struct{ + char *template; + char *name; + int _config_file; + int _start_line; + + char *hostgroup_name; + char *notes; + char *notes_url; + char *action_url; + char *target_frame; + char *notes_textinfo; + char *action_textinfo; + char *notes_icon; + char *notes_icon_alt; + char *action_icon; + char *action_icon_alt; + char *icon_image; + char *icon_image_alt; + + int has_been_resolved; + int register_object; + struct xodtemplate_hostgroupextinfo_struct *next; + }xodtemplate_hostgroupextinfo; + +/* SERVICEGROUPEXTINFO TEMPLATE STRUCTURE */ +typedef struct xodtemplate_servicegroupextinfo_struct{ + char *template; + char *name; + int _config_file; + int _start_line; + + char *servicegroup_name; + char *notes; + char *notes_url; + char *action_url; + char *target_frame; + char *notes_textinfo; + char *action_textinfo; + char *notes_icon; + char *notes_icon_alt; + char *action_icon; + char *action_icon_alt; + char *icon_image; + char *icon_image_alt; + + int has_been_resolved; + int register_object; + struct xodtemplate_servicegroupextinfo_struct *next; + }xodtemplate_servicegroupextinfo; + +#endif // SUPPORT_GROUPEXTINFO /* CONTACT LIST STRUCTURE */ typedef struct xodtemplate_contactlist_struct{ @@ -537,10 +615,17 @@ /********* FUNCTION DEFINITIONS **********/ +#ifndef SUPPORT_GROUPEXTINFO int xodtemplate_read_config_data(char *,int,int); /* top-level routine processes all config files */ int xodtemplate_grab_config_info(char *); /* grabs variables from main config file */ int xodtemplate_process_config_file(char *,int); /* process data in a specific config file */ int xodtemplate_process_config_dir(char *,int); /* process all files in a specific config directory */ +#else +int xodtemplate_read_config_data(char *,unsigned long,int); /* top-level routine processes all config files */ +int xodtemplate_grab_config_info(char *); /* grabs variables from main config file */ +int xodtemplate_process_config_file(char *,unsigned long); /* process data in a specific config file */ +int xodtemplate_process_config_dir(char *,unsigned long); /* process all files in a specific config directory */ +#endif // SUPPORT_GROUPEXTINFO #ifdef NSCORE char *xodtemplate_config_file_name(int); /* returns the name of a numbered config file */ @@ -567,9 +652,15 @@ int xodtemplate_free_servicelist(xodtemplate_servicelist *); void xodtemplate_remove_servicelist_item(xodtemplate_servicelist *,xodtemplate_servicelist **); +#ifndef SUPPORT_GROUPEXTINFO int xodtemplate_begin_object_definition(char *,int,int,int); int xodtemplate_add_object_property(char *,int); int xodtemplate_end_object_definition(int); +#else +int xodtemplate_begin_object_definition(char *,unsigned long,int,int); +int xodtemplate_add_object_property(char *,unsigned long); +int xodtemplate_end_object_definition(unsigned long); +#endif // SUPPORT_GROUPEXTINFO int xodtemplate_register_objects(void); int xodtemplate_free_memory(void); @@ -593,6 +684,10 @@ int xodtemplate_duplicate_servicedependency(xodtemplate_servicedependency *,char *,char *,char *,char *); int xodtemplate_duplicate_hostextinfo(xodtemplate_hostextinfo *,char *); int xodtemplate_duplicate_serviceextinfo(xodtemplate_serviceextinfo *,char *); +#ifdef SUPPORT_GROUPEXTINFO +int xodtemplate_duplicate_hostgroupextinfo(xodtemplate_hostgroupextinfo *,char *); +int xodtemplate_duplicate_servicegroupextinfo(xodtemplate_servicegroupextinfo *,char *); +#endif int xodtemplate_recombobulate_contactgroups(void); int xodtemplate_recombobulate_hostgroups(void); @@ -612,6 +707,10 @@ int xodtemplate_resolve_hostescalation(xodtemplate_hostescalation *); int xodtemplate_resolve_hostextinfo(xodtemplate_hostextinfo *); int xodtemplate_resolve_serviceextinfo(xodtemplate_serviceextinfo *); +#ifdef SUPPORT_GROUPEXTINFO +int xodtemplate_resolve_hostgroupextinfo(xodtemplate_hostgroupextinfo *); +int xodtemplate_resolve_servicegroupextinfo(xodtemplate_servicegroupextinfo *); +#endif int xodtemplate_sort_timeperiods(void); int xodtemplate_sort_commands(void); @@ -627,6 +726,10 @@ int xodtemplate_sort_hostescalations(void); int xodtemplate_sort_hostextinfo(void); int xodtemplate_sort_serviceextinfo(void); +#ifdef SUPPORT_GROUPEXTINFO +int xodtemplate_sort_hostgroupextinfo(void); +int xodtemplate_sort_servicegroupextinfo(void); +#endif xodtemplate_timeperiod *xodtemplate_find_timeperiod(char *); xodtemplate_command *xodtemplate_find_command(char *); @@ -648,6 +751,10 @@ xodtemplate_hostescalation *xodtemplate_find_hostescalation(char *); xodtemplate_hostextinfo *xodtemplate_find_hostextinfo(char *); xodtemplate_serviceextinfo *xodtemplate_find_serviceextinfo(char *); +#ifdef SUPPORT_GROUPEXTINFO +xodtemplate_hostgroupextinfo *xodtemplate_find_hostgroupextinfo(char *); +xodtemplate_servicegroupextinfo *xodtemplate_find_servicegroupextinfo(char *); +#endif // SUPPORT_GROUPEXTINFO #endif int xodtemplate_register_timeperiod(xodtemplate_timeperiod *); @@ -664,7 +771,10 @@ int xodtemplate_register_hostescalation(xodtemplate_hostescalation *); int xodtemplate_register_hostextinfo(xodtemplate_hostextinfo *); int xodtemplate_register_serviceextinfo(xodtemplate_serviceextinfo *); - +#ifdef SUPPORT_GROUPEXTINFO +int xodtemplate_register_hostgroupextinfo(xodtemplate_hostgroupextinfo *); +int xodtemplate_register_servicegroupextinfo(xodtemplate_servicegroupextinfo *); +#endif // SUPPORT_GROUPEXTINFO #endif --- nagios-2.8.orig/xdata/xodtemplate.c 2007-01-19 14:02:01.000000000 -0800 +++ nagios-2.8/xdata/xodtemplate.c 2007-03-28 14:18:31.000000000 -0700 @@ -87,6 +87,10 @@ xodtemplate_hostescalation *xodtemplate_hostescalation_list=NULL; xodtemplate_hostextinfo *xodtemplate_hostextinfo_list=NULL; xodtemplate_serviceextinfo *xodtemplate_serviceextinfo_list=NULL; +#ifdef SUPPORT_GROUPEXTINFO +xodtemplate_hostgroupextinfo *xodtemplate_hostgroupextinfo_list=NULL; +xodtemplate_servicegroupextinfo *xodtemplate_servicegroupextinfo_list=NULL; +#endif void *xodtemplate_current_object=NULL; int xodtemplate_current_object_type=XODTEMPLATE_NONE; @@ -103,7 +107,11 @@ /******************************************************************/ /* process all config files - both core and CGIs pass in name of main config file */ +#ifndef SUPPORT_GROUPEXTINFO int xodtemplate_read_config_data(char *main_config_file,int options,int cache){ +#else +int xodtemplate_read_config_data(char *main_config_file,unsigned long options,int cache){ +#endif // SUPPORT_GROUPEXTINFO #ifdef NSCORE char config_file[MAX_FILENAME_LENGTH]; char *input=NULL; @@ -142,6 +150,10 @@ xodtemplate_hostescalation_list=NULL; xodtemplate_hostextinfo_list=NULL; xodtemplate_serviceextinfo_list=NULL; +#ifdef SUPPORT_GROUPEXTINFO + xodtemplate_hostgroupextinfo_list=NULL; + xodtemplate_servicegroupextinfo_list=NULL; +#endif // SUPPORT_GROUPEXTINFO xodtemplate_current_object=NULL; xodtemplate_current_object_type=XODTEMPLATE_NONE; @@ -349,7 +361,11 @@ /* process all files in a specific config directory */ +#ifndef SUPPORT_GROUPEXTINFO int xodtemplate_process_config_dir(char *dirname, int options){ +#else +int xodtemplate_process_config_dir(char *dirname, unsigned long options){ +#endif // SUPPORT_GROUPEXTINFO char file[MAX_FILENAME_LENGTH]; DIR *dirp; struct dirent *dirfile; @@ -527,7 +543,11 @@ /* process data in a specific config file */ +#ifndef SUPPORT_GROUPEXTINFO int xodtemplate_process_config_file(char *filename, int options){ +#else +int xodtemplate_process_config_file(char *filename, unsigned long options){ +#endif // SUPPORT_GROUPEXTINFO mmapfile *thefile; char *input=NULL; register int in_definition=FALSE; @@ -621,7 +641,11 @@ } /* check validity of object type */ +#ifndef SUPPORT_GROUPEXTINFO if(strcmp(input,"timeperiod") && strcmp(input,"command") && strcmp(input,"contact") && strcmp(input,"contactgroup") && strcmp(input,"host") && strcmp(input,"hostgroup") && strcmp(input,"servicegroup") && strcmp(input,"service") && strcmp(input,"servicedependency") && strcmp(input,"serviceescalation") && strcmp(input,"hostgroupescalation") && strcmp(input,"hostdependency") && strcmp(input,"hostescalation") && strcmp(input,"hostextinfo") && strcmp(input,"serviceextinfo")){ +#else + if(strcmp(input,"timeperiod") && strcmp(input,"command") && strcmp(input,"contact") && strcmp(input,"contactgroup") && strcmp(input,"host") && strcmp(input,"hostgroup") && strcmp(input,"servicegroup") && strcmp(input,"service") && strcmp(input,"servicedependency") && strcmp(input,"serviceescalation") && strcmp(input,"hostgroupescalation") && strcmp(input,"hostdependency") && strcmp(input,"hostescalation") && strcmp(input,"hostextinfo") && strcmp(input,"serviceextinfo") && strcmp(input,"hostgroupextinfo") && strcmp(input,"servicegroupextinfo")){ +#endif // SUPPORT_GROUPEXTINFO #ifdef NSCORE snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Invalid object definition type '%s' in file '%s' on line %d.\n",input,filename,current_line); temp_buffer[sizeof(temp_buffer)-1]='\x0'; @@ -777,7 +801,11 @@ /******************************************************************/ /* starts a new object definition */ +#ifndef SUPPORT_GROUPEXTINFO int xodtemplate_begin_object_definition(char *input, int options, int config_file, int start_line){ +#else +int xodtemplate_begin_object_definition(char *input, unsigned long options, int config_file, int start_line){ +#endif // SUPPORT_GROUPEXTINFO int result=OK; xodtemplate_timeperiod *new_timeperiod; xodtemplate_command *new_command; @@ -793,6 +821,10 @@ xodtemplate_hostescalation *new_hostescalation; xodtemplate_hostextinfo *new_hostextinfo; xodtemplate_serviceextinfo *new_serviceextinfo; +#ifdef SUPPORT_GROUPEXTINFO + xodtemplate_hostgroupextinfo *new_hostgroupextinfo; + xodtemplate_servicegroupextinfo *new_servicegroupextinfo; +#endif // SUPPORT_GROUPEXTINFO int x; #ifdef DEBUG0 @@ -827,6 +859,12 @@ xodtemplate_current_object_type=XODTEMPLATE_HOSTEXTINFO; else if(!strcmp(input,"serviceextinfo")) xodtemplate_current_object_type=XODTEMPLATE_SERVICEEXTINFO; +#ifdef SUPPORT_GROUPEXTINFO + else if(!strcmp(input,"hostgroupextinfo")) + xodtemplate_current_object_type=XODTEMPLATE_HOSTGROUPEXTINFO; + else if(!strcmp(input,"servicegroupextinfo")) + xodtemplate_current_object_type=XODTEMPLATE_SERVICEGROUPEXTINFO; +#endif // SUPPORT_GROUPEXTINFO else return ERROR; @@ -889,6 +927,16 @@ if(!(options & READ_SERVICEEXTINFO)) return OK; break; +#ifdef SUPPORT_GROUPEXTINFO + case XODTEMPLATE_HOSTGROUPEXTINFO: + if(!(options & READ_HOSTGROUPEXTINFO)) + return OK; + break; + case XODTEMPLATE_SERVICEGROUPEXTINFO: + if(!(options & READ_SERVICEGROUPEXTINFO)) + return OK; + break; +#endif // SUPPORT_GROUPEXTINFO default: return ERROR; break; @@ -1456,6 +1504,15 @@ new_hostextinfo->notes=NULL; new_hostextinfo->notes_url=NULL; new_hostextinfo->action_url=NULL; +#ifdef SUPPORT_GROUPEXTINFO + new_hostextinfo->target_frame=NULL; + new_hostextinfo->notes_textinfo=NULL; + new_hostextinfo->action_textinfo=NULL; + new_hostextinfo->notes_icon=NULL; + new_hostextinfo->notes_icon_alt=NULL; + new_hostextinfo->action_icon=NULL; + new_hostextinfo->action_icon_alt=NULL; +#endif // SUPPORT_GROUPEXTINFO new_hostextinfo->icon_image=NULL; new_hostextinfo->icon_image_alt=NULL; new_hostextinfo->vrml_image=NULL; @@ -1499,6 +1556,15 @@ new_serviceextinfo->notes=NULL; new_serviceextinfo->notes_url=NULL; new_serviceextinfo->action_url=NULL; +#ifdef SUPPORT_GROUPEXTINFO + new_serviceextinfo->target_frame=NULL; + new_serviceextinfo->notes_textinfo=NULL; + new_serviceextinfo->action_textinfo=NULL; + new_serviceextinfo->notes_icon=NULL; + new_serviceextinfo->notes_icon_alt=NULL; + new_serviceextinfo->action_icon=NULL; + new_serviceextinfo->action_icon_alt=NULL; +#endif // SUPPORT_GROUPEXTINFO new_serviceextinfo->icon_image=NULL; new_serviceextinfo->icon_image_alt=NULL; new_serviceextinfo->has_been_resolved=FALSE; @@ -1514,6 +1580,88 @@ xodtemplate_current_object=xodtemplate_serviceextinfo_list; break; +#ifdef SUPPORT_GROUPEXTINFO + + case XODTEMPLATE_HOSTGROUPEXTINFO: + + /* allocate memory */ + new_hostgroupextinfo=(xodtemplate_hostgroupextinfo *)malloc(sizeof(xodtemplate_hostgroupextinfo)); + if(new_hostgroupextinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info\n"); +#endif + return ERROR; + } + + new_hostgroupextinfo->template=NULL; + new_hostgroupextinfo->name=NULL; + new_hostgroupextinfo->hostgroup_name=NULL; + new_hostgroupextinfo->notes=NULL; + new_hostgroupextinfo->notes_url=NULL; + new_hostgroupextinfo->action_url=NULL; + new_hostgroupextinfo->target_frame=NULL; + new_hostgroupextinfo->notes_textinfo=NULL; + new_hostgroupextinfo->action_textinfo=NULL; + new_hostgroupextinfo->notes_icon=NULL; + new_hostgroupextinfo->notes_icon_alt=NULL; + new_hostgroupextinfo->action_icon=NULL; + new_hostgroupextinfo->action_icon_alt=NULL; + new_hostgroupextinfo->icon_image=NULL; + new_hostgroupextinfo->icon_image_alt=NULL; + new_hostgroupextinfo->has_been_resolved=FALSE; + new_hostgroupextinfo->register_object=TRUE; + new_hostgroupextinfo->_config_file=config_file; + new_hostgroupextinfo->_start_line=start_line; + + /* add new extended service info to head of list in memory */ + new_hostgroupextinfo->next=xodtemplate_hostgroupextinfo_list; + xodtemplate_hostgroupextinfo_list=new_hostgroupextinfo; + + /* update current object pointer */ + xodtemplate_current_object=xodtemplate_hostgroupextinfo_list; + break; + + case XODTEMPLATE_SERVICEGROUPEXTINFO: + + /* allocate memory */ + new_servicegroupextinfo=(xodtemplate_servicegroupextinfo *)malloc(sizeof(xodtemplate_servicegroupextinfo)); + if(new_servicegroupextinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info\n"); +#endif + return ERROR; + } + + new_servicegroupextinfo->template=NULL; + new_servicegroupextinfo->name=NULL; + new_servicegroupextinfo->servicegroup_name=NULL; + new_servicegroupextinfo->notes=NULL; + new_servicegroupextinfo->notes_url=NULL; + new_servicegroupextinfo->action_url=NULL; + new_servicegroupextinfo->target_frame=NULL; + new_servicegroupextinfo->notes_textinfo=NULL; + new_servicegroupextinfo->action_textinfo=NULL; + new_servicegroupextinfo->notes_icon=NULL; + new_servicegroupextinfo->notes_icon_alt=NULL; + new_servicegroupextinfo->action_icon=NULL; + new_servicegroupextinfo->action_icon_alt=NULL; + new_servicegroupextinfo->icon_image=NULL; + new_servicegroupextinfo->icon_image_alt=NULL; + new_servicegroupextinfo->has_been_resolved=FALSE; + new_servicegroupextinfo->register_object=TRUE; + new_servicegroupextinfo->_config_file=config_file; + new_servicegroupextinfo->_start_line=start_line; + + /* add new extended service info to head of list in memory */ + new_servicegroupextinfo->next=xodtemplate_servicegroupextinfo_list; + xodtemplate_servicegroupextinfo_list=new_servicegroupextinfo; + + /* update current object pointer */ + xodtemplate_current_object=xodtemplate_servicegroupextinfo_list; + break; + +#endif // SUPPORT_GROUPEXTINFO + default: return ERROR; break; @@ -1529,7 +1677,11 @@ /* adds a property to an object definition */ +#ifndef SUPPORT_GROUPEXTINFO int xodtemplate_add_object_property(char *input, int options){ +#else +int xodtemplate_add_object_property(char *input, unsigned long options){ +#endif // SUPPORT_GROUPEXTINFO int result=OK; char *variable=NULL; char *value=NULL; @@ -1548,6 +1700,10 @@ xodtemplate_hostescalation *temp_hostescalation; xodtemplate_hostextinfo *temp_hostextinfo; xodtemplate_serviceextinfo *temp_serviceextinfo; +#ifdef SUPPORT_GROUPEXTINFO + xodtemplate_hostgroupextinfo *temp_hostgroupextinfo; + xodtemplate_servicegroupextinfo *temp_servicegroupextinfo; +#endif // SUPPORT_GROUPEXTINFO register int x; register int y; register int len; @@ -1618,6 +1774,16 @@ if(!(options & READ_SERVICEEXTINFO)) return OK; break; +#ifdef SUPPORT_GROUPEXTINFO + case XODTEMPLATE_HOSTGROUPEXTINFO: + if(!(options & READ_HOSTGROUPEXTINFO)) + return OK; + break; + case XODTEMPLATE_SERVICEGROUPEXTINFO: + if(!(options & READ_SERVICEGROUPEXTINFO)) + return OK; + break; +#endif // SUPPORT_GROUPEXTINFO default: return ERROR; break; @@ -3465,6 +3631,72 @@ return ERROR; } } +#ifdef SUPPORT_GROUPEXTINFO + else if(!strcmp(variable,"target_frame")){ + temp_hostextinfo->target_frame=strdup(value); + if(temp_hostextinfo->target_frame==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended host info target_frame.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_textinfo")){ + temp_hostextinfo->notes_textinfo=strdup(value); + if(temp_hostextinfo->notes_textinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended host info notes_textinfo.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_textinfo")){ + temp_hostextinfo->action_textinfo=strdup(value); + if(temp_hostextinfo->action_textinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended host info action_textinfo.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_icon")){ + temp_hostextinfo->notes_icon=strdup(value); + if(temp_hostextinfo->notes_icon==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended host info notes_icon.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_icon_alt")){ + temp_hostextinfo->notes_icon_alt=strdup(value); + if(temp_hostextinfo->notes_icon_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended host info notes_icon_alt.\n"); +#endif + return ERROR; + } + } + + else if(!strcmp(variable,"action_icon")){ + temp_hostextinfo->action_icon=strdup(value); + if(temp_hostextinfo->action_icon==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended host info action_icon.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_icon_alt")){ + temp_hostextinfo->action_icon_alt=strdup(value); + if(temp_hostextinfo->action_icon_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended host info action_icon_alt.\n"); +#endif + return ERROR; + } + } +#endif // SUPPORT_GROUPEXTINFO else if(!strcmp(variable,"icon_image")){ temp_hostextinfo->icon_image=strdup(value); if(temp_hostextinfo->icon_image==NULL){ @@ -3656,6 +3888,72 @@ return ERROR; } } +#ifdef SUPPORT_GROUPEXTINFO + else if(!strcmp(variable,"target_frame")){ + temp_serviceextinfo->target_frame=strdup(value); + if(temp_serviceextinfo->target_frame==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended service info target_frame.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_textinfo")){ + temp_serviceextinfo->notes_textinfo=strdup(value); + if(temp_serviceextinfo->notes_textinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended service info notes_textinfo.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_textinfo")){ + temp_serviceextinfo->action_textinfo=strdup(value); + if(temp_serviceextinfo->action_textinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended service info action_textinfo.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_icon")){ + temp_serviceextinfo->notes_icon=strdup(value); + if(temp_serviceextinfo->notes_icon==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended service info notes_icon.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_icon_alt")){ + temp_serviceextinfo->notes_icon_alt=strdup(value); + if(temp_serviceextinfo->notes_icon_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended service info notes_icon_alt.\n"); +#endif + return ERROR; + } + } + + else if(!strcmp(variable,"action_icon")){ + temp_serviceextinfo->action_icon=strdup(value); + if(temp_serviceextinfo->action_icon==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended service info action_icon.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_icon_alt")){ + temp_serviceextinfo->action_icon_alt=strdup(value); + if(temp_serviceextinfo->action_icon_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended service info action_icon_alt.\n"); +#endif + return ERROR; + } + } +#endif // SUPPORT_GROUPEXTINFO else if(!strcmp(variable,"icon_image")){ temp_serviceextinfo->icon_image=strdup(value); if(temp_serviceextinfo->icon_image==NULL){ @@ -3669,16 +3967,344 @@ temp_serviceextinfo->icon_image_alt=strdup(value); if(temp_serviceextinfo->icon_image_alt==NULL){ #ifdef DEBUG1 - printf("Error: Could not allocate memory for extended service info icon_image_alt.\n"); + printf("Error: Could not allocate memory for extended service info icon_image_alt.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"register")) + temp_serviceextinfo->register_object=(atoi(value)>0)?TRUE:FALSE; + else{ +#ifdef NSCORE + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Invalid serviceextinfo object directive '%s'.\n",variable); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return ERROR; + } + + break; + +#ifdef SUPPORT_GROUPEXTINFO + + case XODTEMPLATE_HOSTGROUPEXTINFO: + + temp_hostgroupextinfo=xodtemplate_hostgroupextinfo_list; + + if(!strcmp(variable,"use")){ + temp_hostgroupextinfo->template=strdup(value); + if(temp_hostgroupextinfo->template==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info template.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"name")){ + +#ifdef NSCORE + /* check for duplicates */ + if(xodtemplate_find_hostgroupextinfo(value)!=NULL){ + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Duplicate definition found for extended hostgroup info '%s' (config file '%s', starting on line %d)\n",value,xodtemplate_config_file_name(temp_hostgroupextinfo->_config_file),temp_hostgroupextinfo->_start_line); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_WARNING,TRUE); + } +#endif + + temp_hostgroupextinfo->name=strdup(value); + if(temp_hostgroupextinfo->name==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info name.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"hostgroup_name")){ + temp_hostgroupextinfo->hostgroup_name=strdup(value); + if(temp_hostgroupextinfo->hostgroup_name==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info hostgroup_name.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes")){ + temp_hostgroupextinfo->notes=strdup(value); + if(temp_hostgroupextinfo->notes==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info notes.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_url")){ + temp_hostgroupextinfo->notes_url=strdup(value); + if(temp_hostgroupextinfo->notes_url==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info notes_url.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_url")){ + temp_hostgroupextinfo->action_url=strdup(value); + if(temp_hostgroupextinfo->action_url==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info action_url.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"target_frame")){ + temp_hostgroupextinfo->target_frame=strdup(value); + if(temp_hostgroupextinfo->target_frame==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info target_frame.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_textinfo")){ + temp_hostgroupextinfo->notes_textinfo=strdup(value); + if(temp_hostgroupextinfo->notes_textinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info notes_textinfo.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_textinfo")){ + temp_hostgroupextinfo->action_textinfo=strdup(value); + if(temp_hostgroupextinfo->action_textinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info action_textinfo.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_icon")){ + temp_hostgroupextinfo->notes_icon=strdup(value); + if(temp_hostgroupextinfo->notes_icon==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info notes_icon.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_icon_alt")){ + temp_hostgroupextinfo->notes_icon_alt=strdup(value); + if(temp_hostgroupextinfo->notes_icon_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info notes_icon_alt.\n"); +#endif + return ERROR; + } + } + + else if(!strcmp(variable,"action_icon")){ + temp_hostgroupextinfo->action_icon=strdup(value); + if(temp_hostgroupextinfo->action_icon==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info action_icon.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_icon_alt")){ + temp_hostgroupextinfo->action_icon_alt=strdup(value); + if(temp_hostgroupextinfo->action_icon_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info action_icon_alt.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"icon_image")){ + temp_hostgroupextinfo->icon_image=strdup(value); + if(temp_hostgroupextinfo->icon_image==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info icon_image.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"icon_image_alt")){ + temp_hostgroupextinfo->icon_image_alt=strdup(value); + if(temp_hostgroupextinfo->icon_image_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended hostgroup info icon_image_alt.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"register")) + temp_hostgroupextinfo->register_object=(atoi(value)>0)?TRUE:FALSE; + else{ +#ifdef NSCORE + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Invalid hostgroupextinfo object directive '%s'.\n",variable); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return ERROR; + } + + break; + + case XODTEMPLATE_SERVICEGROUPEXTINFO: + + temp_servicegroupextinfo=xodtemplate_servicegroupextinfo_list; + + if(!strcmp(variable,"use")){ + temp_servicegroupextinfo->template=strdup(value); + if(temp_servicegroupextinfo->template==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info template.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"name")){ + +#ifdef NSCORE + /* check for duplicates */ + if(xodtemplate_find_servicegroupextinfo(value)!=NULL){ + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Duplicate definition found for extended servicegroup info '%s' (config file '%s', starting on line %d)\n",value,xodtemplate_config_file_name(temp_servicegroupextinfo->_config_file),temp_servicegroupextinfo->_start_line); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_WARNING,TRUE); + } +#endif + + temp_servicegroupextinfo->name=strdup(value); + if(temp_servicegroupextinfo->name==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info name.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"servicegroup_name")){ + temp_servicegroupextinfo->servicegroup_name=strdup(value); + if(temp_servicegroupextinfo->servicegroup_name==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info servicegroup_name.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes")){ + temp_servicegroupextinfo->notes=strdup(value); + if(temp_servicegroupextinfo->notes==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info notes.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_url")){ + temp_servicegroupextinfo->notes_url=strdup(value); + if(temp_servicegroupextinfo->notes_url==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info notes_url.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_url")){ + temp_servicegroupextinfo->action_url=strdup(value); + if(temp_servicegroupextinfo->action_url==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info action_url.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"target_frame")){ + temp_servicegroupextinfo->target_frame=strdup(value); + if(temp_servicegroupextinfo->target_frame==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info target_frame.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_textinfo")){ + temp_servicegroupextinfo->notes_textinfo=strdup(value); + if(temp_servicegroupextinfo->notes_textinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info notes_textinfo.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_textinfo")){ + temp_servicegroupextinfo->action_textinfo=strdup(value); + if(temp_servicegroupextinfo->action_textinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info action_textinfo.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_icon")){ + temp_servicegroupextinfo->notes_icon=strdup(value); + if(temp_servicegroupextinfo->notes_icon==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info notes_icon.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"notes_icon_alt")){ + temp_servicegroupextinfo->notes_icon_alt=strdup(value); + if(temp_servicegroupextinfo->notes_icon_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info notes_icon_alt.\n"); +#endif + return ERROR; + } + } + + else if(!strcmp(variable,"action_icon")){ + temp_servicegroupextinfo->action_icon=strdup(value); + if(temp_servicegroupextinfo->action_icon==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info action_icon.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"action_icon_alt")){ + temp_servicegroupextinfo->action_icon_alt=strdup(value); + if(temp_servicegroupextinfo->action_icon_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info action_icon_alt.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"icon_image")){ + temp_servicegroupextinfo->icon_image=strdup(value); + if(temp_servicegroupextinfo->icon_image==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info icon_image.\n"); +#endif + return ERROR; + } + } + else if(!strcmp(variable,"icon_image_alt")){ + temp_servicegroupextinfo->icon_image_alt=strdup(value); + if(temp_servicegroupextinfo->icon_image_alt==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for extended servicegroup info icon_image_alt.\n"); #endif return ERROR; } } else if(!strcmp(variable,"register")) - temp_serviceextinfo->register_object=(atoi(value)>0)?TRUE:FALSE; + temp_servicegroupextinfo->register_object=(atoi(value)>0)?TRUE:FALSE; else{ #ifdef NSCORE - snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Invalid serviceextinfo object directive '%s'.\n",variable); + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Invalid servicegroupextinfo object directive '%s'.\n",variable); temp_buffer[sizeof(temp_buffer)-1]='\x0'; write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE); #endif @@ -3687,6 +4313,8 @@ break; +#endif // SUPPORT_GROUPEXTINFO + default: return ERROR; break; @@ -3706,7 +4334,11 @@ /* completes an object definition */ +#ifndef SUPPORT_GROUPEXTINFO int xodtemplate_end_object_definition(int options){ +#else +int xodtemplate_end_object_definition(unsigned long options){ +#endif // SUPPORT_GROUPEXTINFO int result=OK; #ifdef DEBUG0 @@ -5183,6 +5815,15 @@ new_hostextinfo->notes=NULL; new_hostextinfo->notes_url=NULL; new_hostextinfo->action_url=NULL; +#ifdef SUPPORT_GROUPEXTINFO + new_hostextinfo->target_frame = NULL; + new_hostextinfo->action_textinfo = NULL; + new_hostextinfo->notes_textinfo = NULL; + new_hostextinfo->action_icon = NULL; + new_hostextinfo->action_icon_alt = NULL; + new_hostextinfo->notes_icon = NULL; + new_hostextinfo->notes_icon_alt = NULL; +#endif // SUPPORT_GROUPEXTINFO new_hostextinfo->icon_image=NULL; new_hostextinfo->icon_image_alt=NULL; new_hostextinfo->vrml_image=NULL; @@ -5201,6 +5842,22 @@ new_hostextinfo->notes_url=strdup(this_hostextinfo->notes_url); if(this_hostextinfo->action_url!=NULL) new_hostextinfo->action_url=strdup(this_hostextinfo->action_url); +#ifdef SUPPORT_GROUPEXTINFO + if(this_hostextinfo->target_frame!=NULL) + new_hostextinfo->target_frame=strdup(this_hostextinfo->target_frame); + if(this_hostextinfo->notes_textinfo!=NULL) + new_hostextinfo->notes_textinfo=strdup(this_hostextinfo->notes_textinfo); + if(this_hostextinfo->action_textinfo!=NULL) + new_hostextinfo->action_textinfo=strdup(this_hostextinfo->action_textinfo); + if(this_hostextinfo->notes_icon!=NULL) + new_hostextinfo->notes_icon=strdup(this_hostextinfo->notes_icon); + if(this_hostextinfo->notes_icon_alt!=NULL) + new_hostextinfo->notes_icon_alt=strdup(this_hostextinfo->notes_icon_alt); + if(this_hostextinfo->action_icon!=NULL) + new_hostextinfo->action_icon=strdup(this_hostextinfo->action_icon); + if(this_hostextinfo->action_icon_alt!=NULL) + new_hostextinfo->action_icon=strdup(this_hostextinfo->action_icon_alt); +#endif // SUPPORT_GROUPEXTINFO if(this_hostextinfo->icon_image!=NULL) new_hostextinfo->icon_image=strdup(this_hostextinfo->icon_image); if(this_hostextinfo->icon_image_alt!=NULL) @@ -5280,6 +5937,22 @@ new_serviceextinfo->notes_url=strdup(this_serviceextinfo->notes_url); if(this_serviceextinfo->action_url!=NULL) new_serviceextinfo->action_url=strdup(this_serviceextinfo->action_url); +#ifdef SUPPORT_GROUPEXTINFO + if(this_serviceextinfo->target_frame!=NULL) + new_serviceextinfo->target_frame=strdup(this_serviceextinfo->target_frame); + if(this_serviceextinfo->notes_textinfo!=NULL) + new_serviceextinfo->notes_textinfo=strdup(this_serviceextinfo->notes_textinfo); + if(this_serviceextinfo->action_textinfo!=NULL) + new_serviceextinfo->action_textinfo=strdup(this_serviceextinfo->action_textinfo); + if(this_serviceextinfo->notes_icon!=NULL) + new_serviceextinfo->notes_icon=strdup(this_serviceextinfo->notes_icon); + if(this_serviceextinfo->notes_icon_alt!=NULL) + new_serviceextinfo->notes_icon_alt=strdup(this_serviceextinfo->notes_icon_alt); + if(this_serviceextinfo->action_icon!=NULL) + new_serviceextinfo->action_icon=strdup(this_serviceextinfo->action_icon); + if(this_serviceextinfo->action_icon_alt!=NULL) + new_serviceextinfo->action_icon=strdup(this_serviceextinfo->action_icon_alt); +#endif // SUPPORT_GROUPEXTINFO if(this_serviceextinfo->icon_image!=NULL) new_serviceextinfo->icon_image=strdup(this_serviceextinfo->icon_image); if(this_serviceextinfo->icon_image_alt!=NULL) @@ -5296,6 +5969,151 @@ return OK; } +#ifdef SUPPORT_GROUPEXTINFO +/* duplicates a hostgroupextinfo object definition */ +int xodtemplate_duplicate_hostgroupextinfo(xodtemplate_hostgroupextinfo *this_hostgroupextinfo, char *hostgroup_name){ + xodtemplate_hostgroupextinfo *new_hostgroupextinfo; + +#ifdef DEBUG0 + printf("xodtemplate_duplicate_hostgroupextinfo() start\n"); +#endif + + new_hostgroupextinfo=(xodtemplate_hostgroupextinfo *)malloc(sizeof(xodtemplate_hostgroupextinfo)); + if(new_hostgroupextinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for duplicate definition of extended hostgroup info.\n"); +#endif + return ERROR; + } + + new_hostgroupextinfo->template=NULL; + new_hostgroupextinfo->name=NULL; + new_hostgroupextinfo->hostgroup_name=NULL; + new_hostgroupextinfo->notes=NULL; + new_hostgroupextinfo->notes_url=NULL; + new_hostgroupextinfo->action_url=NULL; + new_hostgroupextinfo->icon_image=NULL; + new_hostgroupextinfo->icon_image_alt=NULL; + + new_hostgroupextinfo->has_been_resolved=this_hostgroupextinfo->has_been_resolved; + new_hostgroupextinfo->register_object=this_hostgroupextinfo->register_object; + + /* duplicate strings (host_name member is passed in) */ + if(hostgroup_name!=NULL) + new_hostgroupextinfo->hostgroup_name=strdup(hostgroup_name); + if(this_hostgroupextinfo->template!=NULL) + new_hostgroupextinfo->template=strdup(this_hostgroupextinfo->template); + if(this_hostgroupextinfo->name!=NULL) + new_hostgroupextinfo->name=strdup(this_hostgroupextinfo->name); + if(this_hostgroupextinfo->notes!=NULL) + new_hostgroupextinfo->notes=strdup(this_hostgroupextinfo->notes); + if(this_hostgroupextinfo->notes_url!=NULL) + new_hostgroupextinfo->notes_url=strdup(this_hostgroupextinfo->notes_url); + if(this_hostgroupextinfo->action_url!=NULL) + new_hostgroupextinfo->action_url=strdup(this_hostgroupextinfo->action_url); + if(this_hostgroupextinfo->target_frame!=NULL) + new_hostgroupextinfo->target_frame=strdup(this_hostgroupextinfo->target_frame); + if(this_hostgroupextinfo->notes_textinfo!=NULL) + new_hostgroupextinfo->notes_textinfo=strdup(this_hostgroupextinfo->notes_textinfo); + if(this_hostgroupextinfo->action_textinfo!=NULL) + new_hostgroupextinfo->action_textinfo=strdup(this_hostgroupextinfo->action_textinfo); + if(this_hostgroupextinfo->notes_icon!=NULL) + new_hostgroupextinfo->notes_icon=strdup(this_hostgroupextinfo->notes_icon); + if(this_hostgroupextinfo->notes_icon_alt!=NULL) + new_hostgroupextinfo->notes_icon_alt=strdup(this_hostgroupextinfo->notes_icon_alt); + if(this_hostgroupextinfo->action_icon!=NULL) + new_hostgroupextinfo->action_icon=strdup(this_hostgroupextinfo->action_icon); + if(this_hostgroupextinfo->action_icon_alt!=NULL) + new_hostgroupextinfo->action_icon=strdup(this_hostgroupextinfo->action_icon_alt); + if(this_hostgroupextinfo->icon_image!=NULL) + new_hostgroupextinfo->icon_image=strdup(this_hostgroupextinfo->icon_image); + if(this_hostgroupextinfo->icon_image_alt!=NULL) + new_hostgroupextinfo->icon_image_alt=strdup(this_hostgroupextinfo->icon_image_alt); + + /* add new object to head of list */ + new_hostgroupextinfo->next=xodtemplate_hostgroupextinfo_list; + xodtemplate_hostgroupextinfo_list=new_hostgroupextinfo; + +#ifdef DEBUG0 + printf("xodtemplate_duplicate_hostgroupextinfo() end\n"); +#endif + + return OK; + } + +/* duplicates a servicegroupextinfo object definition */ +int xodtemplate_duplicate_servicegroupextinfo(xodtemplate_servicegroupextinfo *this_servicegroupextinfo, char *servicegroup_name){ + xodtemplate_servicegroupextinfo *new_servicegroupextinfo; + +#ifdef DEBUG0 + printf("xodtemplate_duplicate_servicegroupextinfo() start\n"); +#endif + + new_servicegroupextinfo=(xodtemplate_servicegroupextinfo *)malloc(sizeof(xodtemplate_servicegroupextinfo)); + if(new_servicegroupextinfo==NULL){ +#ifdef DEBUG1 + printf("Error: Could not allocate memory for duplicate definition of extended servicegroup info.\n"); +#endif + return ERROR; + } + + new_servicegroupextinfo->template=NULL; + new_servicegroupextinfo->name=NULL; + new_servicegroupextinfo->servicegroup_name=NULL; + new_servicegroupextinfo->notes=NULL; + new_servicegroupextinfo->notes_url=NULL; + new_servicegroupextinfo->action_url=NULL; + new_servicegroupextinfo->icon_image=NULL; + new_servicegroupextinfo->icon_image_alt=NULL; + + new_servicegroupextinfo->has_been_resolved=this_servicegroupextinfo->has_been_resolved; + new_servicegroupextinfo->register_object=this_servicegroupextinfo->register_object; + + /* duplicate strings (service_name member is passed in) */ + if(servicegroup_name!=NULL) + new_servicegroupextinfo->servicegroup_name=strdup(servicegroup_name); + if(this_servicegroupextinfo->template!=NULL) + new_servicegroupextinfo->template=strdup(this_servicegroupextinfo->template); + if(this_servicegroupextinfo->name!=NULL) + new_servicegroupextinfo->name=strdup(this_servicegroupextinfo->name); + if(this_servicegroupextinfo->notes!=NULL) + new_servicegroupextinfo->notes=strdup(this_servicegroupextinfo->notes); + if(this_servicegroupextinfo->notes_url!=NULL) + new_servicegroupextinfo->notes_url=strdup(this_servicegroupextinfo->notes_url); + if(this_servicegroupextinfo->action_url!=NULL) + new_servicegroupextinfo->action_url=strdup(this_servicegroupextinfo->action_url); + if(this_servicegroupextinfo->target_frame!=NULL) + new_servicegroupextinfo->target_frame=strdup(this_servicegroupextinfo->target_frame); + if(this_servicegroupextinfo->notes_textinfo!=NULL) + new_servicegroupextinfo->notes_textinfo=strdup(this_servicegroupextinfo->notes_textinfo); + if(this_servicegroupextinfo->action_textinfo!=NULL) + new_servicegroupextinfo->action_textinfo=strdup(this_servicegroupextinfo->action_textinfo); + if(this_servicegroupextinfo->notes_icon!=NULL) + new_servicegroupextinfo->notes_icon=strdup(this_servicegroupextinfo->notes_icon); + if(this_servicegroupextinfo->notes_icon_alt!=NULL) + new_servicegroupextinfo->notes_icon_alt=strdup(this_servicegroupextinfo->notes_icon_alt); + if(this_servicegroupextinfo->action_icon!=NULL) + new_servicegroupextinfo->action_icon=strdup(this_servicegroupextinfo->action_icon); + if(this_servicegroupextinfo->action_icon_alt!=NULL) + new_servicegroupextinfo->action_icon=strdup(this_servicegroupextinfo->action_icon_alt); + if(this_servicegroupextinfo->icon_image!=NULL) + new_servicegroupextinfo->icon_image=strdup(this_servicegroupextinfo->icon_image); + if(this_servicegroupextinfo->icon_image_alt!=NULL) + new_servicegroupextinfo->icon_image_alt=strdup(this_servicegroupextinfo->icon_image_alt); + + /* add new object to head of list */ + new_servicegroupextinfo->next=xodtemplate_servicegroupextinfo_list; + xodtemplate_servicegroupextinfo_list=new_servicegroupextinfo; + +#ifdef DEBUG0 + printf("xodtemplate_duplicate_servicegroupextinfo() end\n"); +#endif + + return OK; + } + +#endif // SUPPORT_GROUPEXTINFO + #endif @@ -5321,6 +6139,10 @@ xodtemplate_hostescalation *temp_hostescalation; xodtemplate_hostextinfo *temp_hostextinfo; xodtemplate_serviceextinfo *temp_serviceextinfo; +#ifdef SUPPORT_GROUPEXTINFO + xodtemplate_hostgroupextinfo *temp_hostgroupextinfo; + xodtemplate_servicegroupextinfo *temp_servicegroupextinfo; +#endif // SUPPORT_GROUPEXTINFO #ifdef DEBUG0 printf("xodtemplate_resolve_objects() start\n"); @@ -5409,6 +6231,18 @@ if(xodtemplate_resolve_serviceextinfo(temp_serviceextinfo)==ERROR) return ERROR; } +#ifdef SUPPORT_GROUPEXTINFO + /* resolve all hostgroupextinfo objects */ + for(temp_hostgroupextinfo=xodtemplate_hostgroupextinfo_list;temp_hostgroupextinfo!=NULL;temp_hostgroupextinfo=temp_hostgroupextinfo->next){ + if(xodtemplate_resolve_hostgroupextinfo(temp_hostgroupextinfo)==ERROR) + return ERROR; + } + /* resolve all hostgroupextinfo objects */ + for(temp_servicegroupextinfo=xodtemplate_servicegroupextinfo_list;temp_servicegroupextinfo!=NULL;temp_servicegroupextinfo=temp_servicegroupextinfo->next){ + if(xodtemplate_resolve_servicegroupextinfo(temp_servicegroupextinfo)==ERROR) + return ERROR; + } +#endif // SUPPORT_GROUPEXTINFO #ifdef DEBUG0 printf("xodtemplate_resolve_objects() end\n"); @@ -6422,6 +7256,22 @@ this_hostextinfo->notes_url=strdup(template_hostextinfo->notes_url); if(this_hostextinfo->action_url==NULL && template_hostextinfo->action_url!=NULL) this_hostextinfo->action_url=strdup(template_hostextinfo->action_url); +#ifdef SUPPORT_GROUPEXTINFO + if(this_hostextinfo->target_frame==NULL && template_hostextinfo->target_frame!=NULL) + this_hostextinfo->target_frame=strdup(template_hostextinfo->target_frame); + if(this_hostextinfo->notes_textinfo==NULL && template_hostextinfo->notes_textinfo!=NULL) + this_hostextinfo->notes_textinfo=strdup(template_hostextinfo->notes_textinfo); + if(this_hostextinfo->action_textinfo==NULL && template_hostextinfo->action_textinfo!=NULL) + this_hostextinfo->action_textinfo=strdup(template_hostextinfo->action_textinfo); + if(this_hostextinfo->notes_icon==NULL && template_hostextinfo->notes_icon!=NULL) + this_hostextinfo->notes_icon=strdup(template_hostextinfo->notes_icon); + if(this_hostextinfo->notes_icon_alt==NULL && template_hostextinfo->notes_icon_alt!=NULL) + this_hostextinfo->notes_icon_alt=strdup(template_hostextinfo->notes_icon_alt); + if(this_hostextinfo->action_icon==NULL && template_hostextinfo->action_icon!=NULL) + this_hostextinfo->action_icon=strdup(template_hostextinfo->action_icon); + if(this_hostextinfo->action_icon_alt==NULL && template_hostextinfo->action_icon_alt!=NULL) + this_hostextinfo->action_icon=strdup(template_hostextinfo->action_icon_alt); +#endif // SUPPORT_GROUPEXTINFO if(this_hostextinfo->icon_image==NULL && template_hostextinfo->icon_image!=NULL) this_hostextinfo->icon_image=strdup(template_hostextinfo->icon_image); if(this_hostextinfo->icon_image_alt==NULL && template_hostextinfo->icon_image_alt!=NULL) @@ -6499,6 +7349,22 @@ this_serviceextinfo->notes_url=strdup(template_serviceextinfo->notes_url); if(this_serviceextinfo->action_url==NULL && template_serviceextinfo->action_url!=NULL) this_serviceextinfo->action_url=strdup(template_serviceextinfo->action_url); +#ifdef SUPPORT_GROUPEXTINFO + if(this_serviceextinfo->target_frame==NULL && template_serviceextinfo->target_frame!=NULL) + this_serviceextinfo->target_frame=strdup(template_serviceextinfo->target_frame); + if(this_serviceextinfo->notes_textinfo==NULL && template_serviceextinfo->notes_textinfo!=NULL) + this_serviceextinfo->notes_textinfo=strdup(template_serviceextinfo->notes_textinfo); + if(this_serviceextinfo->action_textinfo==NULL && template_serviceextinfo->action_textinfo!=NULL) + this_serviceextinfo->action_textinfo=strdup(template_serviceextinfo->action_textinfo); + if(this_serviceextinfo->notes_icon==NULL && template_serviceextinfo->notes_icon!=NULL) + this_serviceextinfo->notes_icon=strdup(template_serviceextinfo->notes_icon); + if(this_serviceextinfo->notes_icon_alt==NULL && template_serviceextinfo->notes_icon_alt!=NULL) + this_serviceextinfo->notes_icon_alt=strdup(template_serviceextinfo->notes_icon_alt); + if(this_serviceextinfo->action_icon==NULL && template_serviceextinfo->action_icon!=NULL) + this_serviceextinfo->action_icon=strdup(template_serviceextinfo->action_icon); + if(this_serviceextinfo->action_icon_alt==NULL && template_serviceextinfo->action_icon_alt!=NULL) + this_serviceextinfo->action_icon=strdup(template_serviceextinfo->action_icon_alt); +#endif // SUPPORT_GROUPEXTINFO if(this_serviceextinfo->icon_image==NULL && template_serviceextinfo->icon_image!=NULL) this_serviceextinfo->icon_image=strdup(template_serviceextinfo->icon_image); if(this_serviceextinfo->icon_image_alt==NULL && template_serviceextinfo->icon_image_alt!=NULL) @@ -6511,6 +7377,148 @@ return OK; } +#ifdef SUPPORT_GROUPEXTINFO +/* resolves a hostgroupextinfo object */ +int xodtemplate_resolve_hostgroupextinfo(xodtemplate_hostgroupextinfo *this_hostgroupextinfo){ + xodtemplate_hostgroupextinfo *template_hostgroupextinfo; +#ifdef NSCORE + char temp_buffer[MAX_XODTEMPLATE_INPUT_BUFFER]; +#endif + +#ifdef DEBUG0 + printf("xodtemplate_resolve_hostgroupextinfo() start\n"); +#endif + + /* return if this object has already been resolved */ + if(this_hostgroupextinfo->has_been_resolved==TRUE) + return OK; + + /* set the resolved flag */ + this_hostgroupextinfo->has_been_resolved=TRUE; + + /* return if we have no template */ + if(this_hostgroupextinfo->template==NULL) + return OK; + + template_hostgroupextinfo=xodtemplate_find_hostgroupextinfo(this_hostgroupextinfo->template); + if(template_hostgroupextinfo==NULL){ +#ifdef NSCORE + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Template '%s' specified in extended hostgroup info definition could not be not found (config file '%s', starting on line %d)\n",this_hostgroupextinfo->template,xodtemplate_config_file_name(this_hostgroupextinfo->_config_file),this_hostgroupextinfo->_start_line); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return ERROR; + } + + /* resolve the template hostgroupextinfo... */ + xodtemplate_resolve_hostgroupextinfo(template_hostgroupextinfo); + + /* apply missing properties from template hostgroupextinfo... */ + if(this_hostgroupextinfo->hostgroup_name==NULL && template_hostgroupextinfo->hostgroup_name!=NULL) + this_hostgroupextinfo->hostgroup_name=strdup(template_hostgroupextinfo->hostgroup_name); + if(this_hostgroupextinfo->notes==NULL && template_hostgroupextinfo->notes!=NULL) + this_hostgroupextinfo->notes=strdup(template_hostgroupextinfo->notes); + if(this_hostgroupextinfo->notes_url==NULL && template_hostgroupextinfo->notes_url!=NULL) + this_hostgroupextinfo->notes_url=strdup(template_hostgroupextinfo->notes_url); + if(this_hostgroupextinfo->action_url==NULL && template_hostgroupextinfo->action_url!=NULL) + this_hostgroupextinfo->action_url=strdup(template_hostgroupextinfo->action_url); + if(this_hostgroupextinfo->target_frame==NULL && template_hostgroupextinfo->target_frame!=NULL) + this_hostgroupextinfo->target_frame=strdup(template_hostgroupextinfo->target_frame); + if(this_hostgroupextinfo->notes_textinfo==NULL && template_hostgroupextinfo->notes_textinfo!=NULL) + this_hostgroupextinfo->notes_textinfo=strdup(template_hostgroupextinfo->notes_textinfo); + if(this_hostgroupextinfo->action_textinfo==NULL && template_hostgroupextinfo->action_textinfo!=NULL) + this_hostgroupextinfo->action_textinfo=strdup(template_hostgroupextinfo->action_textinfo); + if(this_hostgroupextinfo->notes_icon==NULL && template_hostgroupextinfo->notes_icon!=NULL) + this_hostgroupextinfo->notes_icon=strdup(template_hostgroupextinfo->notes_icon); + if(this_hostgroupextinfo->notes_icon_alt==NULL && template_hostgroupextinfo->notes_icon_alt!=NULL) + this_hostgroupextinfo->notes_icon_alt=strdup(template_hostgroupextinfo->notes_icon_alt); + if(this_hostgroupextinfo->action_icon==NULL && template_hostgroupextinfo->action_icon!=NULL) + this_hostgroupextinfo->action_icon=strdup(template_hostgroupextinfo->action_icon); + if(this_hostgroupextinfo->action_icon_alt==NULL && template_hostgroupextinfo->action_icon_alt!=NULL) + this_hostgroupextinfo->action_icon=strdup(template_hostgroupextinfo->action_icon_alt); + if(this_hostgroupextinfo->icon_image==NULL && template_hostgroupextinfo->icon_image!=NULL) + this_hostgroupextinfo->icon_image=strdup(template_hostgroupextinfo->icon_image); + if(this_hostgroupextinfo->icon_image_alt==NULL && template_hostgroupextinfo->icon_image_alt!=NULL) + this_hostgroupextinfo->icon_image_alt=strdup(template_hostgroupextinfo->icon_image_alt); + +#ifdef DEBUG0 + printf("xodtemplate_resolve_hostgroupextinfo() end\n"); +#endif + + return OK; + } + +/* resolves a servicegroupextinfo object */ +int xodtemplate_resolve_servicegroupextinfo(xodtemplate_servicegroupextinfo *this_servicegroupextinfo){ + xodtemplate_servicegroupextinfo *template_servicegroupextinfo; +#ifdef NSCORE + char temp_buffer[MAX_XODTEMPLATE_INPUT_BUFFER]; +#endif + +#ifdef DEBUG0 + printf("xodtemplate_resolve_servicegroupextinfo() start\n"); +#endif + + /* return if this object has already been resolved */ + if(this_servicegroupextinfo->has_been_resolved==TRUE) + return OK; + + /* set the resolved flag */ + this_servicegroupextinfo->has_been_resolved=TRUE; + + /* return if we have no template */ + if(this_servicegroupextinfo->template==NULL) + return OK; + + template_servicegroupextinfo=xodtemplate_find_servicegroupextinfo(this_servicegroupextinfo->template); + if(template_servicegroupextinfo==NULL){ +#ifdef NSCORE + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Template '%s' specified in extended servicegroup info definition could not be not found (config file '%s', starting on line %d)\n",this_servicegroupextinfo->template,xodtemplate_config_file_name(this_servicegroupextinfo->_config_file),this_servicegroupextinfo->_start_line); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return ERROR; + } + + /* resolve the template servicegroupextinfo... */ + xodtemplate_resolve_servicegroupextinfo(template_servicegroupextinfo); + + /* apply missing properties from template servicegroupextinfo... */ + if(this_servicegroupextinfo->servicegroup_name==NULL && template_servicegroupextinfo->servicegroup_name!=NULL) + this_servicegroupextinfo->servicegroup_name=strdup(template_servicegroupextinfo->servicegroup_name); + if(this_servicegroupextinfo->notes==NULL && template_servicegroupextinfo->notes!=NULL) + this_servicegroupextinfo->notes=strdup(template_servicegroupextinfo->notes); + if(this_servicegroupextinfo->notes_url==NULL && template_servicegroupextinfo->notes_url!=NULL) + this_servicegroupextinfo->notes_url=strdup(template_servicegroupextinfo->notes_url); + if(this_servicegroupextinfo->action_url==NULL && template_servicegroupextinfo->action_url!=NULL) + this_servicegroupextinfo->action_url=strdup(template_servicegroupextinfo->action_url); + if(this_servicegroupextinfo->target_frame==NULL && template_servicegroupextinfo->target_frame!=NULL) + this_servicegroupextinfo->target_frame=strdup(template_servicegroupextinfo->target_frame); + if(this_servicegroupextinfo->notes_textinfo==NULL && template_servicegroupextinfo->notes_textinfo!=NULL) + this_servicegroupextinfo->notes_textinfo=strdup(template_servicegroupextinfo->notes_textinfo); + if(this_servicegroupextinfo->action_textinfo==NULL && template_servicegroupextinfo->action_textinfo!=NULL) + this_servicegroupextinfo->action_textinfo=strdup(template_servicegroupextinfo->action_textinfo); + if(this_servicegroupextinfo->notes_icon==NULL && template_servicegroupextinfo->notes_icon!=NULL) + this_servicegroupextinfo->notes_icon=strdup(template_servicegroupextinfo->notes_icon); + if(this_servicegroupextinfo->notes_icon_alt==NULL && template_servicegroupextinfo->notes_icon_alt!=NULL) + this_servicegroupextinfo->notes_icon_alt=strdup(template_servicegroupextinfo->notes_icon_alt); + if(this_servicegroupextinfo->action_icon==NULL && template_servicegroupextinfo->action_icon!=NULL) + this_servicegroupextinfo->action_icon=strdup(template_servicegroupextinfo->action_icon); + if(this_servicegroupextinfo->action_icon_alt==NULL && template_servicegroupextinfo->action_icon_alt!=NULL) + this_servicegroupextinfo->action_icon=strdup(template_servicegroupextinfo->action_icon_alt); + if(this_servicegroupextinfo->icon_image==NULL && template_servicegroupextinfo->icon_image!=NULL) + this_servicegroupextinfo->icon_image=strdup(template_servicegroupextinfo->icon_image); + if(this_servicegroupextinfo->icon_image_alt==NULL && template_servicegroupextinfo->icon_image_alt!=NULL) + this_servicegroupextinfo->icon_image_alt=strdup(template_servicegroupextinfo->icon_image_alt); + +#ifdef DEBUG0 + printf("xodtemplate_resolve_servicegroupextinfo() end\n"); +#endif + + return OK; + } +#endif // SUPPORT_GROUPEXTINFO + #endif @@ -7272,6 +8280,41 @@ return temp_serviceextinfo; } +#ifdef SUPPORT_GROUPEXTINFO +/* finds a specific hostgroupextinfo object */ +xodtemplate_hostgroupextinfo *xodtemplate_find_hostgroupextinfo(char *name){ + xodtemplate_hostgroupextinfo *temp_hostgroupextinfo; + + if(name==NULL) + return NULL; + + for(temp_hostgroupextinfo=xodtemplate_hostgroupextinfo_list;temp_hostgroupextinfo!=NULL;temp_hostgroupextinfo=temp_hostgroupextinfo->next){ + if(temp_hostgroupextinfo->name==NULL) + continue; + if(!strcmp(temp_hostgroupextinfo->name,name)) + break; + } + + return temp_hostgroupextinfo; + } + +/* finds a specific servicegroupextinfo object */ +xodtemplate_servicegroupextinfo *xodtemplate_find_servicegroupextinfo(char *name){ + xodtemplate_servicegroupextinfo *temp_servicegroupextinfo; + + if(name==NULL) + return NULL; + + for(temp_servicegroupextinfo=xodtemplate_servicegroupextinfo_list;temp_servicegroupextinfo!=NULL;temp_servicegroupextinfo=temp_servicegroupextinfo->next){ + if(temp_servicegroupextinfo->name==NULL) + continue; + if(!strcmp(temp_servicegroupextinfo->name,name)) + break; + } + + return temp_servicegroupextinfo; + } +#endif // SUPPORT_GROUPEXTINFO /* finds a specific service object */ xodtemplate_service *xodtemplate_find_service(char *name){ @@ -7333,6 +8376,10 @@ xodtemplate_hostescalation *temp_hostescalation; xodtemplate_hostextinfo *temp_hostextinfo; xodtemplate_serviceextinfo *temp_serviceextinfo; +#ifdef SUPPORT_GROUPEXTINFO + xodtemplate_hostgroupextinfo *temp_hostgroupextinfo; + xodtemplate_servicegroupextinfo *temp_servicegroupextinfo; +#endif // SUPPORT_GROUPEXTINFO #ifdef DEBUG0 printf("xodtemplate_register_objects() start\n"); @@ -7422,6 +8469,20 @@ return ERROR; } +#ifdef SUPPORT_GROUPEXTINFO + /* register host group extended info */ + for(temp_hostgroupextinfo=xodtemplate_hostgroupextinfo_list;temp_hostgroupextinfo!=NULL;temp_hostgroupextinfo=temp_hostgroupextinfo->next){ + if((result=xodtemplate_register_hostgroupextinfo(temp_hostgroupextinfo))==ERROR) + return ERROR; + } + + /* register service group extended info */ + for(temp_servicegroupextinfo=xodtemplate_servicegroupextinfo_list;temp_servicegroupextinfo!=NULL;temp_servicegroupextinfo=temp_servicegroupextinfo->next){ + if((result=xodtemplate_register_servicegroupextinfo(temp_servicegroupextinfo))==ERROR) + return ERROR; + } +#endif // SUPPORT_GROUPEXTINFO + #ifdef DEBUG0 printf("xodtemplate_register_objects() end\n"); @@ -8298,7 +9359,11 @@ return OK; /* register the extended host object */ +#ifndef SUPPORT_GROUPEXTINFO new_hostextinfo=add_hostextinfo(this_hostextinfo->host_name,this_hostextinfo->notes,this_hostextinfo->notes_url,this_hostextinfo->action_url,this_hostextinfo->icon_image,this_hostextinfo->vrml_image,this_hostextinfo->statusmap_image,this_hostextinfo->icon_image_alt,this_hostextinfo->x_2d,this_hostextinfo->y_2d,this_hostextinfo->x_3d,this_hostextinfo->y_3d,this_hostextinfo->z_3d,this_hostextinfo->have_2d_coords,this_hostextinfo->have_3d_coords); +#else + new_hostextinfo=add_hostextinfo(this_hostextinfo->host_name,this_hostextinfo->notes,this_hostextinfo->notes_url,this_hostextinfo->action_url,this_hostextinfo->target_frame,this_hostextinfo->notes_textinfo,this_hostextinfo->action_textinfo,this_hostextinfo->notes_icon,this_hostextinfo->notes_icon_alt,this_hostextinfo->action_icon,this_hostextinfo->action_icon_alt,this_hostextinfo->icon_image,this_hostextinfo->vrml_image,this_hostextinfo->statusmap_image,this_hostextinfo->icon_image_alt,this_hostextinfo->x_2d,this_hostextinfo->y_2d,this_hostextinfo->x_3d,this_hostextinfo->y_3d,this_hostextinfo->z_3d,this_hostextinfo->have_2d_coords,this_hostextinfo->have_3d_coords); +#endif // SUPPORT_GROUPEXTINFO /* return with an error if we couldn't add the definition */ if(new_hostextinfo==NULL){ @@ -8335,8 +9400,11 @@ return OK; /* register the extended service object */ +#ifndef SUPPORT_GROUPEXTINFO new_serviceextinfo=add_serviceextinfo(this_serviceextinfo->host_name,this_serviceextinfo->service_description,this_serviceextinfo->notes,this_serviceextinfo->notes_url,this_serviceextinfo->action_url,this_serviceextinfo->icon_image,this_serviceextinfo->icon_image_alt); - +#else + new_serviceextinfo=add_serviceextinfo(this_serviceextinfo->host_name,this_serviceextinfo->service_description,this_serviceextinfo->notes,this_serviceextinfo->notes_url,this_serviceextinfo->action_url,this_serviceextinfo->target_frame,this_serviceextinfo->notes_textinfo,this_serviceextinfo->action_textinfo,this_serviceextinfo->notes_icon,this_serviceextinfo->notes_icon_alt,this_serviceextinfo->action_icon,this_serviceextinfo->action_icon_alt,this_serviceextinfo->icon_image,this_serviceextinfo->icon_image_alt); +#endif // SUPPORT_GROUPEXTINFO /* return with an error if we couldn't add the definition */ if(new_serviceextinfo==NULL){ #ifdef NSCORE @@ -8354,6 +9422,78 @@ return OK; } +#ifdef SUPPORT_GROUPEXTINFO +/* registers a hostgroupextinfo definition */ +int xodtemplate_register_hostgroupextinfo(xodtemplate_hostgroupextinfo *this_hostgroupextinfo){ + hostgroupextinfo *new_hostgroupextinfo; +#ifdef NSCORE + char temp_buffer[MAX_XODTEMPLATE_INPUT_BUFFER]; +#endif + +#ifdef DEBUG0 + printf("xodtemplate_register_hostgroupextinfo() start\n"); +#endif + + /* bail out if we shouldn't register this object */ + if(this_hostgroupextinfo->register_object==FALSE) + return OK; + + /* register the extended hostgroup object */ + new_hostgroupextinfo=add_hostgroupextinfo(this_hostgroupextinfo->hostgroup_name,this_hostgroupextinfo->notes,this_hostgroupextinfo->notes_url,this_hostgroupextinfo->action_url,this_hostgroupextinfo->target_frame,this_hostgroupextinfo->notes_textinfo,this_hostgroupextinfo->action_textinfo,this_hostgroupextinfo->notes_icon,this_hostgroupextinfo->notes_icon_alt,this_hostgroupextinfo->action_icon,this_hostgroupextinfo->action_icon_alt,this_hostgroupextinfo->icon_image,this_hostgroupextinfo->icon_image_alt); + + /* return with an error if we couldn't add the definition */ + if(new_hostgroupextinfo==NULL){ +#ifdef NSCORE + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not register extended hostgroup information (config file '%s', starting on line %d)\n",xodtemplate_config_file_name(this_hostgroupextinfo->_config_file),this_hostgroupextinfo->_start_line); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return ERROR; + } + +#ifdef DEBUG0 + printf("xodtemplate_register_hostgroupextinfo() end\n"); +#endif + + return OK; + } + +/* registers a servicegroupextinfo definition */ +int xodtemplate_register_servicegroupextinfo(xodtemplate_servicegroupextinfo *this_servicegroupextinfo){ + servicegroupextinfo *new_servicegroupextinfo; +#ifdef NSCORE + char temp_buffer[MAX_XODTEMPLATE_INPUT_BUFFER]; +#endif + +#ifdef DEBUG0 + printf("xodtemplate_register_servicegroupextinfo() start\n"); +#endif + + /* bail out if we shouldn't register this object */ + if(this_servicegroupextinfo->register_object==FALSE) + return OK; + + /* register the extended servicegroup object */ + new_servicegroupextinfo=add_servicegroupextinfo(this_servicegroupextinfo->servicegroup_name,this_servicegroupextinfo->notes,this_servicegroupextinfo->notes_url,this_servicegroupextinfo->action_url,this_servicegroupextinfo->target_frame,this_servicegroupextinfo->notes_textinfo,this_servicegroupextinfo->action_textinfo,this_servicegroupextinfo->notes_icon,this_servicegroupextinfo->notes_icon_alt,this_servicegroupextinfo->action_icon,this_servicegroupextinfo->action_icon_alt,this_servicegroupextinfo->icon_image,this_servicegroupextinfo->icon_image_alt); + + /* return with an error if we couldn't add the definition */ + if(new_servicegroupextinfo==NULL){ +#ifdef NSCORE + snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not register extended servicegroup information (config file '%s', starting on line %d)\n",xodtemplate_config_file_name(this_servicegroupextinfo->_config_file),this_servicegroupextinfo->_start_line); + temp_buffer[sizeof(temp_buffer)-1]='\x0'; + write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE); +#endif + return ERROR; + } + +#ifdef DEBUG0 + printf("xodtemplate_register_servicegroupextinfo() end\n"); +#endif + + return OK; + } + +#endif // SUPPORT_GROUPEXTINFO /******************************************************************/ @@ -8425,6 +9565,16 @@ if(xodtemplate_sort_serviceextinfo()==ERROR) return ERROR; +#ifdef SUPPORT_GROUPEXTINFO + /* sort hostgroup extended info */ + if(xodtemplate_sort_hostgroupextinfo()==ERROR) + return ERROR; + + /* sort servicegroup extended info */ + if(xodtemplate_sort_servicegroupextinfo()==ERROR) + return ERROR; +#endif // SUPPORT_GROUPEXTINFO + #ifdef DEBUG0 printf("xodtemplate_sort_objects() end\n"); #endif @@ -9255,6 +10405,120 @@ return OK; } +#ifdef SUPPORT_GROUPEXTINFO +/* sort extended host group info by name */ +int xodtemplate_sort_hostgroupextinfo(){ + xodtemplate_hostgroupextinfo *new_hostgroupextinfo_list=NULL; + xodtemplate_hostgroupextinfo *temp_hostgroupextinfo=NULL; + xodtemplate_hostgroupextinfo *last_hostgroupextinfo=NULL; + xodtemplate_hostgroupextinfo *temp_hostgroupextinfo_orig=NULL; + xodtemplate_hostgroupextinfo *next_hostgroupextinfo_orig=NULL; + +#ifdef DEBUG0 + printf("xodtemplate_sort_hostgroupextinfo() start\n"); +#endif + + /* sort all existing existing hostgroup info */ + for(temp_hostgroupextinfo_orig=xodtemplate_hostgroupextinfo_list;temp_hostgroupextinfo_orig!=NULL;temp_hostgroupextinfo_orig=next_hostgroupextinfo_orig){ + + next_hostgroupextinfo_orig=temp_hostgroupextinfo_orig->next; + + /* add hostgroupextinfo to new list, sorted by host name then hostgroupextinfo description */ + last_hostgroupextinfo=new_hostgroupextinfo_list; + for(temp_hostgroupextinfo=new_hostgroupextinfo_list;temp_hostgroupextinfo!=NULL;temp_hostgroupextinfo=temp_hostgroupextinfo->next){ + + if(xodtemplate_compare_strings1(temp_hostgroupextinfo_orig->hostgroup_name,temp_hostgroupextinfo->hostgroup_name)<=0) + break; + else + last_hostgroupextinfo=temp_hostgroupextinfo; + } + + /* first item added to new sorted list */ + if(new_hostgroupextinfo_list==NULL){ + temp_hostgroupextinfo_orig->next=NULL; + new_hostgroupextinfo_list=temp_hostgroupextinfo_orig; + } + + /* item goes at head of new sorted list */ + else if(temp_hostgroupextinfo==new_hostgroupextinfo_list){ + temp_hostgroupextinfo_orig->next=new_hostgroupextinfo_list; + new_hostgroupextinfo_list=temp_hostgroupextinfo_orig; + } + + /* item goes in middle or at end of new sorted list */ + else{ + temp_hostgroupextinfo_orig->next=temp_hostgroupextinfo; + last_hostgroupextinfo->next=temp_hostgroupextinfo_orig; + } + } + + /* list is now sorted */ + xodtemplate_hostgroupextinfo_list=new_hostgroupextinfo_list; + +#ifdef DEBUG0 + printf("xodtemplate_sort_hostgroupextinfo() end\n"); +#endif + + return OK; + } + +/* sort extended service group info by name */ +int xodtemplate_sort_servicegroupextinfo(){ + xodtemplate_servicegroupextinfo *new_servicegroupextinfo_list=NULL; + xodtemplate_servicegroupextinfo *temp_servicegroupextinfo=NULL; + xodtemplate_servicegroupextinfo *last_servicegroupextinfo=NULL; + xodtemplate_servicegroupextinfo *temp_servicegroupextinfo_orig=NULL; + xodtemplate_servicegroupextinfo *next_servicegroupextinfo_orig=NULL; + +#ifdef DEBUG0 + printf("xodtemplate_sort_servicegroupextinfo() start\n"); +#endif + + /* sort all existing existing servicegroup info */ + for(temp_servicegroupextinfo_orig=xodtemplate_servicegroupextinfo_list;temp_servicegroupextinfo_orig!=NULL;temp_servicegroupextinfo_orig=next_servicegroupextinfo_orig){ + + next_servicegroupextinfo_orig=temp_servicegroupextinfo_orig->next; + + /* add servicegroupextinfo to new list, sorted by service name then servicegroupextinfo description */ + last_servicegroupextinfo=new_servicegroupextinfo_list; + for(temp_servicegroupextinfo=new_servicegroupextinfo_list;temp_servicegroupextinfo!=NULL;temp_servicegroupextinfo=temp_servicegroupextinfo->next){ + + if(xodtemplate_compare_strings1(temp_servicegroupextinfo_orig->servicegroup_name,temp_servicegroupextinfo->servicegroup_name)<=0) + break; + else + last_servicegroupextinfo=temp_servicegroupextinfo; + } + + /* first item added to new sorted list */ + if(new_servicegroupextinfo_list==NULL){ + temp_servicegroupextinfo_orig->next=NULL; + new_servicegroupextinfo_list=temp_servicegroupextinfo_orig; + } + + /* item goes at head of new sorted list */ + else if(temp_servicegroupextinfo==new_servicegroupextinfo_list){ + temp_servicegroupextinfo_orig->next=new_servicegroupextinfo_list; + new_servicegroupextinfo_list=temp_servicegroupextinfo_orig; + } + + /* item goes in middle or at end of new sorted list */ + else{ + temp_servicegroupextinfo_orig->next=temp_servicegroupextinfo; + last_servicegroupextinfo->next=temp_servicegroupextinfo_orig; + } + } + + /* list is now sorted */ + xodtemplate_servicegroupextinfo_list=new_servicegroupextinfo_list; + +#ifdef DEBUG0 + printf("xodtemplate_sort_servicegroupextinfo() end\n"); +#endif + + return OK; + } +#endif // SUPPORT_GROUPEXTINFO + #endif @@ -9285,6 +10549,10 @@ xodtemplate_hostescalation *temp_hostescalation; xodtemplate_hostextinfo *temp_hostextinfo; xodtemplate_serviceextinfo *temp_serviceextinfo; +#ifdef SUPPORT_GROUPEXTINFO + xodtemplate_hostgroupextinfo *temp_hostgroupextinfo; + xodtemplate_servicegroupextinfo *temp_servicegroupextinfo; +#endif // SUPPORT_GROUPEXTINFO time_t current_time; #ifdef DEBUG0 @@ -9761,6 +11029,22 @@ fprintf(fp,"\tnotes_url\t%s\n",temp_hostextinfo->notes_url); if(temp_hostextinfo->action_url) fprintf(fp,"\taction_url\t%s\n",temp_hostextinfo->action_url); +#ifdef SUPPORT_GROUPEXTINFO + if(temp_hostextinfo->notes_textinfo) + fprintf(fp,"\tnotes_textinfo\t%s\n",temp_hostextinfo->notes_textinfo); + if(temp_hostextinfo->action_textinfo) + fprintf(fp,"\taction_textinfo\t%s\n",temp_hostextinfo->action_textinfo); + if(temp_hostextinfo->notes_icon) + fprintf(fp,"\tnotes_icon\t%s\n",temp_hostextinfo->notes_icon); + if(temp_hostextinfo->notes_icon_alt) + fprintf(fp,"\tnotes_icon_alt\t%s\n",temp_hostextinfo->notes_icon_alt); + if(temp_hostextinfo->action_icon) + fprintf(fp,"\taction_icon\t%s\n",temp_hostextinfo->action_icon); + if(temp_hostextinfo->action_icon_alt) + fprintf(fp,"\taction_icon_alt\t%s\n",temp_hostextinfo->action_icon); + if(temp_hostextinfo->target_frame) + fprintf(fp,"\ttarget_frame\t%s\n",temp_hostextinfo->target_frame); +#endif // SUPPORT_GROUPEXTINFO fprintf(fp,"\t}\n\n"); } @@ -9783,9 +11067,95 @@ fprintf(fp,"\tnotes_url\t%s\n",temp_serviceextinfo->notes_url); if(temp_serviceextinfo->action_url) fprintf(fp,"\taction_url\t%s\n",temp_serviceextinfo->action_url); +#ifdef SUPPORT_GROUPEXTINFO + if(temp_serviceextinfo->notes_textinfo) + fprintf(fp,"\tnotes_textinfo\t%s\n",temp_serviceextinfo->notes_textinfo); + if(temp_serviceextinfo->action_textinfo) + fprintf(fp,"\taction_textinfo\t%s\n",temp_serviceextinfo->action_textinfo); + if(temp_serviceextinfo->notes_icon) + fprintf(fp,"\tnotes_icon\t%s\n",temp_serviceextinfo->notes_icon); + if(temp_serviceextinfo->notes_icon_alt) + fprintf(fp,"\tnotes_icon_alt\t%s\n",temp_serviceextinfo->notes_icon_alt); + if(temp_serviceextinfo->action_icon) + fprintf(fp,"\taction_icon\t%s\n",temp_serviceextinfo->action_icon); + if(temp_serviceextinfo->action_icon_alt) + fprintf(fp,"\taction_icon_alt\t%s\n",temp_serviceextinfo->action_icon); + if(temp_serviceextinfo->target_frame) + fprintf(fp,"\ttarget_frame\t%s\n",temp_serviceextinfo->target_frame); +#endif // SUPPORT_GROUPEXTINFO fprintf(fp,"\t}\n\n"); } +#ifdef SUPPORT_GROUPEXTINFO + /* cache host group extended info */ + for(temp_hostgroupextinfo=xodtemplate_hostgroupextinfo_list;temp_hostgroupextinfo!=NULL;temp_hostgroupextinfo=temp_hostgroupextinfo->next){ + if(temp_hostgroupextinfo->register_object==FALSE) + continue; + fprintf(fp,"define hostgroupextinfo {\n"); + if(temp_hostgroupextinfo->hostgroup_name) + fprintf(fp,"\thostgroup_name\t%s\n",temp_hostgroupextinfo->hostgroup_name); + if(temp_hostgroupextinfo->icon_image) + fprintf(fp,"\ticon_image\t%s\n",temp_hostgroupextinfo->icon_image); + if(temp_hostgroupextinfo->icon_image_alt) + fprintf(fp,"\ticon_image_alt\t%s\n",temp_hostgroupextinfo->icon_image_alt); + if(temp_hostgroupextinfo->notes) + fprintf(fp,"\tnotes\t%s\n",temp_hostgroupextinfo->notes); + if(temp_hostgroupextinfo->notes_url) + fprintf(fp,"\tnotes_url\t%s\n",temp_hostgroupextinfo->notes_url); + if(temp_hostgroupextinfo->action_url) + fprintf(fp,"\taction_url\t%s\n",temp_hostgroupextinfo->action_url); + if(temp_hostgroupextinfo->notes_textinfo) + fprintf(fp,"\tnotes_textinfo\t%s\n",temp_hostgroupextinfo->notes_textinfo); + if(temp_hostgroupextinfo->action_textinfo) + fprintf(fp,"\taction_textinfo\t%s\n",temp_hostgroupextinfo->action_textinfo); + if(temp_hostgroupextinfo->notes_icon) + fprintf(fp,"\tnotes_icon\t%s\n",temp_hostgroupextinfo->notes_icon); + if(temp_hostgroupextinfo->notes_icon_alt) + fprintf(fp,"\tnotes_icon_alt\t%s\n",temp_hostgroupextinfo->notes_icon_alt); + if(temp_hostgroupextinfo->action_icon) + fprintf(fp,"\taction_icon\t%s\n",temp_hostgroupextinfo->action_icon); + if(temp_hostgroupextinfo->action_icon_alt) + fprintf(fp,"\taction_icon_alt\t%s\n",temp_hostgroupextinfo->action_icon); + if(temp_hostgroupextinfo->target_frame) + fprintf(fp,"\ttarget_frame\t%s\n",temp_hostgroupextinfo->target_frame); + fprintf(fp,"\t}\n\n"); + } + + /* cache service group extended info */ + for(temp_servicegroupextinfo=xodtemplate_servicegroupextinfo_list;temp_servicegroupextinfo!=NULL;temp_servicegroupextinfo=temp_servicegroupextinfo->next){ + if(temp_servicegroupextinfo->register_object==FALSE) + continue; + fprintf(fp,"define servicegroupextinfo {\n"); + if(temp_servicegroupextinfo->servicegroup_name) + fprintf(fp,"\tservicegroup_name\t%s\n",temp_servicegroupextinfo->servicegroup_name); + if(temp_servicegroupextinfo->icon_image) + fprintf(fp,"\ticon_image\t%s\n",temp_servicegroupextinfo->icon_image); + if(temp_servicegroupextinfo->icon_image_alt) + fprintf(fp,"\ticon_image_alt\t%s\n",temp_servicegroupextinfo->icon_image_alt); + if(temp_servicegroupextinfo->notes) + fprintf(fp,"\tnotes\t%s\n",temp_servicegroupextinfo->notes); + if(temp_servicegroupextinfo->notes_url) + fprintf(fp,"\tnotes_url\t%s\n",temp_servicegroupextinfo->notes_url); + if(temp_servicegroupextinfo->action_url) + fprintf(fp,"\taction_url\t%s\n",temp_servicegroupextinfo->action_url); + if(temp_servicegroupextinfo->notes_textinfo) + fprintf(fp,"\tnotes_textinfo\t%s\n",temp_servicegroupextinfo->notes_textinfo); + if(temp_servicegroupextinfo->action_textinfo) + fprintf(fp,"\taction_textinfo\t%s\n",temp_servicegroupextinfo->action_textinfo); + if(temp_servicegroupextinfo->notes_icon) + fprintf(fp,"\tnotes_icon\t%s\n",temp_servicegroupextinfo->notes_icon); + if(temp_servicegroupextinfo->notes_icon_alt) + fprintf(fp,"\tnotes_icon_alt\t%s\n",temp_servicegroupextinfo->notes_icon_alt); + if(temp_servicegroupextinfo->action_icon) + fprintf(fp,"\taction_icon\t%s\n",temp_servicegroupextinfo->action_icon); + if(temp_servicegroupextinfo->action_icon_alt) + fprintf(fp,"\taction_icon_alt\t%s\n",temp_servicegroupextinfo->action_icon); + if(temp_servicegroupextinfo->target_frame) + fprintf(fp,"\ttarget_frame\t%s\n",temp_servicegroupextinfo->target_frame); + fprintf(fp,"\t}\n\n"); + } +#endif // SUPPORT_GROUPEXTINFO + fclose(fp); #ifdef DEBUG0 @@ -9831,6 +11201,12 @@ xodtemplate_hostextinfo *next_hostextinfo; xodtemplate_serviceextinfo *this_serviceextinfo; xodtemplate_serviceextinfo *next_serviceextinfo; +#ifdef SUPPORT_GROUPEXTINFO + xodtemplate_hostgroupextinfo *this_hostgroupextinfo; + xodtemplate_hostgroupextinfo *next_hostgroupextinfo; + xodtemplate_servicegroupextinfo *this_servicegroupextinfo; + xodtemplate_servicegroupextinfo *next_servicegroupextinfo; +#endif // SUPPORT_GROUPEXTINFO int x; #ifdef DEBUG0 @@ -10024,6 +11400,15 @@ free(this_hostextinfo->notes); free(this_hostextinfo->notes_url); free(this_hostextinfo->action_url); +#ifdef SUPPORT_GROUPEXTINFO + free(this_hostextinfo->target_frame); + free(this_hostextinfo->notes_textinfo); + free(this_hostextinfo->action_textinfo); + free(this_hostextinfo->notes_icon); + free(this_hostextinfo->notes_icon_alt); + free(this_hostextinfo->action_icon); + free(this_hostextinfo->action_icon_alt); +#endif // SUPPORT_GROUPEXTINFO free(this_hostextinfo->icon_image); free(this_hostextinfo->icon_image_alt); free(this_hostextinfo->vrml_image); @@ -10043,12 +11428,67 @@ free(this_serviceextinfo->notes); free(this_serviceextinfo->notes_url); free(this_serviceextinfo->action_url); +#ifdef SUPPORT_GROUPEXTINFO + free(this_serviceextinfo->target_frame); + free(this_serviceextinfo->notes_textinfo); + free(this_serviceextinfo->action_textinfo); + free(this_serviceextinfo->notes_icon); + free(this_serviceextinfo->notes_icon_alt); + free(this_serviceextinfo->action_icon); + free(this_serviceextinfo->action_icon_alt); +#endif // SUPPORT_GROUPEXTINFO free(this_serviceextinfo->icon_image); free(this_serviceextinfo->icon_image_alt); free(this_serviceextinfo); } xodtemplate_serviceextinfo_list=NULL; +#ifdef SUPPORT_GROUPEXTINFO + /* free memory allocated to hostgroupextinfo list */ + for(this_hostgroupextinfo=xodtemplate_hostgroupextinfo_list;this_hostgroupextinfo!=NULL;this_hostgroupextinfo=next_hostgroupextinfo){ + next_hostgroupextinfo=this_hostgroupextinfo->next; + free(this_hostgroupextinfo->template); + free(this_hostgroupextinfo->name); + free(this_hostgroupextinfo->hostgroup_name); + free(this_hostgroupextinfo->notes); + free(this_hostgroupextinfo->notes_url); + free(this_hostgroupextinfo->action_url); + free(this_hostgroupextinfo->target_frame); + free(this_hostgroupextinfo->notes_textinfo); + free(this_hostgroupextinfo->action_textinfo); + free(this_hostgroupextinfo->notes_icon); + free(this_hostgroupextinfo->notes_icon_alt); + free(this_hostgroupextinfo->action_icon); + free(this_hostgroupextinfo->action_icon_alt); + free(this_hostgroupextinfo->icon_image); + free(this_hostgroupextinfo->icon_image_alt); + free(this_hostgroupextinfo); + } + xodtemplate_hostgroupextinfo_list=NULL; + + /* free memory allocated to servicegroupextinfo list */ + for(this_servicegroupextinfo=xodtemplate_servicegroupextinfo_list;this_servicegroupextinfo!=NULL;this_servicegroupextinfo=next_servicegroupextinfo){ + next_servicegroupextinfo=this_servicegroupextinfo->next; + free(this_servicegroupextinfo->template); + free(this_servicegroupextinfo->name); + free(this_servicegroupextinfo->servicegroup_name); + free(this_servicegroupextinfo->notes); + free(this_servicegroupextinfo->notes_url); + free(this_servicegroupextinfo->action_url); + free(this_servicegroupextinfo->target_frame); + free(this_servicegroupextinfo->notes_textinfo); + free(this_servicegroupextinfo->action_textinfo); + free(this_servicegroupextinfo->notes_icon); + free(this_servicegroupextinfo->notes_icon_alt); + free(this_servicegroupextinfo->action_icon); + free(this_servicegroupextinfo->action_icon_alt); + free(this_servicegroupextinfo->icon_image); + free(this_servicegroupextinfo->icon_image_alt); + free(this_servicegroupextinfo); + } + xodtemplate_servicegroupextinfo_list=NULL; +#endif // SUPPORT_GROUPEXTINFO + /* free memory for the config file names */ for(x=0;xgroup_name),sizeof(output_buffer)-strlen(output_buffer)-1); + } + in_macro=FALSE; + } + } + + printf("%s",output_buffer); + return; + } + +void print_extra_servicegroup_url(char *servicegroup_name, char *url){ + char input_buffer[MAX_INPUT_BUFFER]=""; + char output_buffer[MAX_INPUT_BUFFER]=""; + char *temp_buffer; + int in_macro=FALSE; + servicegroup *temp_servicegroup; + + if(servicegroup_name==NULL || url==NULL) + return; + + temp_servicegroup=find_servicegroup(servicegroup_name); + if(temp_servicegroup==NULL){ + printf("%s",url); + return; + } + + strncpy(input_buffer,url,sizeof(input_buffer)-1); + output_buffer[sizeof(input_buffer)-1]='\x0'; + + for(temp_buffer=my_strtok(input_buffer,"$");temp_buffer!=NULL;temp_buffer=my_strtok(NULL,"$")){ + if(in_macro==FALSE){ + if(strlen(output_buffer)+strlen(temp_buffer)group_name),sizeof(output_buffer)-strlen(output_buffer)-1); + } + in_macro=FALSE; + } + } + + printf("%s",output_buffer); + return; + } +#endif // SUPPORT_GROUPEXTINFO /* include user-defined SSI footers or headers */ --- nagios-2.8.orig/cgi/config.c 2006-03-21 13:31:46.000000000 -0800 +++ nagios-2.8/cgi/config.c 2007-03-28 14:18:31.000000000 -0700 @@ -51,7 +51,10 @@ extern hostescalation *hostescalation_list; extern hostextinfo *hostextinfo_list; extern serviceextinfo *serviceextinfo_list; - +#ifdef SUPPORT_GROUPEXTINFO +extern hostgroupextinfo *hostgroupextinfo_list; +extern servicegroupextinfo *servicegroupextinfo_list; +#endif // SUPPORT_GROUPEXTINFO #define DISPLAY_NONE 0 #define DISPLAY_HOSTS 1 @@ -69,6 +72,10 @@ #define DISPLAY_HOSTEXTINFO 13 #define DISPLAY_SERVICEEXTINFO 14 #define DISPLAY_SERVICEGROUPS 15 +#ifdef SUPPORT_GROUPEXTINFO +#define DISPLAY_HOSTGROUPEXTINFO 16 +#define DISPLAY_SERVICEGROUPEXTINFO 17 +#endif // SUPPORT_GROUPEXTINFO void document_header(int); void document_footer(void); @@ -90,6 +97,10 @@ void display_hostescalations(void); void display_hostextinfo(void); void display_serviceextinfo(void); +#ifdef SUPPORT_GROUPEXTINFO +void display_hostgroupextinfo(void); +void display_servicegroupextinfo(void); +#endif // SUPPORT_GROUPEXTINFO void unauthorized_message(void); @@ -177,6 +188,10 @@ printf("