Wednesday, July 23, 2008

check_http as a Nagios Web Service plugin

We typically use nagios to monitor our hardware and hosted services. Now that we are starting to offer more web services, we wanted to replace the ad-hoc curl wrapper we were using with a more standard nagios plugin. After searching for one and not finding any, it occurred to me that if curl can do it, maybe you can trick the standard check_http plugin to also do it. A quick experiment with an https hosted web service (self signed certificate for this test) shows that it works:

./check_http -S -k 'SOAPAction: ping' -r 'Current Status.*OK' -T text/xml -P '<s:envelope s="http://schemas.xmlsoap.org/soap/envelope/"><s:header/><s:body><ping/><s:Body><s:Envelope>' -t 10 -m 512 -p 8083 -H 192.168.1.254 -u /Services/Search/search.svc
HTTP OK HTTP/1.1 200 OK - 0.033 second response time |time=0.032722s;;;0.000000 size=897B;512;0;0

Now time to look at nagios grapher...

10 comments:

pve said...

Very neat. Simple and effective.
Thanks.

Aleksandar said...

Outstanding job! Thanks a million!

mama said...

props to you - works like a charm.

Levy Carneiro Jr. said...
This comment has been removed by the author.
Levy Carneiro Jr. said...

I developed a similar plugin for Nagios, written in Python, for testing Webservices.

The nice about it is the ability to use a config file in a nicely formatted way, instead having to pass the arguments as command line options, which makes it a little cluttered in my opinion.

You can test the response against as many regular expressions as you want. Then you can define if at least one or all of them must match.

You can send special HTTP headers, set a timeout for the request, set the method (GET or POST), set a string to be POSTed (content), and so on.

Check it out at: http://github.com/levycarneiro/check_webservice

Brian said...

Some of our internal web servers are protected with Windows Authentication which check_http doesn't work with. Are you aware of any alternatives?

Jason Brazile said...

@brian - Sorry I have never had to deal with Windows Authentication for a nagios check. Good luck.

Elizabeth Greene said...

@Brian, Jason:

We use check_http_ntlm.pl from the exchange..
http://exchange.nagios.org/directory/Plugins/Network-Protocols/HTTP/check_http_ntlm-2Epl/details
to check Our Windows Auth Webservices. It is a wrapper for curl with the -ntlm option on it.

-Ellie

Simon Thrane Hansen said...

Hi

I was wondering how I can check if the HTTP response contains a special string.
What kinds of commands do I have to give the plugin?

Jason Brazile said...

@Simon

http://nagios-plugins.org/doc/man/check_http.html

Look at flags like -s, -r, -R, etc.