Page 1 of 1

Strange Inheritance bug?

Posted: Tue Feb 13, 2018 2:11 pm
by Cartaugrapher
Hello, all.
I've been setting up nagios for a little while here, and after finishing a fairly long list of hosts, hostgroups, services, and such; I've come to some strange bugs in some inheritances.

I'm using hostgroups for more easy control (we have a number of different servers running a plethora of services), so the inheritance looks like this:

Service -> hostgroup(s) -> hosttemplate(s) -> hosts

So interestingly, I've been getting a few errors that don't make sense. a number of them have been solved by fiddling with names and such, but most of the errors and such are nonsensical, given the situation:

Error:

Code: Select all

Error: Unable to locate host 'linux-mail' for service 'IMAP on port 143'
Error: Could not register service (config file '/opt/nagios/etc/objects/services.cfg', starting on line 61)
Service Block:

Code: Select all

define service{
        name                    IMAP
        use                     generic-service
        hostgroup_name          mail-servers
        service_description     IMAP on port 143
        check_command           check_imap
}
Hostgroup Block:

Code: Select all

define hostgroup{
        hostgroup_name  mail-servers
        alias           Incoming Mail Servers
        members         linux-mail
}
Host Template Block:

Code: Select all

define host{
        host_name                       linux-mail
        name                            linux-mail
        use                             linux-server
        register                        0
}
And a sanitized Host Block:

Code: Select all

define host{
        host_name       $Hostname_here
        address         $Address_here
        use             linux-mail
        register        1
}
Has anyone seen anything similar to this? Any thoughts on fixes?

Re: Strange Inheritance bug?

Posted: Tue Feb 13, 2018 3:24 pm
by lmiltchev
First thing I noticed is that you have an extra (wrong) directive in your template definition ("host_name"). For more info: https://assets.nagios.com/downloads/nag ... tance.html
define host{
host_name linux-mail
name linux-mail
use linux-server
register 0
}
Change it to:

Code: Select all

define host{        
        name                            linux-mail
        use                             linux-server
        register                        0
}
Do you see any config errors now, when you verify the configuration?

Re: Strange Inheritance bug?

Posted: Tue Feb 13, 2018 3:41 pm
by Cartaugrapher
lmiltchev wrote:First thing I noticed is that you have an extra (wrong) directive in your template definition ("host_name"). For more info: https://assets.nagios.com/downloads/nag ... tance.html
define host{
host_name linux-mail
name linux-mail
use linux-server
register 0
}
Change it to:

Code: Select all

define host{        
        name                            linux-mail
        use                             linux-server
        register                        0
}
Do you see any config errors now, when you verify the configuration?

The hostgroup inheritance doesn't seem to work correctly with just name (and not host_name), giving me the following:

Code: Select all

Error: Could not find any host matching 'linux-mail' (config file '/opt/nagios/etc/objects/hostgroups.cfg', starting on line 43)
Error: Could not expand members specified in hostgroup (config file '/opt/nagios/etc/objects/hostgroups.cfg', starting on line 43)

Re: Strange Inheritance bug?

Posted: Wed Feb 14, 2018 10:10 am
by lmiltchev
Zip up the "/opt/nagios/etc/" directory, and PM me (or any other member of the Nagios Support team) the zip file. We will review the configs, and suggest a solution.