Page 1 of 2
Looking for a way to delete and reconfigure services
Posted: Thu Dec 03, 2015 1:21 am
by CFT6Server
I am looking for a easy method to mass remove a particular server from a group of servers of about 300 hosts. They all have a common service check name. Is there any way to accomplish this while not remove the other services?
Re: Looking for a way to delete and reconfigure services
Posted: Thu Dec 03, 2015 11:12 am
by rkennedy
Can you navigate toe Configure -> Core Config Manager -> click 'Services' -> search by the 'Config Name' that is relevant to the server.
From there, select all the services for that server, and select 'Delete' next to the With Checked.
Does that answer your question?
Re: Looking for a way to delete and reconfigure services
Posted: Thu Dec 03, 2015 12:24 pm
by CFT6Server
Sorry that doesn't help as we have hundreds of servers to go through. I am looking for an automated way to remove a single common service from a big list of servers.
Re: Looking for a way to delete and reconfigure services
Posted: Thu Dec 03, 2015 12:28 pm
by rkennedy
Do they all have a common service description?
Re: Looking for a way to delete and reconfigure services
Posted: Thu Dec 03, 2015 1:24 pm
by CFT6Server
That could work. In the search, can it do Exact match? quotes doesn't seem to work.
Re: Looking for a way to delete and reconfigure services
Posted: Thu Dec 03, 2015 2:30 pm
by rkennedy
It should work without quotes - do you have a quote in the service description?
I just tested on my machine here and see that it appends the \'s, but doesn't return a result when using a " in the search.
Re: Looking for a way to delete and reconfigure services
Posted: Mon Dec 07, 2015 4:57 pm
by CFT6Server
I couldn't get exact match as it just returns everything containing the search string.
Is there any methods of modifying without the use of the GUI? I ended up have to click through after doing the initial filtering, but very time consuming.
Re: Looking for a way to delete and reconfigure services
Posted: Tue Dec 08, 2015 10:25 am
by lmiltchev
I was hoping this could be done via the REST API but it seems like it is not possible yet. You could remove a service from a host, but if your service is added to many hosts, this wouldn't work. There is another way (workaround), where you could remove services from the CLI. Copy your config to the "imports" directory:
Code: Select all
cp /usr/local/nagios/etc/services/<your config>.cfg /usr/local/nagios/etc/import/
Open the config in a text editor:
Code: Select all
vi /usr/local/nagios/etc/import/<your config>.cfg
and remove the "unwanted" services, i.e.
change this:
Code: Select all
define service {
host_name HostA,HostB,HostC,HostD
service_description Service1
...
}
to this:
Code: Select all
define service {
host_name HostA
service_description Service1
...
}
or this:
Code: Select all
define service {
host_name HostA,HostB,HostC,HostD
service_description Service1
...
}
define service {
host_name HostA,HostB,HostC,HostD
service_description Service2
...
}
define service {
host_name HostA,HostB,HostC,HostD
service_description Service3
...
}
to this:
Code: Select all
define service {
host_name HostA,HostB,HostC,HostD
service_description Service3
...
}
depending on how your services were configured on the first place.
Then all you need to do is run "reconfigure".
Code: Select all
cd /usr/local/nagiosxi/scripts
./reconfigure_nagios.sh
Hope this helps.
Re: Looking for a way to delete and reconfigure services
Posted: Tue Dec 08, 2015 3:53 pm
by CFT6Server
With Nagios XI, the services file is set to individual hosts. So for example hostname.cfg will only contain services from hostname. So this method wouldn't work as I would have to go through each file manually. I was hoping there could be some ways to do this bulk but doesn't seem like there's any options?
Re: Looking for a way to delete and reconfigure services
Posted: Wed Dec 09, 2015 10:45 am
by lmiltchev
With Nagios XI, the services file is set to individual hosts. So for example hostname.cfg will only contain services from hostname.
I see. I thought you had one service added to multiple hosts because of what you said in your first post.
It is possible to remove these services via mysql query but this is not recommended (nor supported). Removing 300+ services in the CCM could be a tedious task but it is not awfully difficult. All you need to do is go to CCM->Services, select "None" from the "Limit Results To" drop-down menu, type the service name in the "Search" bar, and hit "Enter" (Don't select any configs from the "Filter by Config Name" drop-down menu). Select "Toggle All Checkboxes". De-select the ones that you don't want to be deleted, then click on "Go" ("With Checked" = "Delete"). Apply Configuration.