Nagios 3.0 template issues, bug or me?


#1

I am going try to summarize:
I think I am getting a false error. I am at a loss as to why I am getting a duplicate definition error.

I have broken up the template files into several files.
/etc/nagios/objects/templates/contacts.cfg/
/etc/nagios/objects/templates/devices/swtich.cfg
/etc/nagios/objects/templates/devices/host.cfg
/etc/nagios/objects/templates/devices/printer.cfg
/etc/nagios/objects/templates/service/service.cfg

nagios.cfg changes
#templates.cfg is commented out and moved to another location.
cfg_dir=/etc/nagios/objects/templates
cfg_dir=/etc/nagios/objects/templates/service
cfg_dir=/etc/nagios/objects/templates/device

As expected there is only one definition

find /etc/nagios -exec grep -l “name *generic-service” {} ;

/etc/nagios/objects/templates/service/service.cfg

Here is the ERROR:

/usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg

Nagios 3.0
Copyright © 1999-2008 Ethan Galstad (nagios.org)
Last Modified: 03-13-2008
License: GPL

Reading configuration data…

Warning: Duplicate definition found for service ‘generic-service’ (config file ‘/etc/nagios/objects/templates/service/service.cfg’, starting on line 11)
Error: Could not add object property in file ‘/etc/nagios/objects/templates/service/service.cfg’ on line 12.

Can anyone duplication this?
I can supply files if required.

Thanks


#2

Hi!

I’m not sure of where your error comes from, but, from my experience:
maybe you could try to get rid of the “cfg_dir” in your nagios.cfg, and replace them with “cfg_file” pointing to the exact file.
I’m saying that because it is quite easy to forget a temporary file or a backup file in a directory, and nagios will parse it because of the “cfg_dir” directive.

So, maybe try that :slight_smile:

(or else: could you post the content of the ‘/etc/nagios/objects/templates/service/service.cfg’ file; and also a listing of all the files in the “/etc/nagios/objects/templates” dir ?)


#3

Hi

You only need to specify the templates directory as cfg_dir as nagios processes all subdirectories within thatas well, and therefore it is indeed reading the contents of the services and device subdirectoreis twice.

[blockquote]This directive is used to specify a directory which contains object configuration files that Nagios should use for monitoring. All files in the directory with a .cfg extension are processed as object config files. Additionally, Nagios will recursively process all config files in subdirectories of the directory you specify here. You can seperate your configuration files into different directories and specify multiple cfg_dir= statements to have all config files in each directory processed. [/blockquote]

HTH

/S


#4

Strides is the winner here.

Removed the subdirectories from nagios.cfg and it now work.
Should have read the docs more carefully.

Thanks.