Page 1 of 2

Nagios check_http plugin

Posted: Thu Aug 01, 2013 8:58 am
by lord_hypnos
Hi,
I have 2 simple(hope:P) questions:
1) How to chceck Content-Type in server response header. Parameter -e check only 1st line of header
2) How to set HTTP Method in request (DELETE, PUT etc. ). Parameter -j is not support now.

Thank you for help!

Re: Nagios check_http plugin

Posted: Thu Aug 01, 2013 10:16 am
by yancy
lord_hypnos,

http://nagiosplugins.org/man/check_http

Code: Select all

 -T, --content-type=STRING
    specify Content-Type header media type when POSTing

 -j, --method=STRING  (for example: HEAD, OPTIONS, TRACE, PUT, DELETE)
    Set HTTP method.
It looks like both options are supported in the documentation....

-Yancy

Re: Nagios check_http plugin

Posted: Thu Aug 01, 2013 10:42 am
by lord_hypnos
yancy wrote:lord_hypnos,

http://nagiosplugins.org/man/check_http

Code: Select all

 -T, --content-type=STRING
    specify Content-Type header media type when POSTing

 -j, --method=STRING  (for example: HEAD, OPTIONS, TRACE, PUT, DELETE)
    Set HTTP method.
It looks like both options are supported in the documentation....

-Yancy
Thank u for answer!
-j is not supported because i have error when i use it on my test Nagios XI version
-T allows You set content-type for sending POST data. When u POSTIing something to server. Or I wrong understood this parameter?

Re: Nagios check_http plugin

Posted: Thu Aug 01, 2013 12:04 pm
by yancy
lord_hypnos,
-j is not supported because i have error when i use it on my test Nagios XI version
can you post the error you're getting when running from the command line
-T allows You set content-type for sending POST data. When u POSTIing something to server. Or I wrong understood this parameter?
yes I _think_ this option controls the content type (get or post) controlled by http header. Give it a test and let us know if you run into issues

-Yancy

Re: Nagios check_http plugin

Posted: Thu Aug 01, 2013 12:26 pm
by lord_hypnos
I send POST action to WS with one param and using basic authentication

Code: Select all

COMMAND: /usr/local/nagios/libexec/check_http -I xxx.xxx.xx  -f ok -I xxx.xxx.x.xxx  -u "/XXX/Login" -p 443 -j "POST" -s "Login successful"  -P "xxxx=xxx" -S  -a "XYZ:XYZ" -t 60
OUTPUT: Usage: check_http -H  | -I  [-u ] [-p ]
       [-w ] [-c ] [-t ] [-L]
       [-a auth] [-f ] [-e ]
       [-s string] [-l] [-r  | -R ] [-P string]
       [-m :] [-4|-6] [-N] [-M ] [-A string]
       [-k string] [-S] [-C ] [-T ]
-j param is not on list

Ok now check that response is JPEG:

Code: Select all

-f ok -I XXX.XXX.X.XXX -u "/XXX/File?xxx.xxx=XXX&XXXr.XXX=XXX" -S -p 443 -a "XXX:XXX" -T "image/jpeg"-t 60
Nagios check and it's ok, BUT when i change -T to "image/jpeg222" nagios still say: "OK"

Re: Nagios check_http plugin

Posted: Thu Aug 01, 2013 5:07 pm
by abrist
I did some testing, and it seems the -T switch is not acting as expected. I will do some more testing tomorrow.

Re: Nagios check_http plugin

Posted: Wed Aug 07, 2013 3:03 am
by lord_hypnos
abrist wrote:I did some testing, and it seems the -T switch is not acting as expected. I will do some more testing tomorrow.
Any suggestions?

Can someone ask me for two simple questions:

1) How change HTTP method for HTTP Request?
2) How check Content-Type for HTTP response?

Is possible to do in Nagios or i should write my own plugin???

Re: Nagios check_http plugin

Posted: Wed Aug 07, 2013 9:25 am
by scottwilkerson
lord_hypnos wrote: 1) How change HTTP method for HTTP Request?
By adding the -P you will be posting.
lord_hypnos wrote:2) How check Content-Type for HTTP response?
his particular pligin does not test the Content-Type, the -T is for specifying the content type when posting
lord_hypnos wrote:Is possible to do in Nagios or i should write my own plugin???
I am not aware of a plugin that checks the return Content-Type so you will likely have to write your own

Re: Nagios check_http plugin

Posted: Wed Aug 07, 2013 2:12 pm
by lord_hypnos
Thank You for answer.

Is possible to send DELETE Request? Not only POST? Why -j parameter was delete ?

Send various type of http request(POST,DELETE,PUT) will be very helpful. Also possible to check content-type. Will be add this feature in the future to Nagios XI?

Re: Nagios check_http plugin

Posted: Wed Aug 07, 2013 4:59 pm
by abrist
lord_hypnos wrote:Will be add this feature in the future to Nagios XI?
It really was not on the roadmap, though you are welcome to open up a feature request at the nagios-plugins sourceforge website.