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:
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.