Hi
I want to add device into Nagios using HTTP POST call from HTTP server . THe client at Http server should call the POST and NAgios should store it in database just same as it do in case of SNMP discovery and return some achknowledgemet to client.
Any help would be appriciated.
Regards
How to POST http request from external HTTserver to NagiosXI
-
network2016
- Posts: 47
- Joined: Tue Mar 08, 2016 11:35 am
Re: How to POST http request from external HTTserver to Nagi
The verbose output for check_http (via the -v flag) can display a full JSON response:
And similarly if you wanted to make a POST request and provide some data (be mindful of escaping for the CLI, bash in this case):
I'm not sure what you mean by "store it in the database", but practically any and all status output from Nagios plugins makes it's way into the nagios database for the duration of that check's validity.
Code: Select all
[root@nagios ~]# /usr/local/nagios/libexec/check_http -H esdev00 --method=GET -t 3 -p 9200 -v
GET / HTTP/1.1
User-Agent: check_http/v2.2.1.git (nagios-plugins 2.2.1)
Connection: close
Host: esdev00:9200
Accept: */*
content-type:application/json
http://esdev00:9200/ is 416 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Content-Type: application/json; charset=UTF-8
Content-Length: 329
**** CONTENT ****
{
"status" : 200,
"name" : "esdev00",
"cluster_name" : "esdev",
"tagline" : "You Know, for Search"
}
HTTP OK: HTTP/1.1 200 OK - 416 bytes in 0.005 second response time |time=0.004709s;;;0.000000 size=416B;;;0Code: Select all
[root@nagios ~]# /usr/local/nagios/libexec/check_http -H esdev00 -u /hits/_search?size=1 --method=POST --post="{\"query\":{\"term\":{\"browser\":\"Chrome\"}}}" -t 3 -p 9200 -v
POST /hits/_search?size=1 HTTP/1.1
User-Agent: check_http/v2.2.1.git (nagios-plugins 2.2.1)
Connection: close
Host: esdev00:9200
Accept: */*
Content-Type: application/x-www-form-urlencoded
Content-Length: 39
{"query":{"term":{"browser":"Chrome"}}}
http://esdev00:9200/hits/_search?size=1 is 1673 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Content-Type: application/json; charset=UTF-8
Content-Length: 1585
**** CONTENT ****
{"took":74,"timed_out":false,"_shards":{"total":4,"successful":4,"failed":0},"hits":{"total":7374340,"max_score":1.54193,"hits":[{"_index":"hits","_type":"request","_id":"AVx4vLqKZ501FTCJdzXW","_score":1.54193,"_source":{"appServer":"dev01",}}]}}
HTTP OK: HTTP/1.1 200 OK - 1673 bytes in 0.080 second response time |time=0.080303s;;;0.000000 size=1673B;;;0Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
avandemore
- Posts: 1597
- Joined: Tue Sep 27, 2016 4:57 pm
Re: How to POST http request from external HTTserver to Nagi
I too am unclear as to your exact request. Perhaps you are inquiring about the API? You can find that information in XI > Help > REST API Docs. We also have this document:
https://assets.nagios.com/downloads/nag ... gement.pdf
https://assets.nagios.com/downloads/nag ... gement.pdf
Previous Nagios employee
Re: How to POST http request from external HTTserver to Nagi
Just checking in since we have not heard from you in a while. Did @avandemore's post clear things up or has the issue otherwise been resolved?
Former Nagios employee
-
network2016
- Posts: 47
- Joined: Tue Mar 08, 2016 11:35 am
Re: How to POST http request from external HTTserver to Nagi
SORRY FOR NOT REPLYING IN A WHILE
PLEASE CLOSE THIS THREAD ,IT HAS BEEN RESOLVED.
THANKS
PLEASE CLOSE THIS THREAD ,IT HAS BEEN RESOLVED.
THANKS
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: How to POST http request from external HTTserver to Nagi
No problem. Let us know if you have any other issues.