Script to disable monitoring

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Script to disable monitoring

Post by RIDS_I2MP »

Hi Team,

We want to disable monitoring on large number of servers, performing this task one by one for each server will take huge amount of time. So kindly can you let us know if there is any script which can disable monitoring just by passing some arguments.

If such script do not exist then we would like to built a script which fulfills our purpose.

Kindly let us know, what all changes need to be made in configuration files during disabling monitoring on any server and services monitored on it.
Thanks & Regards,
I2MP Team.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Script to disable monitoring

Post by tmcdonald »

If you have a list of hosts, services, hostgroups, or servicegroups, this can be automated quite easily:

http://old.nagios.org/developerinfo/ext ... ndlist.php

You will want to look into things like:

Code: Select all

 DISABLE_HOSTGROUP_HOST_CHECKS
DISABLE_HOST_CHECK
DISABLE_HOSTGROUP_SVC_CHECKS
etc. as fits your needs.
Former Nagios employee
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Re: Script to disable monitoring

Post by RIDS_I2MP »

Hi Team,

Below mentioned are inbuilt commands or we need to create them?
DISABLE_HOSTGROUP_HOST_CHECKS
DISABLE_HOST_CHECK
DISABLE_HOSTGROUP_SVC_CHECKS

I am receiving "command not found" as the result

[nagios@eu2napu004 hosts]$ DISABLE_HOST_CHECK;<hostname>
-bash: DISABLE_HOST_CHECK: command not found
-bash: <hostname>: command not found


kindly let me know if mmy understanding is wrong.
Thanks & Regards,
I2MP Team.
RIDS_I2MP
Posts: 751
Joined: Thu Mar 13, 2014 9:25 am

Re: Script to disable monitoring

Post by RIDS_I2MP »

Hi Team,

After few more analysis on your suggestion I would like to update few things.

I have tried the code for " DISABLE_HOST_CHECK" and it is just disabling the active checks for that host. But my concern is to disable monitoring complete monitoring.

step wise
1. Disable monitoring on services monitored on particular host.
2. Now disable monitoring on host

I went through the list of code present on below link, but could not find anything which can disable monitoring, kindly suggest:

http://old.nagios.org/developerinfo/ext ... egory_id=1
Thanks & Regards,
I2MP Team.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Script to disable monitoring

Post by lmiltchev »

In addition to disabling active checks, you could disable passive checks for specific hosts or "program-wide".

http://old.nagios.org/developerinfo/ext ... mand_id=72

http://old.nagios.org/developerinfo/ext ... mand_id=70
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 »

As per my understanding, this commands will just disable the monitoring temporarily, but we want to completely remove the entry of any particular host from the configuration files and database. Kindly let me if my understanding is wrong.

Also let me know how can I achieve it?

I guess we need to delete the host and service entries from configuration files, I am right?

Kindly also let me know in which file host and service dependencies is mentioned?
Thanks & Regards,
I2MP Team.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Script to disable monitoring

Post by lmiltchev »

You don't need to delete the hosts/services that you would like to remove. You can simply deactivate them - services first, then hosts. Under the CCM->Hosts or CCM/Services, click on the "Yes" ("Deactivate" button) under the "Active" column. To make sure the object doesn't have any dependencies, click on the "Relationship Info" button. It will tell you is there is a "Dependent relationship" and if the object can be deleted/deactivated.
If you deactivated your objects, they would not be visible in the GUI. In the future, you can always activate them (if needed).
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,

I am aware of the process of disabling monitoring through GUI, but I need to achieve this process using a script as I want to disable monitoring on large no of servers. So kindly help me to create a shell script to disable monitoring on any particular host.

Please let me know in which configuration file "host dependent on service" information is present. As I am not able to delete the host until and unless I disable the services which are monitored on that host.

Refer the snapshot attached regarding "host dependent on service":
dependency.PNG
You do not have the required permissions to view the files attached to this post.
Thanks & Regards,
I2MP Team.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Script to disable monitoring

Post by lmiltchev »

According to our developers, there isn't an easy way to do that right now. It is a good candidate for a feature request though. Let me know if you want me to file an internal feature request.

Having said that, it is probably possible to use the REST API from the CLI (GET objects/service), then filter somehow the results (grep, sed, awk, etc.) to get the info you need. This is not going to be "pretty" or easy, and it falls out of the scope of Nagios support.
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,

I am working on the script and succeeded at some extend, kindly let me know what commands are executed when we click on apply configuration?

And also let me know if my below approach is right?
1. Just deleting the hostname entry from the service configuration files present at location /usr/local/nagios/etc/services
2. Then deleting the host configuration file present at location /usr/local/nagios/etc/hosts
3. Then executing the commands for apply configuration

Kindly suggest if my approach is wrong.
Thanks & Regards,
I2MP Team.
Locked