Deployment/ Removal of Host via API

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
biswajit.banerjee
Posts: 152
Joined: Fri Dec 08, 2017 10:24 pm

Deployment/ Removal of Host via API

Post 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
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Deployment/ Removal of Host via API

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
biswajit.banerjee
Posts: 152
Joined: Fri Dec 08, 2017 10:24 pm

Re: Deployment/ Removal of Host via API

Post 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)
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Deployment/ Removal of Host via API

Post 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&notification_interval=30&applyconfig=1"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked