Sharing this bit of information to help someone who is worried with this same error. While configuring or modifying Icinga, you may experience an issue like
Warning: Duplicate definition found for host ‘env_servers’ (config file ‘/etc/icinga/conf.d/hostgroups.cfg’, starting on line 19)
Error: Could not add object property in file ‘/etc/icinga/conf.d/hostgroups.cfg’ on line 20.
Error processing object config files!
It took some time to find out the real cause of this issue. If you analyze the issue, you can see a warning on top, but might not have noticed it seriously(I didnt 😛 ). Error is the result of warning, so resolve the warning first. Though it says it found a duplicate definition found, you may not be able to find such a duplicate. Which means the issue is not with the hostgroups.cfg file, but with the icinga.cfg file. In the main cfg file of Icinga(icinga.cfg), I had some entries as shown below:
This is the root cause of the warning. What these lines mean is that while having the config check, icinga finds two hostgroups.cfg (and thus duplicate definitions too), one from cfg_dir and another from cfg_file. So, it shows the warning duplicate entries found. What you need to do is that just remove cfg_file setting from the cfg file and your issue is now resolved.
The same solution is applicable with Nagios monitoring server also.