Page 1 of 2
Duplicate Service Definitions
Posted: Sat Dec 01, 2018 8:43 am
by ddaluka
Hi,
We were using Nagios version 5.4.7 so far and we were importing service configurations in Nagios from backend. All of our service configurations are tied to hostgroups and host definitions are configured with hostgroups as well.
So far, when a service definition is already present in Nagios (Lets say service A) defined with hostgroup (appHostGroup) and if we are importing the same service definition again from backend, duplicate definition was not being added because it is the same definition.
Or if we change the check command or any other parameter for that service definition and import it again, existing service definition was being updated.
Now, we had a requirement to upgrade Nagios to 5.5.6 and for that instead of upgrading existing server directly, we have done following activity:
1. Installed 5.4.7 again using offline install on new VM
2. Restored nagiosxi backup to new server
3. Once all the checks are in working state, upgraded nagios to 5.5.6 using offline install
4. Switched the ip to original server ip.
Now , if we are importing the same service definitions from backend, it is keep on adding the duplicate configuration on each import which was not happening in previous set up.
Note: I have also done separate fresh installation of 5.5.6 on a test box (without any backup restore) and add the service definitions multiple times and I can see duplicate configuration being added for each import.
Could you please suggest? Is there anything changed in this area in 5.5.6 version
Re: Duplicate Service Definitions
Posted: Mon Dec 03, 2018 5:29 am
by ddaluka
One of the configuration file content:
Code: Select all
define service {
service_description HeapCheckAPP
use xiwizard_nrpe_service
hostgroup_name appProjectHostGroup
check_command check_heap_memory!8181!:90!:80!!!!!!
max_check_attempts 5
check_interval 5
retry_interval 1
check_period xi_timeperiod_24x7
notification_interval 1440
notification_period xi_timeperiod_24x7
register 1
}
define service {
service_description HeapCheckAPP
use xiwizard_nrpe_service
hostgroup_name appProjectHostGroup
check_command check_heap_memory!8181!:90!:80!!!!!!
max_check_attempts 5
check_interval 5
retry_interval 1
check_period xi_timeperiod_24x7
notification_interval 1440
notification_period xi_timeperiod_24x7
register 1
}
define service {
service_description HeapCheckAPP
use xiwizard_nrpe_service
hostgroup_name appProjectHostGroup
check_command check_heap_memory!8181!:90!:80!!!!!!
max_check_attempts 5
check_interval 5
retry_interval 1
check_period xi_timeperiod_24x7
notification_interval 1440
notification_period xi_timeperiod_24x7
register 1
}
I have tried various scenarios such as 1. Did the multiple import on fresh installed 5.4.7 release and it is working fine and not adding duplicate configuration. Then I upgraded it to 5.5.6 release and did the same import activity multiple times, it started adding duplicate configurations.
2. I also did a fresh install for 5.5.6 release and did the multiple imports for same configuration file, it started adding duplicate configurations.
3. I have also noticed that this duplication is happening for the definitions which are using hostgroups in its definition instead of direct host. Definitions with direct host entry are not being duplicated.
Re: Duplicate Service Definitions
Posted: Mon Dec 03, 2018 12:28 pm
by lmiltchev
I was able to recreate the issue, and filed an internal bug report (task_id=13871). Thank you for reporting the bug!
Re: Duplicate Service Definitions
Posted: Mon Dec 03, 2018 12:37 pm
by ddaluka
lmiltchev wrote:I was able to recreate the issue, and filed an internal bug report (task_id=13871). Thank you for reporting the bug!
Hi lmiltchev,
Thanks for your confirmation. Is there any workaround which I can do to fix this for now because I have already upgraded Nagios to 5.5.6 and all our configurations are being applied using Ansible?
Configuration will keep on adding on each import. If you can provide me a way around until it gets fixed properly, it will be very helpful.
Re: Duplicate Service Definitions
Posted: Mon Dec 03, 2018 1:37 pm
by lmiltchev
Thanks for your confirmation. Is there any workaround which I can do to fix this for now because I have already upgraded Nagios to 5.5.6 and all our configurations are being applied using Ansible?
How are you upgrading services exactly? Are you dropping the "new" configs in the import directory, then running the reconfigure_nagios.sh script or you are using the Nagios XI REST API? Can you show us an example of the steps you take in order to re-import the service?
Re: Duplicate Service Definitions
Posted: Mon Dec 03, 2018 3:44 pm
by ddaluka
Hi lmiltchev,
I am putting the .cfg files in import directory and then using reconfigure script to apply them in Nagios. I am using hostgroups in service definitions and host definitions are being created with a list of hostgroup depending on the applications/components deployed on that host.
Re: Duplicate Service Definitions
Posted: Tue Dec 04, 2018 4:39 am
by ddaluka
Hi,
Please let me know if I need to open any support ticket for way around of this issue until proper fix is provided.
Re: Duplicate Service Definitions
Posted: Tue Dec 04, 2018 11:12 am
by lmiltchev
Unfortunately, we do not have a workaround at this time. Our developers are looking into this issue and will offer a patch as soon as they have one.
Re: Duplicate Service Definitions
Posted: Tue Dec 04, 2018 12:24 pm
by swolf
Hi
@ddaluka,
We've found the errors and have a fix ready to go - see the instructions below
To apply the patch, you'll want to download this file:
import.class.txt
copy it onto your Nagios XI machine, and copy over the file at /usr/local/nagiosxi/html/includes/components/ccm/classes/import.class.php
If you transfer the file to your home folder, this will be like:
Code: Select all
cp /usr/local/nagiosxi/html/includes/components/ccm/classes/import.class.php /usr/local/nagiosxi/html/includes/components/ccm/classes/import.class.php.bak
cp ~/import.class.txt /usr/local/nagiosxi/html/includes/components/ccm/classes/import.class.php -f
chmod 755 /usr/local/nagiosxi/html/includes/components/ccm/classes/import.class.php
If you've changed your Nagios XI base directory, you'll need to change that in each of your commands as well.
Please let us know if this worked for you or if you have any other issues.
Re: Duplicate Service Definitions
Posted: Wed Dec 05, 2018 6:34 am
by ddaluka
Hi Swolf,
I have got following error in importing the configuration.
Code: Select all
PHP Fatal error: Call to undefined method mysqldb::escape() in /usr/local/nagiosxi/html/includes/components/ccm/classes/import.class.php on line 429
Importing into the CCM failed!