Recently when I am trying to setup nagios on one of the machine I got the following error message:
Warning: Duplicate definition found for host 'host.example.com' (config file '/etc/nagios/hosts/host.cfg', starting on line 25)
Error: Could not add object property in file '/etc/nagios/servers/host.cfg' on line 30.
Error processing object config files!
After debugging this issue after some time I got to know that this is not because of my host.cfg file, it’s because of /etc/nagios/nagios.cfg file.
The issue with nagios.cfg file is I added following lines in it:
cfg_dir=/etc/nagios/servers cfg_file=/etc/nagios/servers/host.cfg
Because of above lines when nagios checking nagios.cfg file its getting host.cfg file two times, one is because of cfg_dir and other is because of cfg_file.
So I removed cfg_file=/etc/nagios/servers/host.cfg from nagios.cfg, validated nagios.cfg file again, then its worked without any issue.
-Sany
Hi Sany,
I am facing a similar issue. Nagios server is not starting up. the difference is that it is related to localhost.cfg file. When i try to verify the configuration and execute below command, it gives me a warning.
[root@nagiosserver objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 3.4.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 05-11-2012
License: GPL
Website: http://www.nagios.org
Reading configuration data…
Read main config file okay…
Processing object config file ‘/usr/local/nagios/etc/objects/commands.cfg’…
Processing object config file ‘/usr/local/nagios/etc/objects/contacts.cfg’…
Processing object config file ‘/usr/local/nagios/etc/objects/timeperiods.cfg’…
Processing object config file ‘/usr/local/nagios/etc/objects/templates.cfg’…
Processing object config file ‘/usr/local/nagios/etc/objects/localhost.cfg’…
Warning: Duplicate definition found for host ‘nagiosserver.sdsu.edu’ (config file ‘/usr/local/nagios/etc/objects/localhost.cfg’, starting on line 158)
Error: Could not add object property in file ‘/usr/local/nagios/etc/objects/localhost.cfg’ on line 160.
Error processing object config files!
***> One or more problems was encountered while processing the config files…
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
‘Whats New’ section to find out what has changed.
When i try to comment the line of “cfg_file=/usr/local/nagios/etc/objects/localhost.cfg” from nagoios.cfg, it give me 2 errors but no description.
Any guidance will be helpful.
Thanks,
Vikrant Korde.
Vikrant,
Can you share your localhost.cfg file or content around line number 160.
vikrant,
When you comment your “cfg_file=/usr/local/nagios/etc/objects/localhost.cfg”. it seems it will not able found any host and service. just verify the error what it says.