Remove Host/Service from monitoring using command line

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Avinash91
Posts: 14
Joined: Thu Feb 04, 2016 4:37 am

Remove Host/Service from monitoring using command line

Post by Avinash91 »

Currently I am able to remove hosts /services from monitoring on the Nagios portal using the CCM. I would like to do the same using a script on the command line.
I have

created a host "remove_host_monitoring" and corresponding service "remove_service_monitoring". I understand that all the hosts and services config files are present

under the path /usr/local/nagiosxi/scripts/
I moved to the folder /usr/local/nagiosxi/scripts/ using cd /usr/local/nagiosxi/scripts/
I am not able to remove the service

from monitoring using the command ./nagiosql_delete_service.php –-config=remove_host_monitoring.

The error that I am getting.
./nagiosql_delete_service.php --

config=remove_host_monitoring
o/p:
URL: http://localhost/nagiosxi/includes/components/ccm/
Unable find services in nagiosql database.
Usage: ./nagiosql_delete_service.php

[--id=<service id>] [--config=<config_name>]
I also tried to apply configuration using the command: ./reconfigure_nagios.sh
Can you please suggest on how to remove

services from monitoring using command line
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Remove Host/Service from monitoring using command line

Post by tmcdonald »

I would not recommend using those scripts for this purpose unless you are 100% sure how they work - those are used internally by the application and as part of our troubleshooting.

I would strongly recommend using the API that was introduced in Nagios XI 5. Information on its usage is available in the web interface under the Help menu.
Former Nagios employee
Avinash91
Posts: 14
Joined: Thu Feb 04, 2016 4:37 am

Re: Remove Host/Service from monitoring using command line

Post by Avinash91 »

Thanks for the reply @ tmcdonald
I am using the Nagios Xi Version 5.2.9. I searched the help menu for the API but didn't find anything specific. Is the API available on this version?
Can you please share the API name or the usage info.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Remove Host/Service from monitoring using command line

Post by tmcdonald »

The information should be in there. If you are in the Help section then in the top-left there should be a category called Backend API Docs which contains links to the various pages. If you are not seeing this, please send a screenshot of your Help page.
Former Nagios employee
Avinash91
Posts: 14
Joined: Thu Feb 04, 2016 4:37 am

Re: Remove Host/Service from monitoring using command line

Post by Avinash91 »

Thanks for your reply @tmcdonald.
I was able to find the API and commands to remove hosts and services from monitoring.

PFB the commands in case anyone else is looking for a similar command

To Remove host:
curl -XDELETE "http://10.10.83.94/nagiosxi/api/v1/conf ... lyconfig=1"

To Remove service:
curl -XDELETE "http://10.10.83.94/nagiosxi/api/v1/conf ... lyconfig=1"
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Remove Host/Service from monitoring using command line

Post by tmcdonald »

Looks like you got that sorted out. Are we good to close this thread?
Former Nagios employee
Avinash91
Posts: 14
Joined: Thu Feb 04, 2016 4:37 am

Re: Remove Host/Service from monitoring using command line

Post by Avinash91 »

Yup! we can close this thread :)
Locked