Same Host Dependencies With Servicegroups

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.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Same Host Dependencies With Servicegroups

Post by eloyd »

My turn to ask a question. We had a minor meltdown with one of our virtual hosts still being reachable via ping, but having the out-of-memory reaper start blowing away services. So we had a lot of alerts that could have been avoided if we'd just seen the "out of memory" errors in all the weeds. The host (and others like it) are checked via NRPE. They belong to a hostgroup called "private" and the services that rely on NRPE being functional belong to a servicegroup called "NRPE". There is also a service check that simply checks to see if NRPE is responding called "NRPE-service". This is all on Nagios Core 4.0.7.

Enter Time-Saving Tricks For Object Definitions and the section on "Same Host Dependencies With Servicegroups" (last one in the section).

I believe we should be able to specify our dependency (to make NRPE-dependent checks depend on the NRPE service being up and running) as:

Code: Select all

define servicedependency{
        service_description             NRPE:service
        dependent_servicegroup_name     NRPE
        <remainder of dependency code>
}
to make each service in the NRPE servicegroup dependent on the NRPE-service on that host.

This sort of works. What we get is each service in the NRPE servicegroup on each host being dependent upon the NRPE-service but only on the last host listed in the hosts config file that has services that match the service group. This was confirmed by moving the order around in the config file. So we added hostgroup_name to the list:

Code: Select all

define servicedependency{
        hostgroup_name                  private
        service_description             NRPE:service
        dependent_servicegroup_name     NRPE
        <remainder>
}
And it's the same thing. We tried using combinations of hostgroup_name, host_name, dependent_hostgroup_name and dependent_host_name, but many combinations were outright rejected by the parser, while the closest we could get to what we want is the two excerpts above - straight out of the documentation example.

I'd really like to avoid having to list all the service_descriptions (which works, if we use the hostgroup_name directive), and since this is a direct implementation of what's listed in the documentation, I believe it's a bug in the parser. But if it's not, and we're doing something wrong, please let me know.

Code: Select all

Nagios® Core™
Version 4.0.7
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Same Host Dependencies With Servicegroups

Post by sreinhardt »

To start off, there are a few (hopefully minor) known issues with config parsing at the moment and service dependencies is one thing that is hit by it. Mainly with hosts and hostgroups not exclusively working within a service dependency. They aren't being worked on presently, other issues are taking priority, but they are know and on our radar. However this idea that only the last host list or last host in a hostgroup listed matters for all dependencies is very odd! It would seem to me that the services for a host should only be dependent on other services for that host, and not inclusive of other hosts services within the same service dependency config. However I do understand there is also a likely need for services on different hosts to be dependent, but thats another thing. Is it possible for you to shoot over a few different configs and examples of what isn't working and how you expected it to work so we can make sure we are 100% on the same page here?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Same Host Dependencies With Servicegroups

Post by eloyd »

I'll try to get you on the same page without throwing out too much of our internal private network. And let me preface this with saying that this is the first time since 2004 that we have not been able to get Nagios Core to do what we think it should do. :-)

Hosts A, B, and C are in a hostgroup called "private." Nagios host is X. Service checks 1, 2, and 3 are in a service group called NRPE, and are checked from X->A, X->B, and X->C via NRPE. In real life, add some zeros to the number of checks and hosts, but the idea is the same. Now, X also checks A, B, and C via a direct check (via check_nrpe with no arguments) to ensure that NRPE is running. This check is called NRPE-service.

All the NRPE service checks on A need to be dependent the NRPE-service check being OK. Same for all the NRPE services on B (need to make sure that NRPE-service on B is OK) and same for C. According to the documentation I quoted, we should be able to do something like this:

Code: Select all

define hostgroup{
        hostgroup_name  private
        alias           Private Hosts
}

define host{
        use private-host-template
        host_name A
        hostgroups private
}

<REPEAT FOR B AND C>

define servicegroup{
        servicegroup_name       NRPE
        alias                   Services dependent upon NRPE
}

define service{
        use                     nrpe-service
        service_description     SERVICE CHECK 1
        hostgroups              private
        servicegroups           NRPE
        check_command           check_nrpe!<command>!params|etc
}

<REPEAT FOR SERVICE CHECK 2 AND 3>

define servicedependency{
        hostgroup_name                  private
        service_description             NRPE-service
        dependent_servicegroup_name     NRPE
        inherits_parent                 1
        execution_failure_criteria      u,c
}
And if I parse the documentation correctly, we should end up with dependencies like:

Code: Select all

S1 on A dependent upon NRPE-service on A being OK
S2 on A dependent upon NRPE-service on A being OK
S3 on A dependent upon NRPE-service on A being OK
S1 on B dependent upon NRPE-service on B being OK
S2 on B dependent upon NRPE-service on B being OK
S3 on B dependent upon NRPE-service on B being OK
S1 on C dependent upon NRPE-service on C being OK
S2 on C dependent upon NRPE-service on C being OK
S3 on C dependent upon NRPE-service on C being OK
What we get is:

Code: Select all

S1 on A dependent upon NRPE-service on C being OK
S2 on A dependent upon NRPE-service on C being OK
S3 on A dependent upon NRPE-service on C being OK
S1 on B dependent upon NRPE-service on C being OK
S2 on B dependent upon NRPE-service on C being OK
S3 on B dependent upon NRPE-service on C being OK
S1 on C dependent upon NRPE-service on C being OK
S2 on C dependent upon NRPE-service on C being OK
S3 on C dependent upon NRPE-service on C being OK
Note that host C was the last host defined. If we switch the order of the "define host" config snippets so that C is defined first, then A, then B, then everything in the previous CODE section will be dependent upon NRPE-service on B being OK.

My goal is to avoid listing specific services and just use the service group. So I figure, okay, this isn't parsing as I expect it to, so let's do each one host-by-host:

Code: Select all

define servicedependency{
        host_name                       A
        dependent_host_name             A
        service_description             NRPE-service
        dependent_servicegroup_name     NRPE
        inherits_parent                 1
        execution_failure_criteria      u,c
}

<REPEAT FOR HOST B AND C>
Now the parser complains:
Error: Could not expand dependent service(s) (at config file '<dependency file>', starting on line 1)
(line 1 is the first line of the dependencies file)

So, whew! Even trying to use just the service group on each individual host doesn't work. So we tried using the hostgroup on each individual service:

Code: Select all

define servicedependency{
        hostgroup_name                  private
        service_description             NRPE-service
        dependent_service_description   1,2,3
        inherits_parent                 1
        execution_failure_criteria      u,c
}
And that works as desired (yay!). Except, as much as we have our Nagios automated and integrated with things, we don't want to have to change dependencies to add a new service every time we add a new service - that's the point of servicegroups! So I'd love to know if we're doing something wrong or if it's the parser.
Last edited by eloyd on Mon Jul 21, 2014 7:23 pm, edited 1 time in total.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Same Host Dependencies With Servicegroups

Post by eloyd »

Bump.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Same Host Dependencies With Servicegroups

Post by slansing »

Hey Eric,

Sorry for the delay, we're going to need to do some testing on our end, it's sounding like the config parser is where the issue lays. Thank you for elaborating so much, it will make this a lot easier to set up. Any additional details you want to share are more than welcome! We will keep this open in case some one else runs into this while we test. Hopefully we will have something fairly soon.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Same Host Dependencies With Servicegroups

Post by eloyd »

I can't resist. Have to ask. Any results from testing yet? :twisted:
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Same Host Dependencies With Servicegroups

Post by slansing »

Yeah my apologies for not getting an update to you, I've gotten some of this set up on a core 4.0.8 system, unfortunately I was out the past two weeks (that is why I did not update you). Have you found anything else out through testing at all?
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Same Host Dependencies With Servicegroups

Post by eloyd »

No, but I've been too busy answering other people's questions than to try to figure out a low-priority issue of my own. :)

No worries.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Same Host Dependencies With Servicegroups

Post by abrist »

We have yet to hear back from Eric or Sam on this. Maybe tomorrow?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Same Host Dependencies With Servicegroups

Post by eloyd »

Tell Mr. Stanley that I said I'll buy him a beer if he fixes it by October 13th. ;-)
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
Locked