Service to Hostgroups to Hosts - service { hostgroup_name }

I’m running to problems with “All Hosts In Multiple Hostgroup” from nagios.sourceforge.net/docs/3_0/ … ricks.html.

If I define an empty hostgroup HG_ABC, then create 2 services SVC1 and SVC2 with “hostgroup_name HG_ABC” (no direct host entry) and create hosts HOST1 and HOST2 with “hostgroups HG_ABC” I see the following…

Warning: Duplicate definition found for service ‘HOST1’ on host ‘SVC1’ (config file ‘/usr/local/nagios/etc/servers/HOST1.cfg’, starting on line 30)
Warning: Duplicate definition found for service ‘HOST2’ on host ‘SVC1’ (config file ‘/usr/local/nagios/etc/servers/HOST2.cfg’, starting on line 30)
Warning: Duplicate definition found for service ‘HOST1’ on host ‘SVC2’ (config file ‘/usr/local/nagios/etc/servers/HOST1.cfg’, starting on line 30)
Warning: Duplicate definition found for service ‘HOST2’ on host ‘SVC2’ (config file ‘/usr/local/nagios/etc/servers/HOST2.cfg’, starting on line 30)

Strange, huh. Now check out the final tally:

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

Any ideas?

Welcome to the forums Semireg… for starters, take a look at your service definitions. You might have defined a duplicate service definition for one or more hosts. Post your config for your definitions where the error is coming up so I can see what you have.

Geofoxer: I can paste my configs but do you see how the “Warning” above has it’s host/svc names flipped? This really looks like a Nagios bug where the mapping logic for sanity checks is accidently reversed. Can someone verify this on their install?

I dont entirely understand why nagios is giving this error… if it is a Bug in Nagios, not sure what it could be. What version are you using? And can you please post what is on line 30 from your config, it would be be helpful to see what you have there.

linux.cfg

define hostgroup {
hostgroup_name Linux
alias Linux Servers
}

define service {
use ssh
hostgroup_name Linux
}

define service {
use load
hostgroup_name Linux
}

======

testhost1.cfg

define host {
use default
host_name testhost1
alias My Host 1
hostgroups Linux
}

======

testhost2.cfg

define host {
use default
host_name testhost2
alias My Host 2
hostgroups Linux
}

Warning: Duplicate definition found for service ‘testhost1’ on host ‘ssh’ (config file ‘/usr/local/nagios/etc/servers/testhost1.cfg’, starting on line 6)
Warning: Duplicate definition found for service ‘testhost2’ on host ‘ssh’ (config file ‘/usr/local/nagios/etc/servers/testhost2.cfg’, starting on line 6)
Warning: Duplicate definition found for service ‘testhost1’ on host ‘load’ (config file ‘/usr/local/nagios/etc/servers/testhost1.cfg’, starting on line 6)
Warning: Duplicate definition found for service ‘testhost2’ on host ‘load’ (config file ‘/usr/local/nagios/etc/servers/testhost2.cfg’, starting on line 6)

Please understand that everything works even with these warnings.

My guess is that you have to define the host in the service definition that you have defined in the host definition. Here is what your service definition should look like:

define hostgroup {
hostgroup_name Linux
alias Linux Servers
members testhost1, testhost2
}

define service {
use ssh
hostgroup_name Linux**
host_name testhost1, testhost2**
}

define service {
use load
hostgroup_name Linux
host_name testhost1, testhost2
}

I hope that will fix the problem. If not post the error if not the same as before. And which part of the your config is on line 6. Could you point that out for me so I can narrow down the part of your config where the error is coming from?

And also here is a couple of helpful sites to help you with building your own config:

nagios.sourceforge.net/docs/2_0/xodtemplate.html
totkat.org/pages/nconf_commands.shtml
nagios.sourceforge.net/docs/3_0/toc.html

Hope that helps!!!

well yes, i’d say it is a bug…
BUT, I wouldn’t even consider reporting it:
you’re stretching a little bit the definition tricks :slight_smile:

so, if you’re not trying to find bugs i’d suggest that you should stick to the usual way to define hosts, hostgroups and services; it will work (better), and from what I can see, it isn’t much more work to do it the conventionnal way ^^

“What you can see” is a very small example. Right now I’m using this to define 10 “default” services to 300 hundred hosts. That’s 3,000 lines of configuration I’m saving.

This “typo” was reported 3 days ago on the nagios-dev list: article.gmane.org/gmane.network. … definition

I’m going to see why my hostgroup configuration is causing it, though. I suspect it’s just a bit more than a typo. :slight_smile: