Problem creating identical service for multiple hosts


#1

Hi All,

I’m having trouble defining a service for hosts in a hostgroup using v1.2. It appears that if there’s more than one host in the hostgroup it complains of duplicate host descriptions. Has anyone seen this before and am I doing something silly?

srv-ftp01# …/bin/nagios -v nagios.cfg
–snip–

Reading configuration data…

Error: Service ‘rtr-cor01.sta-bgp’ on host ‘rtr-lrm05.sta’ has already been defined

Error: Could not register service (config file ‘/usr/local/nagios/etc/services.cfg’, line 44)
–snip–

define service{
hostgroup_name hk_lrm_routers
service_description rtr-cor01.sta-bgp
check_command check-bgp!210.5.192.241%rtr-cor01.sta
use genericservice
}

define hostgroup{
hostgroup_name hk_lrm_routers
alias Hong Kong Low Rate Modem Routers
members rtr-lrm01.sta, rtr-lrm02.sta, rtr-lrm03.sta, rtr-lrm04.sta, rtr-lrm05.sta
contact_groups all
}


#2

I’ve tried this with different services and still have the same problem. I assume other people have got this feature to work?


#3

i define the same service on multiple hosts telling nagios explicitly the names of the hosts i want to be checked in services.cfg.

Using hostgroups could be better… but i never tried it.

Luca


#4

Hi Luca - yes I tried doing that as a workaround and that works fine. Thanks, John.


#5

That is not a workaround, that is how you are suppose to configure hosts/services.

I have fping defined for each and every host on our network. So I have lets say 100 hosts in the same hostgroup, all with fping as there service check and that is how it’s supposed to work.

Now, I think I know what you are attempting to do. You want to define a service check for a hostgroup, and not for each and every host. If that is true, show me the directive from the instructions/doc’s that allows this. Save yourself the trouble. There IS NO directive in the hostsgroups.cfg file that allows this.


#6

I think this says what I’m trying to do is allowed:

nagios.sourceforge.net/docs/1_0/ … ml#service

All Hosts In Multiple Hostgroups: If you want to create identical services that are assigned to all hosts in one or more hostgroups, you can do so by creating a single service definition. How? The hostgroup_name directive allows you to specify the name of one or more hostgroups that the service should be created for:

define service{
	hostgroup_name		HOSTGROUP1,HOSTGROUP2,...,HOSTGROUPN
	service_description	SOMESERVICE
	other service directives ...
	}

Anyway, it doesn’t seem to work for me, whether I put in a single or multiple hostgroups.


#7

[quote=“jakkedup”]

Now, I think I know what you are attempting to do. You want to define a service check for a hostgroup, and not for each and every host.[/quote]

Yes that’s exactly what I’m trying to do. :slight_smile:

By the way, thanks for your assistance so far. I’ve been configuring it for two weeks and got it talking nicely to our broadcast video multiplexors and receivers and it’s looking far better that the rather expensive prorprietary stuff we’ve got in place already!


#8

Whew, I haven’t seen that page in ages and thank you for pointing it out.
I’m gonna try it out right now, since I’ve never ever used that trick.
I’ll let you know how it goes.


#9

in services.cfg I defined:
define service{
use generic-service
hostgroup_name Bus-Switches
service_description testing
check_command check_ping!200.0,20%!500.0,60%
contact_groups Bus-Switches

Hostgroup Bus_switches is composed of about 5 hosts.
Restarted nagios and each and every host in hostgroup Bus_switches has a new service called “testing” which is simply a check_ping check.
I have no idea then why yours is not working, except that you already have a service check with the same definition per the error you stated. Error: Service ‘rtr-cor01.sta-bgp’ on host ‘rtr-lrm05.sta’ has already been defined"

So fix your services.cfg.
"


#10

Are you using 1.2 also?


#11

Yes I am using v1.2
If you run nagios using the -v to check your configs, you will find that you have defined a service check more than once. You might have defined it once as a normal ping check for one host and then again, as I did above, as another check for that host, but using the hostgroup_name directive.
Edited Sat Oct 01 2005, 05:00AM ]


#12

Yes, it didn’t like the ping check for * hosts used in combination with hostgroup_name directive.

Doesn’t work:

define service{
host_name *
service_description check-fping
check_command check-fping
–snip–
}

define service{
hostgroup_name hk_lrm_routers
service_description BGP-to-rtr-cor01.sta
check_command check-bgp!210.5.192.241%rtr-cor01.sta
–snip–
}

Does like:

define service{
hostgroup_name hk_lrm_routers
service_description BGP-to-rtr-cor01.sta
check_command check-bgp!210.5.192.241%rtr-cor01.sta
–snip–
}