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
Remove Host/Service from monitoring using command line
Re: Remove Host/Service from monitoring using command line
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.
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
Re: Remove Host/Service from monitoring using command line
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.
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
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
Re: Remove Host/Service from monitoring using command line
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"
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
Looks like you got that sorted out. Are we good to close this thread?
Former Nagios employee
Re: Remove Host/Service from monitoring using command line
Yup! we can close this thread 