Page 1 of 1

Use nagios to send xml request to web service, and retrieve

Posted: Fri May 16, 2014 5:50 am
by gsd_pe
I'm sending a request manually over Soap UI currently, the request is as follows.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelop ... chcustomer">
<soapenv:Header/>
<soapenv:Body>
<sear:searchCustomerRequest>
<sear:sustomerID>0000245</sear:sustomerID>
<sear:registrationStatus>R</sear:registrationStatus>
<sear:versionNumber>1.0</sear:versionNumber>
</sear:searchCustomerRequest>
</soapenv:Body>
</soapenv:Envelope>

Now, I was hoping it would be possible to sent this using the check_http class/function in Nagios XI, Do you know if this is possible?
I would hope it would give me the following:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<ns2:searchGprnResponse xmlns:ns2="http://www.mysite.com/ws/gasmapservice/searchcustomer">
<ns2:areaName>Blackrock, County Dublin</ns2:areaName>
<ns2:townName>Dublin City</ns2:townName>
<ns2:countyName>Dublin</ns2:countyName>
</ns2:searchcustomer>
</env:Body>
</env:Envelope>

I would then like to grep for, lets say "Dublin", and if the count is > 0 then it would give an OK, if it doesn't return this, then it would give a failure.
I'm new to nagios, and am finding it a bit complicated to get this working,
Any Ideas would be greatly appreciated, I was thinking CURL might work, not sure though :)

Re: Use nagios to send xml request to web service, and retri

Posted: Fri May 16, 2014 1:44 pm
by abrist
You can submit post data with check_http:

Code: Select all

./plugins/check_http --help | grep -4 post
 -s, --string=STRING
    String to expect in the content
 -u, --url=PATH
    URL to GET or POST (default: /)
 -P, --post=STRING
    URL encoded http POST data
 -j, --method=STRING  (for example: HEAD, OPTIONS, TRACE, PUT, DELETE)
    Set HTTP method.
 -N, --no-body
So your check may look something like:

Code: Select all

check_http -H <host>  -P "Post data here" -r "Dublin"