Page 3 of 3

Re: Script to disable monitoring

Posted: Wed Dec 07, 2016 9:29 pm
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
        }


Re: Script to disable monitoring

Posted: Thu Dec 08, 2016 10:38 am
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.