Script to disable monitoring

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Script to disable monitoring

Post by gormank »

My sed's a bit rusty... sed "s/register.*1/register\t\t\t0/"

The grep -v is just to remove comments.

Code: Select all

# grep -v ^# host.cfg

define host {
        host_name                       host
        use                             default_host
        alias                           Windows update VM?
        address                         10.133.134.80
        contacts                        nagiosadmin
        icon_image                      win_server.png
        statusmap_image                 win_server.png
        _xiwizard                       windowsserver
        register                        1
        }

# grep -v ^# host.cfg | sed "s/register.*1/register\t\t\t0/"

define host {
        host_name                       host
        use                             default_host
        alias                           Windows update VM?
        address                         10.133.134.80
        contacts                        nagiosadmin
        icon_image                      win_server.png
        statusmap_image                 win_server.png
        _xiwizard                       windowsserver
        register                        0
        }

bheden
Product Development Manager
Posts: 179
Joined: Thu Feb 13, 2014 9:50 am
Location: Nagios Enterprises

Re: Script to disable monitoring

Post by bheden »

If you're on XI 5.3.0 or greater, my suggestion would be to use the REST API...

Delete Service:

Code: Select all

curl -XDELETE "http://nagiosxi/nagiosxi/api/v1/config/service?apikey=[APIKEY]&pretty=1&host_name=[HOSTNAME]&service_description=[SERVICEDESCRIPTION]&applyconfig=1"
Delete Host:

Code: Select all

curl -XDELETE "http://nagiosxi/nagiosxi/api/v1/config/host?apikey=[APIKEY]&pretty=1&host_name=[HOSTNAME]&applyconfig=1"
Where your API key is represented as [APIKEY], the host name is represented as [HOSTNAME], and the service description is represented as [SERVICEDESCRIPTION].

You can find the documentation in your XI system under the Help menu. Hope this helps point you in the right direction!

Also, if you have a lot of these to do at once, I wouldn't use applyconfig=1 after each - only the last one would be necessary.

Edit: Addition to original text and formatting.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Nagios Enterprises
Senior Developer
Locked