Page 1 of 2

Duplicate entries when running reconfigure

Posted: Fri Sep 14, 2018 2:52 pm
by ericcl9p
Hello-

We are running NagioxXI on rhel7.5 and use template files to add new VMs into Nagios by putting them in /usr/local/nagios/etc/import/ and running reconfigure. This is done by an automation process so we do not need to manually add the hosts/services.

In our environment VMs can also be suspended, so we have automation in place that will change active_checks_enabled and passive_checks_enabled to 0 for the host/services when the VM is suspended, and change back to 1 when it is restarted.

We've noticed that during the reconfigure (/usr/local/nagiosxi/scripts/reconfigure_nagios.sh) we are getting "Warning: Duplicate definition found for service" warnings, although we are not adding any additional services to the hosts.

We're not really sure what to check at this point... but think that maybe it is a hostgroup/servicegroup issue?

I'm attaching the template we use when adding a linux host/VM. If there is a better way for us to be doing this, please let me know.

Thanks
-Eric

Re: Duplicate entries when running reconfigure

Posted: Fri Sep 14, 2018 3:10 pm
by npolovenko
Hello, @ericcl9p. These warnings can happen if you assign two hostgroups to the same hosts and use the same services. Or there can be a few other causes as well. If you PM me your profile and the full warning error message, I will try to trace the error and tell you what's wrong.
To send us your system profile. Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button
Save the profile.zip file and upload it to a cloud storage of your choice. You can share a link with me in a personal message.
After you upload the profile please post something in this thread to bring it up in the support queue.

Re: Duplicate entries when running reconfigure

Posted: Fri Sep 14, 2018 10:42 pm
by ericcl9p
Hello,

The profile should be attached.

Below are the warnings we are receiving

Thanks
-Eric


Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1401VM04254' (config file '/usr/local/nagios/etc/services/USA1401VM04254.cfg', starting on line 175)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1401VM04254' (config file '/usr/local/nagios/etc/services/USA1401VM04254.cfg', starting on line 134)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1401VM04254' (config file '/usr/local/nagios/etc/services/USA1401VM04254.cfg', starting on line 93)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1401VM04254' (config file '/usr/local/nagios/etc/services/USA1401VM04254.cfg', starting on line 55)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1401VM04254' (config file '/usr/local/nagios/etc/services/USA1401VM04254.cfg', starting on line 35)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1401VM04254' (config file '/usr/local/nagios/etc/services/USA1401VM04254.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402VM04304' (config file '/usr/local/nagios/etc/services/USA1402VM04304.cfg', starting on line 181)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402VM04304' (config file '/usr/local/nagios/etc/services/USA1402VM04304.cfg', starting on line 161)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1402VM04304' (config file '/usr/local/nagios/etc/services/USA1402VM04304.cfg', starting on line 120)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1402VM04304' (config file '/usr/local/nagios/etc/services/USA1402VM04304.cfg', starting on line 77)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1402VM04304' (config file '/usr/local/nagios/etc/services/USA1402VM04304.cfg', starting on line 36)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1402VM04304' (config file '/usr/local/nagios/etc/services/USA1402VM04304.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1401VM04277' (config file '/usr/local/nagios/etc/services/USA1401VM04277.cfg', starting on line 170)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1401VM04277' (config file '/usr/local/nagios/etc/services/USA1401VM04277.cfg', starting on line 151)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1401VM04277' (config file '/usr/local/nagios/etc/services/USA1401VM04277.cfg', starting on line 111)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1401VM04277' (config file '/usr/local/nagios/etc/services/USA1401VM04277.cfg', starting on line 73)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1401VM04277' (config file '/usr/local/nagios/etc/services/USA1401VM04277.cfg', starting on line 54)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1401VM04277' (config file '/usr/local/nagios/etc/services/USA1401VM04277.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402VM04303' (config file '/usr/local/nagios/etc/services/USA1402VM04303.cfg', starting on line 134)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402VM04303' (config file '/usr/local/nagios/etc/services/USA1402VM04303.cfg', starting on line 115)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1402VM04303' (config file '/usr/local/nagios/etc/services/USA1402VM04303.cfg', starting on line 76)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1402VM04303' (config file '/usr/local/nagios/etc/services/USA1402VM04303.cfg', starting on line 36)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402LV04381' (config file '/usr/local/nagios/etc/services/USA1402LV04381.cfg', starting on line 112)
Warning: Duplicate definition found for service 'Disk Usage on /dev/sda2' on host 'USA1402LV04381' (config file '/usr/local/nagios/etc/services/USA1402LV04381.cfg', starting on line 55)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1402LV04381' (config file '/usr/local/nagios/etc/services/USA1402LV04381.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1401VM04276' (config file '/usr/local/nagios/etc/services/USA1401VM04276.cfg', starting on line 118)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1401VM04276' (config file '/usr/local/nagios/etc/services/USA1401VM04276.cfg', starting on line 57)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1401VM04276' (config file '/usr/local/nagios/etc/services/USA1401VM04276.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402VM04470' (config file '/usr/local/nagios/etc/services/USA1402VM04470.cfg', starting on line 124)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1402VM04470' (config file '/usr/local/nagios/etc/services/USA1402VM04470.cfg', starting on line 82)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1402VM04470' (config file '/usr/local/nagios/etc/services/USA1402VM04470.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1400VM04219' (config file '/usr/local/nagios/etc/services/USA1400VM04219.cfg', starting on line 172)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1400VM04219' (config file '/usr/local/nagios/etc/services/USA1400VM04219.cfg', starting on line 133)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1400VM04219' (config file '/usr/local/nagios/etc/services/USA1400VM04219.cfg', starting on line 114)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1400VM04219' (config file '/usr/local/nagios/etc/services/USA1400VM04219.cfg', starting on line 74)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1400VM04219' (config file '/usr/local/nagios/etc/services/USA1400VM04219.cfg', starting on line 36)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1400VM04219' (config file '/usr/local/nagios/etc/services/USA1400VM04219.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1400VM04278' (config file '/usr/local/nagios/etc/services/USA1400VM04278.cfg', starting on line 136)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1400VM04278' (config file '/usr/local/nagios/etc/services/USA1400VM04278.cfg', starting on line 96)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1400VM04278' (config file '/usr/local/nagios/etc/services/USA1400VM04278.cfg', starting on line 56)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1400VM04278' (config file '/usr/local/nagios/etc/services/USA1400VM04278.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1401VM04468' (config file '/usr/local/nagios/etc/services/USA1401VM04468.cfg', starting on line 132)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1401VM04468' (config file '/usr/local/nagios/etc/services/USA1401VM04468.cfg', starting on line 93)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1401VM04468' (config file '/usr/local/nagios/etc/services/USA1401VM04468.cfg', starting on line 74)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1401VM04468' (config file '/usr/local/nagios/etc/services/USA1401VM04468.cfg', starting on line 36)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402VM04305' (config file '/usr/local/nagios/etc/services/USA1402VM04305.cfg', starting on line 181)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1402VM04305' (config file '/usr/local/nagios/etc/services/USA1402VM04305.cfg', starting on line 138)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1402VM04305' (config file '/usr/local/nagios/etc/services/USA1402VM04305.cfg', starting on line 99)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1402VM04305' (config file '/usr/local/nagios/etc/services/USA1402VM04305.cfg', starting on line 79)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1402VM04305' (config file '/usr/local/nagios/etc/services/USA1402VM04305.cfg', starting on line 59)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1402VM04305' (config file '/usr/local/nagios/etc/services/USA1402VM04305.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1401LV04379' (config file '/usr/local/nagios/etc/services/USA1401LV04379.cfg', starting on line 175)
Warning: Duplicate definition found for service 'Disk Usage on /dev/sdb1' on host 'USA1401LV04379' (config file '/usr/local/nagios/etc/services/USA1401LV04379.cfg', starting on line 135)
Warning: Duplicate definition found for service 'Disk Usage on /dev/sdb1' on host 'USA1401LV04379' (config file '/usr/local/nagios/etc/services/USA1401LV04379.cfg', starting on line 116)
Warning: Duplicate definition found for service 'Disk Usage on /dev/sda2' on host 'USA1401LV04379' (config file '/usr/local/nagios/etc/services/USA1401LV04379.cfg', starting on line 75)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1401LV04379' (config file '/usr/local/nagios/etc/services/USA1401LV04379.cfg', starting on line 35)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1401LV04379' (config file '/usr/local/nagios/etc/services/USA1401LV04379.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402VM04306' (config file '/usr/local/nagios/etc/services/USA1402VM04306.cfg', starting on line 200)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402VM04306' (config file '/usr/local/nagios/etc/services/USA1402VM04306.cfg', starting on line 181)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1402VM04306' (config file '/usr/local/nagios/etc/services/USA1402VM04306.cfg', starting on line 139)
Warning: Duplicate definition found for service 'Disk Usage on D:/' on host 'USA1402VM04306' (config file '/usr/local/nagios/etc/services/USA1402VM04306.cfg', starting on line 120)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1402VM04306' (config file '/usr/local/nagios/etc/services/USA1402VM04306.cfg', starting on line 80)
Warning: Duplicate definition found for service 'Disk Usage on C:/' on host 'USA1402VM04306' (config file '/usr/local/nagios/etc/services/USA1402VM04306.cfg', starting on line 59)
Warning: Duplicate definition found for service 'CPU Usage' on host 'USA1402VM04306' (config file '/usr/local/nagios/etc/services/USA1402VM04306.cfg', starting on line 16)
Warning: Duplicate definition found for service 'Memory Usage' on host 'USA1402LV04375' (config file '/usr/local/nagios/etc/services/USA1402LV04375.cfg', starting on line 82)

Re: Duplicate entries when running reconfigure

Posted: Mon Sep 17, 2018 9:53 am
by npolovenko
@ ericcl9p, Looks like you might've rerun the NCPA wizard against the same hosts twice, and that created duplicate configs. These warning errors are not critical but if you want to get rid of them you can do the following.
In XI web interface go to Configure -> Core Configurations Manager, then click on Tools -> Config File Management in the left column. Then perform the following actions in order:
1)Delete
2)Write
3)Verify
After you click the verify you'll see warning errors. Open a console session to the nagios server or FileZilla/WinSCP FTP session, go to the files specified in the errors and delete duplicate entries. After you done removing all duplicates run these commands again:
1)Delete
2)Write
3)Verify
If you see more warnings - fix them and repeat the steps. If there are no more warnings click on the Apply Configuration button in the CCM.

Re: Duplicate entries when running reconfigure

Posted: Tue Sep 18, 2018 7:10 am
by ericcl9p
@npolovenko, thanks for the reply.

Delete/Write/Verify puts the same duplicate entries back in to the files. If we manually edit the files to remove the duplicates, won't running the 3 commands write the same files again with dupes?

We're seeing hosts that were just recently added, through the process I described earlier, with dupes. We are not using the NCPA wizard.

What else could be causing this?

Thanks

Re: Duplicate entries when running reconfigure

Posted: Tue Sep 18, 2018 11:54 am
by npolovenko
@ericcl9p, You're right about the Delete-Verify procedure. To get rid of the warnings you'd need to find duplicate services in CCM and delete them.
There is a problem with the templates you attached. They all have "register 1" directive instead of "register 0" as it is supposed to be set for templates. This means nagios will actually create a new config out of these definitions each time you Apply Configuration. Please change register 1 to 0 in all your templates.

Re: Duplicate entries when running reconfigure

Posted: Tue Sep 18, 2018 6:45 pm
by ericcl9p
@npolovenko

OK, we'll change register 1 to 0, and remove the dupes from the CCM.


Is there a better way to do what we the current templates do?

Each linux and windows host gets the same base service checks, only the disk usage checks are slightly different.


Thanks
-Eric

Re: Duplicate entries when running reconfigure

Posted: Tue Sep 18, 2018 8:35 pm
by ericcl9p
one other question...

we removed all dupes in CCM, and did d/w/v and all seemed ok

we changed register to 0 in the templates

should the cfg files in /usr/local/nagios/etc/hosts and services have register set to 0 or 1?

Thanks

Re: Duplicate entries when running reconfigure

Posted: Wed Sep 19, 2018 1:23 pm
by ericcl9p
After changing register to 0 in the config templates we populate to import, the hosts were not getting added to nagios.

So, I thought maybe we should just set register to 0 for the services and leave it set to 1 for hosts. After doing that, the hosts get added, but show no services.

What do we need to do to get host and services added, without dupes?


Thanks
-Eric

Re: Duplicate entries when running reconfigure

Posted: Wed Sep 19, 2018 3:34 pm
by npolovenko
@ericcl9p, The configs themselves should be set to 1. Only templates need to be set to 0.
We might've had some misunderstanding. In XI templates are configs that hosts or services can inherit from. That way when you create a new host or service you can simply do something like this:
////this is a new host
define host {
host_name myNewHost
address 128.0.0.1
use template1
register 1
}

////this is a template
define host {
name template1
hostgroups fm-linux-servers
check_command check-ncpa-alive
max_check_attempts 10
check_interval 5
retry_interval 2
active_checks_enabled 1
passive_checks_enabled 1
check_period xi_timeperiod_24x7
contacts uswu61403
notification_interval 60
notification_period xi_timeperiod_24x7
icon_image linux-server.png
statusmap_image linux-server.png
_xiwizard ncpa
register 0
}
As you can see myNewHost inherits all options from the template1.
use template1
The final "compiled" config will look like this:
define host {
host_name myNewHost
address 128.0.0.1
hostgroups fm-linux-servers
check_command check-ncpa-alive
max_check_attempts 10
check_interval 5
retry_interval 2
active_checks_enabled 1
passive_checks_enabled 1
check_period xi_timeperiod_24x7
contacts uswu61403
notification_interval 60
notification_period xi_timeperiod_24x7
icon_image linux-server.png
statusmap_image linux-server.png
_xiwizard ncpa
register 0
}
This saves time because you don't need to write out all the configs for each new host, but instead, you can write them in a template once, and reuse them.

In your case, you were not using those configs as templates. Rather you were showing me the structure of service and host configs that you're importing, right?