Using the import function to remove config items

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
crystal.then
Posts: 57
Joined: Mon Oct 27, 2014 12:05 am

Using the import function to remove config items

Post by crystal.then »

Hello,

I have a need to remove all "service group" configs from several services - about 800 of them. I don't want these services to be a part of any service group. Rather than using the GUI to do this, I'd like modify a list of cfg files, and then use the import function. The steps that I'm taking:

1. Copy /usr/local/nagios/etc/services/host.cfg to my local computer
2. Remove all "servicegroup" lines
3. Upload new config to /usr/local/nagios/etc/import/host.cfg
4. In Nagios CCM, import /usr/local/nagios/etc/import/host.cfg
5. Write configs to file/Verify/Apply

The problem I'm having is that the import seems to be additive - after the import the previously configured service group remains in the database. I can use the import to change the configuration (i.e.: change servicegroup from A to B), but not remove it. The "overwrite database" box is checked. Is this by design?

Thanks
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Using the import function to remove config items

Post by lmiltchev »

What is the version of Nagios XI that you are currently using?
The problem I'm having is that the import seems to be additive - after the import the previously configured service group remains in the database.
I was not able to recreate your issue on 2014R2.7. After replacing servicesgroup A with servicegroup B in the service config, moving it to the "import" directory and running "reconfigure_nagios.sh", I can see only servicegroup B in the service definition.
Be sure to check out our Knowledgebase for helpful articles and solutions!
crystal.then
Posts: 57
Joined: Mon Oct 27, 2014 12:05 am

Re: Using the import function to remove config items

Post by crystal.then »

We're running Nagios XI 2014R2.7.

I'm also able to replace service group A with service group B. The issue is that I need to remove the service groups completely - so import a zero or null value for service groups.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Using the import function to remove config items

Post by lmiltchev »

You are correct - you cannot remove the service group completely - not using this method anyway. There is a "workaround" that you can use in order to remove all servicegroups from a service in the CLI. You can do the following:

1. Copy your service config to "/tmp/"

Code: Select all

cp /usr/local/nagios/etc/services/<service config>.cfg /tmp/
2. Delete the service completely.

Code: Select all

cd /usr/local/nagiosxi/scripts
./nagiosql_delete_service.php --config=<service config>
./reconfigure_nagios.sh
For more info about managing host/services from the command line, see this document:
https://assets.nagios.com/downloads/nag ... gement.pdf

3. Modify the config that you saved in "/tmp/" directory by deleting the "servicegroups" directive from your service. Delete the whole line:

Code: Select all

servicegroups	servicegroup_names
4. Move the config to the "import" directory and run "reconfigure":

Code: Select all

mv /tmp/<service config>.cfg /usr/local/nagios/etc/import
cd /usr/local/nagiosxi/scripts
./reconfigure_nagios.sh
Be sure to check out our Knowledgebase for helpful articles and solutions!
crystal.then
Posts: 57
Joined: Mon Oct 27, 2014 12:05 am

Re: Using the import function to remove config items

Post by crystal.then »

Thanks lmiltchev - this works a treat!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Using the import function to remove config items

Post by lmiltchev »

I am glad I could help! :)
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked