Re: [Nagios-devel] Mass define servicedependency for NRPE services
Posted: Wed Sep 02, 2009 9:15 pm
This is a multi-part message in MIME format.
--------------030400090200070903050904
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
On 9/2/09 5:40 PM, Mathieu Gagné wrote:
> You will find attached to this message a patch against Nagios 3.0.6 that
> should fix this bug.
Fixed typo. :-/
--
Mathieu
--------------030400090200070903050904
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="nagios-same-host-servicedependencies-with-servicegroups.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="nagios-same-host-servicedependencies-with-servicegroups.patc";
filename*1="h"
diff -Naur nagios-3.0.6-orig/xdata/xodtemplate.c nagios-3.0.6/xdata/xodtemplate.c
--- nagios-3.0.6-orig/xdata/xodtemplate.c 2009-09-02 17:15:52.000000000 -0400
+++ nagios-3.0.6/xdata/xodtemplate.c 2009-09-02 17:21:55.000000000 -0400
@@ -5247,6 +5247,7 @@
char *service_descriptions=NULL;
int first_item=FALSE;
+ int same_host_servicedependency=FALSE;
/*************************************/
@@ -5725,6 +5726,11 @@
my_free(temp_servicedependency->dependent_service_description);
my_free(temp_servicedependency->dependent_hostgroup_name);
}
+
+ /* MG(20090902): Same host servicegroups dependencies */
+ same_host_servicedependency=FALSE;
+ if(temp_servicedependency->host_name==NULL && temp_servicedependency->hostgroup_name==NULL)
+ same_host_servicedependency=TRUE;
/* duplicate service dependency entries */
first_item=TRUE;
@@ -5742,6 +5748,10 @@
my_free(temp_servicedependency->dependent_service_description);
temp_servicedependency->dependent_service_description=(char *)strdup(temp_dependentservice->name2);
+
+ /* MG(20090902): Same host servicegroups dependencies */
+ if(same_host_servicedependency==TRUE)
+ temp_servicedependency->host_name=(char *)strdup(temp_dependentservice->name1);
/* clear the dependent servicegroup */
temp_servicedependency->have_dependent_servicegroup_name=FALSE;
@@ -5757,7 +5767,11 @@
}
/* duplicate service dependency definition */
- result=xodtemplate_duplicate_servicedependency(temp_servicedependency,temp_servicedependency->host_name,temp_servicedependency->service_description,NULL,NULL,temp_dependentservice->name1,temp_dependentservice->name2,NULL,NULL);
+ /* MG(20090902): Same host servicegroups dependencies */
+ if(same_host_servicedependency==TRUE)
+ result=xodtemplate_duplicate_servicedependency(temp_servicedependency,temp_dependentservice->name1,temp_servicedependency->service_description,NULL,NULL,temp_dependentservice->name1,temp_dependentservice->name2,NULL,NULL);
+ else
+ result=xodtemplate_duplicate_servicedependency(temp_servicedependency,temp_servicedependency->host_name,temp_servicedependency->service_description,NULL,NULL,temp_dependentservice->name1,temp_dependentservice->name2,NULL,NULL);
/* exit on error */
if(result==ERROR){
--------------030400090200070903050904--
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
--------------030400090200070903050904
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
On 9/2/09 5:40 PM, Mathieu Gagné wrote:
> You will find attached to this message a patch against Nagios 3.0.6 that
> should fix this bug.
Fixed typo. :-/
--
Mathieu
--------------030400090200070903050904
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="nagios-same-host-servicedependencies-with-servicegroups.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="nagios-same-host-servicedependencies-with-servicegroups.patc";
filename*1="h"
diff -Naur nagios-3.0.6-orig/xdata/xodtemplate.c nagios-3.0.6/xdata/xodtemplate.c
--- nagios-3.0.6-orig/xdata/xodtemplate.c 2009-09-02 17:15:52.000000000 -0400
+++ nagios-3.0.6/xdata/xodtemplate.c 2009-09-02 17:21:55.000000000 -0400
@@ -5247,6 +5247,7 @@
char *service_descriptions=NULL;
int first_item=FALSE;
+ int same_host_servicedependency=FALSE;
/*************************************/
@@ -5725,6 +5726,11 @@
my_free(temp_servicedependency->dependent_service_description);
my_free(temp_servicedependency->dependent_hostgroup_name);
}
+
+ /* MG(20090902): Same host servicegroups dependencies */
+ same_host_servicedependency=FALSE;
+ if(temp_servicedependency->host_name==NULL && temp_servicedependency->hostgroup_name==NULL)
+ same_host_servicedependency=TRUE;
/* duplicate service dependency entries */
first_item=TRUE;
@@ -5742,6 +5748,10 @@
my_free(temp_servicedependency->dependent_service_description);
temp_servicedependency->dependent_service_description=(char *)strdup(temp_dependentservice->name2);
+
+ /* MG(20090902): Same host servicegroups dependencies */
+ if(same_host_servicedependency==TRUE)
+ temp_servicedependency->host_name=(char *)strdup(temp_dependentservice->name1);
/* clear the dependent servicegroup */
temp_servicedependency->have_dependent_servicegroup_name=FALSE;
@@ -5757,7 +5767,11 @@
}
/* duplicate service dependency definition */
- result=xodtemplate_duplicate_servicedependency(temp_servicedependency,temp_servicedependency->host_name,temp_servicedependency->service_description,NULL,NULL,temp_dependentservice->name1,temp_dependentservice->name2,NULL,NULL);
+ /* MG(20090902): Same host servicegroups dependencies */
+ if(same_host_servicedependency==TRUE)
+ result=xodtemplate_duplicate_servicedependency(temp_servicedependency,temp_dependentservice->name1,temp_servicedependency->service_description,NULL,NULL,temp_dependentservice->name1,temp_dependentservice->name2,NULL,NULL);
+ else
+ result=xodtemplate_duplicate_servicedependency(temp_servicedependency,temp_servicedependency->host_name,temp_servicedependency->service_description,NULL,NULL,temp_dependentservice->name1,temp_dependentservice->name2,NULL,NULL);
/* exit on error */
if(result==ERROR){
--------------030400090200070903050904--
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]