Page 2 of 3
Re: Script to disable monitoring
Posted: Thu Oct 06, 2016 9:54 am
by avandemore
RIDS_I2MP,
I understand you would like to disable a large amount of hosts and/or services. Walking through the entire procress of creating such script is beyond the scope of support but I may be able to give you a work around.
Use Firefox and install the multiple-checkbox-checker and restart FF. Navigate to your XI install > CCM > Hosts or Services. Right click somewhere in the tables listing of objects and choose This Frame > Show only this frame. You should end up with a URL similar to the following: [url]http://<Your%20IP>/nagiosxi/includes/components/ccm/?cmd=view&type=service[/url].
You should now be able to follow the instructions from the
addon to mass select and alter objects.
If you do not like this approach I would advise you to carefully read the headers in the file locations you previously mentioned as it contains critical information for scripting needs.
Re: Script to disable monitoring
Posted: Thu Oct 06, 2016 3:00 pm
by gormank
This is just a thought, so if its nonsense, disregard...
You may be able to put all the to be deactivated hosts in a hostgroup, then deactivate the group.
XI allows us to be able to not do things like use templates and hostgroups that core would force us to. We would be wise to use templates and hostgroups for every host and service. This would cut posts for support by 25% at least.
BTW, I'm not support, just a pain in the butt user who asks dumb questions. :)
Re: Script to disable monitoring
Posted: Thu Oct 06, 2016 3:51 pm
by lmiltchev
@gormank I don't think this is going to work. If you added the hostgroup to the host, and tried to deactivate the hostgroup, you would get an error when applying configuration. If you added your hosts to the hostgroup, then yes, you could deactivate the hostgroup, but the hosts will be still monitored.
@RIDS_I2MP let us know if avandemore's solution is something that you could use.
Re: Script to disable monitoring
Posted: Thu Oct 06, 2016 3:59 pm
by gormank
Using hostgroups will remove the problem in the pic above.
Deactivating a hostgroup in a script seems a less daunting task than disabling/deleting a hundred hosts. I'd suggest a creative way to do it but the Nagios support people would say don't do that... :)
Re: Script to disable monitoring
Posted: Fri Oct 07, 2016 10:01 am
by lmiltchev
I'd suggest a creative way to do it but the Nagios support people would say don't do that...

We are open to suggestions - many of our new features have been developed because of requests/ideas/feedback of our customers/Nagios users.
Re: Script to disable monitoring
Posted: Wed Dec 07, 2016 3:15 am
by RIDS_I2MP
Hi Team,
Kindly suggest me a solution for my request, as I have tried the add-ons in firefox but it doesn't seems to be working.
So creating a script would work?
Re: Script to disable monitoring
Posted: Wed Dec 07, 2016 10:46 am
by rkennedy
RIDS_I2MP wrote:Hi Team,
Kindly suggest me a solution for my request, as I have tried the add-ons in firefox but it doesn't seems to be working.
So creating a script would work?
What issue did you experience with the Firefox addon?
Yes, a script should work if you wanted to take a step back to using the Core commands pentioned on page #1.
As for what @lmiltchev mentioned, I went ahead and filed a feature request on our end. #10346 is the ID, which is for the ability to use the API to disable hosts / services.
Re: Script to disable monitoring
Posted: Wed Dec 07, 2016 1:25 pm
by gormank
Edit. My sed example had an error. I added \n to the search to match before and after.
My original post suggested adding hosts to groups, not attaching hostgroups to hosts. I'm sure you can deactivate a hostgroup containing hosts. Its best to only add hosts to hostgroups (best option to me), or hostgroups to hosts. Otherwise, things get weird.
While not deleting, the following may be a primitive (modify via import) workaround...
Copy all config files for all to be removed/deactivated hosts and services to the import dir.
Search and replace the 1 in the register line w/ 0. Replacing text in a list of files should be pretty eassy automate w/ sed (sed -e "s/\t1\n/\t0/" host.cfg for example). See below for the regexp correction.
Run the reconfig script: cd /usr/local/nagiosxi/scripts & ./reconfigure_nagios.sh
Setting register to 0 on a host/service is the same as deactivating it in CCM (that's how CCM does it). It exists in CCM, but not in core so the host/service is functionally deleted.
Of course if hosts are directly attached to services or the monitoring design is otherwise crazy, this may fail. It depends on the reconfig process.
Re: Script to disable monitoring
Posted: Wed Dec 07, 2016 5:59 pm
by rkennedy
Thanks for the addition @gormank!
That's one way to do it that would work pretty well actually.
Officially, we'll need to wait for the FR, but I'll leave this thread open for further discussion.
Re: Script to disable monitoring
Posted: Wed Dec 07, 2016 6:58 pm
by gormank
I actually found my supposedly trivial sed solution still doesn't work so now I have to eat my shoe for lying. Not sure why it doesn't work since the 1 is preceded by a tab and followed by a newline. I'll keep working on a fix since I said it could be done. Its just a question of getting the regexp right...