[Nagios-devel] [PATCH] Fix to allow incomplete service dependency

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] [PATCH] Fix to allow incomplete service dependency

Post by Guest »

This is a multi-part message in MIME format.
--------------040906030505080106070805
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

The attached patch fixes a problem with parsing service dependency
templates that specify "hostgroups" without "dependent_hostgroups" or
vice versa. The following config snippet triggers the bug:

define host {
use generic-host ; generic host template omitted for brevity
host_name b
}

define hostgroup {
hostgroup_name test-hg
alias test-hg
members a,b
}

define servicedependency {
register 0
name base-sd
hostgroups test-hg
}

Since it's not a registered object, the servicedependency template should be
valid, but Nagios reports "Could not expand dependent hostgroups and/or
hosts
specified in service dependency" instead.

This patch applies to both Nagios 2.5 and 2.6.

Jason Hoos



--------------040906030505080106070805
Content-Type: text/plain;
name="nagios-2.5-partial-deps-fix.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios-2.5-partial-deps-fix.diff"

The attached patch fixes a problem with parsing service dependency templates that specify "hostgroups" without "dependent_hostgroups" or vice versa. The following config snippet triggers the bug:

define host {
use generic-host
host_name b
}

define hostgroup {
hostgroup_name test-hg
members a,b
}

define servicedependency {
register 0
name base-sd
hostgroups test-hg
}

Since it's a template and not a full object, the servicedependency should be
valid, but Nagios reports "Could not expand dependent hostgroups and/or hosts
specified in service dependency" instead.


*** nagios-2.5/xdata/xodtemplate.c.orig Wed Oct 11 23:13:45 2006
--- nagios-2.5/xdata/xodtemplate.c Wed Oct 11 23:17:23 2006
***************
*** 4060,4066 ****
for(temp_hostdependency=xodtemplate_hostdependency_list;temp_hostdependency!=NULL;temp_hostdependency=temp_hostdependency->next){

/* skip host dependencies without enough data */
! if(temp_hostdependency->hostgroup_name==NULL && temp_hostdependency->dependent_hostgroup_name==NULL && temp_hostdependency->host_name==NULL && temp_hostdependency->dependent_host_name==NULL)
continue;

/* get list of master host names */
--- 4060,4066 ----
for(temp_hostdependency=xodtemplate_hostdependency_list;temp_hostdependency!=NULL;temp_hostdependency=temp_hostdependency->next){

/* skip host dependencies without enough data */
! if((temp_hostdependency->hostgroup_name==NULL && temp_hostdependency->host_name==NULL) || (temp_hostdependency->dependent_hostgroup_name==NULL && temp_hostdependency->dependent_host_name==NULL))
continue;

/* get list of master host names */
***************
*** 4119,4125 ****
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->host_name==NULL && temp_servicedependency->dependent_host_name==NULL)
continue;

/* get list of master host names */
--- 4119,4125 ----
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->host_name==NULL) || (temp_servicedependency->dependent_hostgroup_name==NULL && temp_servicedependency->dependent_host_name==NULL))
continue;

/* get list of master host names */

--------------040906030505080106070805--






This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked