Page 1 of 1
Deployment/ Removal of Host via API
Posted: Mon Feb 03, 2020 12:28 pm
by biswajit.banerjee
We are using Nagios API for deploying the host but we do not find any logs in /usr/local/nagiosxi/var/load_url.log where as host get deployed successfully in Nagios .
Also , Calling API for removal for host is some how failing and as logs are not there so we are not able to diagnose the issue .
Please help
TIA
Re: Deployment/ Removal of Host via API
Posted: Mon Feb 03, 2020 2:45 pm
by benjaminsmith
Hello
@biswalt.banerjee,
Let's take a look at the apache logs for any errors (
/var/log/httpd ). You'll find the GET/POST requests in the access_log, can you post the logs to the thread. Also, it would be helpful to review the API call you are using. Thanks.
Code: Select all
tail /var/log/httpd/*error_log /var/log/httpd/*access_log
Re: Deployment/ Removal of Host via API
Posted: Tue Feb 04, 2020 12:02 pm
by biswajit.banerjee
API Information is Below , using Service Catalog to provision AWS Host
Provisioning:
URL:
http://nagiosxi/nagiosxi/api/v1/config/ ... >&pretty=1
Method: POST
Data to Pass (items in bold are variables passed from PMG):
host_name=
<host_name>&address=
<host_IP_address>&use=ht_cis_io_ops_ma_
<OS_value_from_form>_aws_
<Dev_or_Prod_environment_from_form>&hostgroups=hgt_stacked_
<OS_value_from_form>_Cloudwatch_build-AWS-
<AWS_Account_value_from_form>,gearman_dca1,Servers - DCA - NV&force=1&applyconfig=1
Termination:
URL:
http://nagiosxi/nagiosxi/api/v1/config/ ... >&pretty=1
Method: DELETE
Data to Pass:
There are no options set here, this may be why things are failing to delete (I’m assuming it needs something similar to the Add string in order to know which host to delete)
Re: Deployment/ Removal of Host via API
Posted: Tue Feb 04, 2020 3:16 pm
by benjaminsmith
Hello,
Thank you for posting the commands. Not sure exactly what the strings look like but I see some spaces, remember to url encode any data that is beings passed such as / or blank spaces. You can use the tool below to assist.
https://meyerweb.com/eric/tools/dencoder/
If that is not the issue, run the following tail command on the XI subsystem to watch the new configuration get applied. Post the output to the thread.
Code: Select all
tail -F /usr/local/nagiosxi/var/cmdsubsys.log
Are you able to add a host successfully using the sample command provided in the API docs?
Code: Select all
curl -XPUT "http://192.168.0.232/nagiosxi/api/v1/config/host/testapihost?apikey=<api key>&pretty=1&address=127.0.0.1¬ification_interval=30&applyconfig=1"