[Nagios-devel] [PATCH] Service escalations and negated service

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] Service escalations and negated service

Post by Guest »

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

Good morning everyone!

We have run into an interesting situation trying to set up some service
escalations, and I BELIEVE the attached patch is an appropriate general
fix, but would appreciate any comments or additional thoughts. First,
an explanation of what I'm trying to do:

I would like to have service escalations defined for all services except
"NTP Time Offset" on all hosts not in the "gtpods" hostgroup. To
accomplish this, I had defined my service escalation as follows:

define serviceescalation {
host_name *
hostgroup_name !gtpods
service_description *,!NTP Time Offset
first_notification 1
last_notification 5
notification_interval 10
contact_groups admins,oncall
}

Under stock Nagios 3.2.0, this fails with the following error, because
not all hosts have an "NTP Time Offset" service defined:

Error: Could not find a service matching host name 'servXX' and
description 'NTP Time Offset' (config file
'/usr/local/nagios-3.2.0/etc/objects/escalations.cfg', starting on line 62)
Error: Could not expand services specified in service escalation (config
file '/usr/local/nagios-3.2.0/etc/objects/escalations.cfg', starting on
line 62)
Error processing object config files!

As the code stands today, when expanding service escalations, if a
negated service is not attached to the host in question, it returns this
error. But in my opinion, a negated service that would wind up on the
reject list can just be silently ignored when it doesn't exist on a
host, because the behavior is identical, and in fact more intuitive to
the configuration writer.

The attached patch simply adds a check of reject_item to two
conditionals within xodtemplate_expand_services, which I believe should
make this work in the way that I perceive as intuitive without
compromising any other configuration scenarios. I have tested my
specific scenario and the configuration is built as I would expect and
intend. I'm happy to receive any feedback, thoughts on better ways to
accomplish this, etc!

Thanks,
Tim Wilde

--------------030508000702050602090707
Content-Type: text/plain;
name="xodtemplate.c.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="xodtemplate.c.patch"

--- xdata/xodtemplate.c.orig 2009-10-05 14:36:43.000000000 +0000
+++ xdata/xodtemplate.c 2009-10-05 14:44:55.000000000 +0000
@@ -14378,7 +14378,7 @@
}

/* we didn't find a match */
- if(found_match==FALSE){
+ if(found_match==FALSE && reject_item==FALSE){
#ifdef NSCORE
logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not find a service matching host name '%s' and description '%s' (config file '%s', starting on line %d)\n",host_name,temp_ptr,xodtemplate_config_file_name(_config_file),_start_line);
#endif
@@ -14390,7 +14390,7 @@
regfree(&preg2);
my_free(service_names);

- if(found_match==FALSE)
+ if(found_match==FALSE && reject_item==FALSE)
return ERROR;

return OK;

--------------030508000702050602090707--





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