Strange Inheritance bug?

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
Cartaugrapher
Posts: 2
Joined: Tue Feb 13, 2018 1:50 pm

Strange Inheritance bug?

Post 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?
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Strange Inheritance bug?

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Cartaugrapher
Posts: 2
Joined: Tue Feb 13, 2018 1:50 pm

Re: Strange Inheritance bug?

Post 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)
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Strange Inheritance bug?

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked