Page 1 of 1

Remove Host/Service from monitoring using command line

Posted: Tue Oct 04, 2016 9:00 am
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

Re: Remove Host/Service from monitoring using command line

Posted: Tue Oct 04, 2016 11:24 am
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.

Re: Remove Host/Service from monitoring using command line

Posted: Wed Oct 05, 2016 5:32 am
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.

Re: Remove Host/Service from monitoring using command line

Posted: Wed Oct 05, 2016 2:14 pm
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.

Re: Remove Host/Service from monitoring using command line

Posted: Thu Oct 06, 2016 5:58 am
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"

Re: Remove Host/Service from monitoring using command line

Posted: Thu Oct 06, 2016 10:55 am
by tmcdonald
Looks like you got that sorted out. Are we good to close this thread?

Re: Remove Host/Service from monitoring using command line

Posted: Tue Oct 11, 2016 5:21 am
by Avinash91
Yup! we can close this thread :)