[Nagios-devel] Patch to fix some 2.0 duplication issues with objects using servicegroup_name lines
Posted: Thu Mar 25, 2004 11:12 am
This is a multi-part message in MIME format.
------=_NextPart_000_001E_01C41272.E5BBAC30
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi, all.
It looks like there are some issues in Nagios 2.0 in the
xodtemplate_duplicate_objects function with regards to duplicating
service escalations and service dependencies which use
"servicegroup_name" to specify the services to use. The attached patch
fixes most of these issues (but I think that a few may remain).
!! A WORD OF CAUTION: this patch is POORLY TESTED....
With service escalations, if you use both
host/hostgroup/service_descriptions AND servicegroups to specify
services in the same escalation definition, it would be possible to end
up with multiple escalations duplicates which are exactly the same.
After the patch, this is still possible, but it happens under fewer
circumstances (only if multiple hosts are specified AND a servicegroup
which has multiple services). This may not even be harmful to other
Nagios internals, I'm not sure....
With service dependencies, if you use both
host/hostgroup/service_descriptions AND servicegroups to specify the
master (or dependent) services, there existed a problem where sometimes
the wrong service got duplicated (a service with its host_name take from
the host/hostgroups, and its service_description from the servicegroups,
which may not even be an existent service). This is fixed, but the same
issue that exists with service escalations described above still exists
with service dependencies.
Lastly, with service dependencies, it was not possible to specify the
master service(s) using host/hostgroup/service_descriptions, and the
dependent service(s) using servicegroups (or vice versa). In other
words, before the patch, this wasn't allowed:
define servicedependency{
host_name master_host
service_description master_service
dependent_servicegroup_name list_of_dependent_services
}
As for the remaining issues I mentioned, I don't know how to fix them
without significant rewrites. The only thing I can think of doing is
adding host expansion capabilities to the xodtemplate_expand_services
function, and then rewriting xodtemplate_duplicate_objects to make use
of these new capabilities to do host expansion (via calls to
xodtemplate_expand_servicegroups_and_services) instead of doing it
separately with xodtemplate_expand_hostgroups_and_hosts. Maybe there's a
better way I'm not seeing... (and maybe this is too minor a bug to worry
about at this point)
Regards,
Chris
------=_NextPart_000_001E_01C41272.E5BBAC30
Content-Type: application/octet-stream;
name="nagios-duplication-with-servicegroups.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="nagios-duplication-with-servicegroups.patch"
*** ../nagios-orig/xdata/xodtemplate.c Wed Mar 24 23:28:31 2004=0A=
--- xdata/xodtemplate.c Thu Mar 25 13:20:55 2004=0A=
***************=0A=
*** 3662,3677 ****=0A=
}=0A=
=0A=
=0A=
! /****** DUPLICATE SERVICE ESCALATION DEFINITIONS WITH MULTIPLE =
DESCRIPTIONS ******/=0A=
/* THIS MUST BE DONE AFTER DUPLICATING FOR MULTIPLE HOST NAMES (SEE =
ABOVE) */=0A=
=
for(temp_serviceescalation=3Dxodtemplate_serviceescalation_list;temp_serv=
iceescalation!=3DNULL;temp_serviceescalation=3Dtemp_serviceescalation->ne=
xt){=0A=
=0A=
/* skip serviceescalations without enough data */=0A=
! if(temp_serviceescalation->service_description=3D=3DNULL || =
temp_serviceescalation->host_name=3D=3DNULL)=0A=
continue;=0A=
=0A=
/* get list of services */=0A=
! =
temp_servicelist=3Dxodtemplate_expand_servicegroups_and_services(NULL,tem=
p_serviceescalation->host_name,temp_serviceescalation->service_descriptio=
n);=0A=
if(temp_servicelist=3D=3DNULL){=0A=
#ifdef NSCORE=0A=
snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not expand =
services specified in service escalation (config file '%s', starting on =
line =
%d)\n",xodtemplate_config_file_name(temp_serviceescalation->_config_file)=
,temp_serviceescalation->_start_line);=0A=
--- 3662,3677 ----=0A=
}=0A=
=0A=
=
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
------=_NextPart_000_001E_01C41272.E5BBAC30
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi, all.
It looks like there are some issues in Nagios 2.0 in the
xodtemplate_duplicate_objects function with regards to duplicating
service escalations and service dependencies which use
"servicegroup_name" to specify the services to use. The attached patch
fixes most of these issues (but I think that a few may remain).
!! A WORD OF CAUTION: this patch is POORLY TESTED....
With service escalations, if you use both
host/hostgroup/service_descriptions AND servicegroups to specify
services in the same escalation definition, it would be possible to end
up with multiple escalations duplicates which are exactly the same.
After the patch, this is still possible, but it happens under fewer
circumstances (only if multiple hosts are specified AND a servicegroup
which has multiple services). This may not even be harmful to other
Nagios internals, I'm not sure....
With service dependencies, if you use both
host/hostgroup/service_descriptions AND servicegroups to specify the
master (or dependent) services, there existed a problem where sometimes
the wrong service got duplicated (a service with its host_name take from
the host/hostgroups, and its service_description from the servicegroups,
which may not even be an existent service). This is fixed, but the same
issue that exists with service escalations described above still exists
with service dependencies.
Lastly, with service dependencies, it was not possible to specify the
master service(s) using host/hostgroup/service_descriptions, and the
dependent service(s) using servicegroups (or vice versa). In other
words, before the patch, this wasn't allowed:
define servicedependency{
host_name master_host
service_description master_service
dependent_servicegroup_name list_of_dependent_services
}
As for the remaining issues I mentioned, I don't know how to fix them
without significant rewrites. The only thing I can think of doing is
adding host expansion capabilities to the xodtemplate_expand_services
function, and then rewriting xodtemplate_duplicate_objects to make use
of these new capabilities to do host expansion (via calls to
xodtemplate_expand_servicegroups_and_services) instead of doing it
separately with xodtemplate_expand_hostgroups_and_hosts. Maybe there's a
better way I'm not seeing... (and maybe this is too minor a bug to worry
about at this point)
Regards,
Chris
------=_NextPart_000_001E_01C41272.E5BBAC30
Content-Type: application/octet-stream;
name="nagios-duplication-with-servicegroups.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="nagios-duplication-with-servicegroups.patch"
*** ../nagios-orig/xdata/xodtemplate.c Wed Mar 24 23:28:31 2004=0A=
--- xdata/xodtemplate.c Thu Mar 25 13:20:55 2004=0A=
***************=0A=
*** 3662,3677 ****=0A=
}=0A=
=0A=
=0A=
! /****** DUPLICATE SERVICE ESCALATION DEFINITIONS WITH MULTIPLE =
DESCRIPTIONS ******/=0A=
/* THIS MUST BE DONE AFTER DUPLICATING FOR MULTIPLE HOST NAMES (SEE =
ABOVE) */=0A=
=
for(temp_serviceescalation=3Dxodtemplate_serviceescalation_list;temp_serv=
iceescalation!=3DNULL;temp_serviceescalation=3Dtemp_serviceescalation->ne=
xt){=0A=
=0A=
/* skip serviceescalations without enough data */=0A=
! if(temp_serviceescalation->service_description=3D=3DNULL || =
temp_serviceescalation->host_name=3D=3DNULL)=0A=
continue;=0A=
=0A=
/* get list of services */=0A=
! =
temp_servicelist=3Dxodtemplate_expand_servicegroups_and_services(NULL,tem=
p_serviceescalation->host_name,temp_serviceescalation->service_descriptio=
n);=0A=
if(temp_servicelist=3D=3DNULL){=0A=
#ifdef NSCORE=0A=
snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not expand =
services specified in service escalation (config file '%s', starting on =
line =
%d)\n",xodtemplate_config_file_name(temp_serviceescalation->_config_file)=
,temp_serviceescalation->_start_line);=0A=
--- 3662,3677 ----=0A=
}=0A=
=0A=
=
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]