Script to disable monitoring

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Script to disable monitoring

Post 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.
Previous Nagios employee
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Script to disable monitoring

Post 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. :)
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Script to disable monitoring

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Script to disable monitoring

Post 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... :)
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Script to disable monitoring

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Re: Script to disable monitoring

Post 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?
Thanks & Regards,
I2MP Team.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Script to disable monitoring

Post 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.
Former Nagios Employee
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Script to disable monitoring

Post 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.
Last edited by gormank on Wed Dec 07, 2016 9:31 pm, edited 1 time in total.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Script to disable monitoring

Post 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.
Former Nagios Employee
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Script to disable monitoring

Post 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...
Locked