Page 1 of 1

Using the import function to remove config items

Posted: Thu Jul 02, 2015 1:10 am
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

Re: Using the import function to remove config items

Posted: Thu Jul 02, 2015 8:52 am
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.

Re: Using the import function to remove config items

Posted: Thu Jul 02, 2015 6:19 pm
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.

Re: Using the import function to remove config items

Posted: Mon Jul 06, 2015 7:51 am
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

Re: Using the import function to remove config items

Posted: Tue Jul 07, 2015 9:41 pm
by crystal.then
Thanks lmiltchev - this works a treat!

Re: Using the import function to remove config items

Posted: Wed Jul 08, 2015 9:02 am
by lmiltchev
I am glad I could help! :)