Nagios 3.0 template issues, bug or me?


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.

nagios.cfg changes
#templates.cfg is commented out and moved to another location.

As expected there is only one definition

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


Here is the ERROR:

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

Nagios 3.0
Copyright © 1999-2008 Ethan Galstad (
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.




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 ?)



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]




Strides is the winner here.

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