servicegroup shortcut in servicedependency doesn't work

Michael Durket durket at hw-durket.stanford.edu
Thu Aug 24 23:37:29 CEST 2006


If one attempts to specify the following in Nagios:

define servicedependency {
servicegroup_name               X           
dependent_host_name             Y
dependent_service_description   Z
execution_failure_criteria      w,u,c
notification_failure_criteria   w,u,c
}

it generates the error:

Error: Could not expand master hostgroups and/or hosts specified in service dependency 
(config file 'config.cfg', starting on line ....

The following patch corrects the problem (based on the version of xodtemplate.c supplied 
with the Nagios 2.5 release). However please note I'm not that familiar with all the 
various machinations that xodtemplate.c is going through, so there is always the possibility
I've seriously misinterpreted the developer's intentions as to how servicegroup names were
supposed to be expanded in servicedependencies.

--- xdata/xodtemplate.original	2006-07-10 12:20:24.000000000 -0700
+++ xdata/xodtemplate.c	2006-08-24 14:27:01.000000000 -0700
@@ -4119,6 +4119,8 @@
 	for(temp_servicedependency=xodtemplate_servicedependency_list;temp_servicedependency!=NULL;temp_servicedependency=temp_servicedependency->next){
 
 		/* skip service dependencies without enough data */
+		if(temp_servicedependency->hostgroup_name==NULL && temp_servicedependency->dependent_hostgroup_name==NULL && temp_servicedependency->servicegroup_name!=NULL)
+			continue;
 		if(temp_servicedependency->hostgroup_name==NULL && temp_servicedependency->dependent_hostgroup_name==NULL && temp_servicedependency->host_name==NULL && temp_servicedependency->dependent_host_name==NULL)
 			continue;
 
@@ -4178,9 +4180,9 @@
 	/* THIS MUST BE DONE AFTER DUPLICATING FOR MULTIPLE HOST NAMES (SEE ABOVE) */
 	for(temp_servicedependency=xodtemplate_servicedependency_list;temp_servicedependency!=NULL;temp_servicedependency=temp_servicedependency->next){
 
-		/* skip servicedependencies without enough data */
-		if(temp_servicedependency->service_description==NULL || temp_servicedependency->host_name==NULL)
-			continue;
+	        /* skip servicedependencies without enough data */
+	        if (temp_servicedependency->service_description==NULL && temp_servicedependency->host_name==NULL && temp_servicedependency->servicegroup_name==NULL)
+	           continue;
 
 		/* get list of services */
 		temp_servicelist=xodtemplate_expand_servicegroups_and_services(temp_servicedependency->servicegroup_name,temp_servicedependency->host_name,temp_servicedependency->service_description);
@@ -4200,6 +4202,7 @@
 			/* if this is the first duplication, use the existing entry */
 			if(first_item==TRUE){
 
+   			        free(temp_servicedependency->host_name);
 				free(temp_servicedependency->service_description);
 				temp_servicedependency->service_description=strdup(this_servicelist->service_description);
 				if(temp_servicedependency->service_description==NULL){
@@ -4207,12 +4210,17 @@
 					return ERROR;
 				        }
 
+                                temp_servicedependency->host_name=strdup(this_servicelist->host_name);
+				if(temp_servicedependency->host_name==NULL){
+					xodtemplate_free_servicelist(temp_servicelist);
+					return ERROR;
+				        }
 				first_item=FALSE;
 				continue;
 			        }
 
 			/* duplicate service escalation definition */
-			result=xodtemplate_duplicate_servicedependency(temp_servicedependency,temp_servicedependency->host_name,this_servicelist->service_description,temp_servicedependency->dependent_host_name,temp_servicedependency->dependent_service_description);
+			result=xodtemplate_duplicate_servicedependency(temp_servicedependency,this_servicelist->host_name,this_servicelist->service_description,temp_servicedependency->dependent_host_name,temp_servicedependency->dependent_service_description);
 
 			/* exit on error */
 			if(result==ERROR){

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the Developers mailing list