Page 1 of 2

Executing POST statement

Posted: Fri Mar 29, 2013 1:08 pm
by stecino
Hi everyone,

Is there a way for me to run POST with nagios, other than a curl command embedded in bash script?

Re: Executing POST statement

Posted: Fri Mar 29, 2013 6:57 pm
by stecino
I have the following setup
in nrpe.cfg

command[check_http]=/usr/local/nagios/libexec/check_http -w $ARG1$ -c $ARG2$ -u $ARG3$ -p $ARG4$ -P $ARGS5$

Nagios service definition

define service{
use generic-service
hostgroup_name stage_webservers
service_description Web_sso2_8088_login
check_command check_http!2!4!/fans/rs/login!8088!username=testdude&password=password
notifications_enabled 1
}

Running on my nagios server from command line:

root@stageutil01 libexec]# ./check_http -H stageweb01 -w 2 -c 4 -u /fans/rs/login -p 8088 -P 'username=testdude&password=password'
HTTP OK: HTTP/1.1 200 OK - 1590 bytes in 0.197 second response time |time=0.197171s;2.000000;4.000000;0.000000 size=1590B;;;0

On nagios GUI:

Current Status:
WARNING
(for 0d 0h 8m 36s)
Status Information: HTTP WARNING: HTTP/1.1 405 Method Not Allowed - 1328 bytes in 0.020 second response time
Performance Data: time=0.020231s;2.000000;4.000000;0.000000 size=1328B;;;0

Re: Executing POST statement

Posted: Sat Mar 30, 2013 12:34 pm
by scottwilkerson
missing quotes
change this

Code: Select all

define service{
use generic-service
hostgroup_name stage_webservers
service_description Web_sso2_8088_login
check_command check_http!2!4!/fans/rs/login!8088!username=testdude&password=password
notifications_enabled 1
}
to this
change this

Code: Select all

define service{
use generic-service
hostgroup_name stage_webservers
service_description Web_sso2_8088_login
check_command check_http!2!4!/fans/rs/login!8088!'username=testdude&password=password'
notifications_enabled 1
}

Re: Executing POST statement

Posted: Mon Apr 01, 2013 1:24 pm
by stecino
I added the single quotes, but it didn't change

Re: Executing POST statement

Posted: Mon Apr 01, 2013 2:01 pm
by abrist
Try url-encoding the ampersand:

Code: Select all

check_command check_http!2!4!/fans/rs/login!8088!username=testdude%26password=password

Re: Executing POST statement

Posted: Mon Apr 01, 2013 2:21 pm
by stecino
Tried that, "No Bueno"

Re: Executing POST statement

Posted: Mon Apr 01, 2013 2:26 pm
by abrist
Is there any reason why you are running this check through nrpe?
Have you tried running the command from the cli as user nagios?

Re: Executing POST statement

Posted: Mon Apr 01, 2013 2:34 pm
by stecino
What command are you referring to?

I'm running this from command line interface to verify

[root@stageutil01 libexec]# ./check_http -H stageweb01 -w 2 -c 4 -u /fans/rs/login -p 8088 -P 'username=testdude&password=password'
HTTP OK: HTTP/1.1 200 OK - 1590 bytes in 0.118 second response time |time=0.117990s;2.000000;4.000000;0.000000 size=1590B;;;0

Re: Executing POST statement

Posted: Mon Apr 01, 2013 2:38 pm
by stecino
I have bash script that uses curl to execute, but I don't know how to configure it within Nagios

Re: Executing POST statement

Posted: Mon Apr 01, 2013 2:44 pm
by abrist
I was confused by the following:
stecino wrote:I have the following setup
in nrpe.cfg

command[check_http]=/usr/local/nagios/libexec/check_http -w $ARG1$ -c $ARG2$ -u $ARG3$ -p $ARG4$ -P $ARGS5$
But it looks like you have the check setup in core without "check_nrpe" (so ignore).
Could you do me a favor and try running the check from the cli as the nagios user?

Code: Select all

su nagios
./check_http -H stageweb01 -w 2 -c 4 -u /fans/rs/login -p 8088 -P 'username=testdude&password=password'