2.0 Nagios CVS - Service Dependencies Patch - bug fixes and new features

Mueller, Karl KMueller at netsuite.com
Tue Apr 20 03:28:02 CEST 2004


Hello All,

I wrote a few weeks ago the list asking some questions about service
dependencies, because the way they are currently defined, I find them
very hard to use for our typical needs.  A typical example is an Oracle
SQL check which does something (perhaps checks redo log status).  It
should not run the check if Oracle is down, right?  Service dependencies
to the rescue!  Unfortunately, if you have a large group of host - we
have 50 in this group, for example - you can't tell Nagios that every
Oracle Redo Log check depends on its OWN Oracle check without defining
50 service dependencies.  That is a pain, and we probably have 6 or 7
dependencies on each host on its own services, if not more.

Instead of writing some kind of configuration script to do this for me,
I decided to just write a patch to do it.  There are two main features
to the patch:

1) If a "host_name" entry in a servicedependency definition is "SELF"
(any capitalization), then every host in the host_name, host_group, or
service_group line will receive a dependency instance against ITSELF
ONLY with the appropriate service name.  An example configs:

####
#### Depend on 'Oracle' service on our own service
####


define servicedependency {

        use                             defaults

        dependent_service_description   Oracle Failed Logins
        dependent_hostgroup_name        s_prod_oracle

        service_description             Oracle
        host_name                       SELF

}

This creates dependencies for every host in "s_prod_oracle" on ITSELF
for the "Oracle Failed Logins" service on the "Oracle" service.  It's
exactly the same as if you took every host in "s_prod_oracle" and
defined a servicedependency object with its own host_name in it.  ('N'
objects)

2) Something similar, but slightly different:  if you set a new config
variable "peer_groups", indicating that the two groups you're going to
specify are "peers" to each other, Nagios will create one to one
dependencies instead of many to many dependencies.  Example:


define servicedependency {

        use                             defaults

        dependent_service_description   Oracle Failed Logins
        dependent_hostgroup_name        s_prod_oracle

        service_description             Oracle
        host_name                       s_prod_oracle

	  peer_groups				1

}

Is functionally equivilant to the first example.  If you have:

dependent_host_name	A, B, C, D
host_name			M, N, O, P

Nagios would *normally* create dependencies: "A:M, A:N, A:O, A:P, B:M,
B:N...", etc.

With "peer_groups" enabled, Nagios will now create: "A:M, B:N, C:O, D:P"
ONLY.  

Of course, with this option set, the number of hosts that are eventually
resolved from expansion of hostgroup(s)/servicegroup(s) MUST BE EQUAL.  

How is this useful?  Besides creating "self" dependencies as above
(which are better handled through 'self'), you can reverse the group
names or hosts, etc., to do some interesting things.

3) Fixes a bug where inherits_parent was not initialized in
xodtemplate_duplicate_servicedependency() in xodtemplate.c

 
4) Fixes a bug where value of inherits_parent() was not verified to be 0
or 1  (hiding bug #3 while I was verifying this patch :(  ) (objects.c)

The patch is located at, and is made against the 2.0 CVS tree as of
today:

http://www.xney.com/nagios/nagios-2.0-servicedep.patch


I have tested this patch in positive and negative cases, but I'd love to
hear if people could use it and have verified it works (or doesn't break
anything).

-Karl









-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click




More information about the Developers mailing list