Page 1 of 1

Servicegroups ignore services assigned via hostgroups

Posted: Fri Sep 09, 2016 1:04 pm
by eloyd
I never really got why servicegroups exist, since they don't seem to do much except for reporting. Be that as it may, in our XI 5.2.9 customer demo box, we wanted to showcase how easy things are to add in the future. So this is what we did:

Create a hostgroup called "Cars" into which we put the hosts Ford, Chevy, and Lexus. Then we created a service check called "check_gas_tank" with the config name of "Car Stuff" and assigned it to the Cars hostgroup. So far, so good, all the hosts are checking their gas. So then we create a service check called "check_emissions" and do the same thing. Then another called "check_inspection" and another called "check_tires" and another called "check_oil" and do the same thing. Yay. In the future, if we get a new car, like a Hyundai, we can add it to the Cars host group and everything is groovy.

But now we want to make a service group so we can do capacity planning reports on the things that are consumable. Namely, gas and oil. So we go to the CCM, go to make a service group called "Consumables" and then try to put in the check_gas and check_oil service checks, but woah, Nellie! They don't show up in the list. In fact, no service checks show up if they're assigned to hostgroups. They only show up if they are assigned to specific hosts.

Therefore, this breaks the "all you need to do is add a new host to the Cars group and everything is groovy" bit, since you can't just do that and have the service group pick up the new host.

I think it would be better, and more intuitive, if the servicegroup parsed the final host:service definitions, and allowed you to add each service on each host (or maybe the entire service check without specifying a host, specifically). That would be useful.

Re: Servicegroups ignore services assigned via hostgroups

Posted: Fri Sep 09, 2016 1:40 pm
by tmcdonald
I don't think this can even be done in Core:

Code: Select all

define service
{
    hostgroup_name          linux-servers
    service_description     Total Processes SG
    use                     local-service
    check_command           check_local_procs!400!500!RSZDT
    register                1
}

Code: Select all

define servicegroup
{
    servicegroup_name   test_sg
    alias               Test SH
    members             linux-servers,Total Processes SG
}
localhost does in fact belong to linux-servers, but when I verify:

Code: Select all

[root@localhost bin]# ./nagios -v ../etc/nagios.cfg

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Warning: Duplicate definition found for service 'Current Load' on host 'localhost' (config file '/usr/local/nagios/etc/services/localhost_copy_1.cfg', starting on line 16)
Error: Could not find a service matching host name 'linux-servers' and description 'Total Processes SG' (config file '/usr/local/nagios/etc/servicegroups.cfg', starting on line 16)
Error: Could not expand members specified in servicegroup 'test_sg' (config file '/usr/local/nagios/etc/servicegroups.cfg', starting at line 16)
   Error processing object config files!


***> One or more problems was encountered while processing the config files...

     Check your configuration file(s) to ensure that they contain valid
     directives and data defintions.  If you are upgrading from a previous
     version of Nagios, you should be aware that some variables/definitions
     may have been removed or modified in this version.  Make sure to read
     the HTML documentation regarding the config files, as well as the
     'Whats New' section to find out what has changed.
If I remove/comment out the servicegroup definition it verifies cleanly (sans the warnings which are unrelated).

The documentation does seem to back this up in the servicegroups section for the members entry, though it doesn't explicitly say that hostgroups are not included:
This is a list of the descriptions of services (and the names of their corresponding hosts) that should be included in this group.
And as for:
eloyd wrote:I never really got why servicegroups exist, since they don't seem to do much except for reporting.
Also grouping in XI dashlets :)

Also also, commands:

http://old.nagios.org/developerinfo/ext ... mand_id=98
http://old.nagios.org/developerinfo/ext ... mand_id=94
http://old.nagios.org/developerinfo/ext ... and_id=102
http://old.nagios.org/developerinfo/ext ... and_id=100
http://old.nagios.org/developerinfo/ext ... mand_id=96
http://old.nagios.org/developerinfo/ext ... mand_id=92
http://old.nagios.org/developerinfo/ext ... mand_id=97
http://old.nagios.org/developerinfo/ext ... mand_id=93
http://old.nagios.org/developerinfo/ext ... and_id=101
http://old.nagios.org/developerinfo/ext ... mand_id=99
(Plus 4 more I can't post due to URL limits in the forum)

Re: Servicegroups ignore services assigned via hostgroups

Posted: Fri Sep 09, 2016 1:49 pm
by eloyd
Then please consider this a feature request to implement such a structure.

Ideally, I'd like to see an object-oriented approach to things within Nagios, so there is no differentiation (configuration-wise) between a host and a service. It's just "thing to be monitored." Then a group of things is a just a group, a dependency is just a parent/child relationship, which could easily replace dependencies, and greatly simplify life in general. Until that day happens though, I will go on believing that service groups serve no useful purpose. :-(

Re: Servicegroups ignore services assigned via hostgroups

Posted: Fri Sep 09, 2016 2:02 pm
by tmcdonald
eloyd wrote:Then please consider this a feature request to implement such a structure.
If only there were some place to file this sort of thing officially :)

Want me to or are you gonna?

Re: Servicegroups ignore services assigned via hostgroups

Posted: Fri Sep 09, 2016 2:19 pm
by eloyd

Re: Servicegroups ignore services assigned via hostgroups

Posted: Mon Sep 12, 2016 9:09 am
by tmcdonald
Gonna close this up :)