Looking for a way to delete and reconfigure services
-
CFT6Server
- Posts: 506
- Joined: Wed Apr 15, 2015 4:21 pm
Looking for a way to delete and reconfigure services
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
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?
From there, select all the services for that server, and select 'Delete' next to the With Checked.
Does that answer your question?
Former Nagios Employee
-
CFT6Server
- Posts: 506
- Joined: Wed Apr 15, 2015 4:21 pm
Re: Looking for a way to delete and reconfigure services
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
Do they all have a common service description?
Former Nagios Employee
-
CFT6Server
- Posts: 506
- Joined: Wed Apr 15, 2015 4:21 pm
Re: Looking for a way to delete and reconfigure services
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
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.
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.
Former Nagios Employee
-
CFT6Server
- Posts: 506
- Joined: Wed Apr 15, 2015 4:21 pm
Re: Looking for a way to delete and reconfigure services
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.
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
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:
Open the config in a text editor:
and remove the "unwanted" services, i.e.
change this:
to this:
or this:
to this:
depending on how your services were configured on the first place.
Then all you need to do is run "reconfigure".
Hope this helps.
Code: Select all
cp /usr/local/nagios/etc/services/<your config>.cfg /usr/local/nagios/etc/import/Code: Select all
vi /usr/local/nagios/etc/import/<your config>.cfgchange this:
Code: Select all
define service {
host_name HostA,HostB,HostC,HostD
service_description Service1
...
}Code: Select all
define service {
host_name HostA
service_description Service1
...
}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
...
}Code: Select all
define service {
host_name HostA,HostB,HostC,HostD
service_description Service3
...
}Then all you need to do is run "reconfigure".
Code: Select all
cd /usr/local/nagiosxi/scripts
./reconfigure_nagios.shBe sure to check out our Knowledgebase for helpful articles and solutions!
-
CFT6Server
- Posts: 506
- Joined: Wed Apr 15, 2015 4:21 pm
Re: Looking for a way to delete and reconfigure services
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
I see. I thought you had one service added to multiple hosts because of what you said in your first post.With Nagios XI, the services file is set to individual hosts. So for example hostname.cfg will only contain services from hostname.
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.
Be sure to check out our Knowledgebase for helpful articles and solutions!