Executing POST statement

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Executing POST statement

Post by stecino »

Hi everyone,

Is there a way for me to run POST with nagios, other than a curl command embedded in bash script?
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Executing POST statement

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Executing POST statement

Post 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
}
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Executing POST statement

Post by stecino »

I added the single quotes, but it didn't change
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Executing POST statement

Post by abrist »

Try url-encoding the ampersand:

Code: Select all

check_command check_http!2!4!/fans/rs/login!8088!username=testdude%26password=password
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Executing POST statement

Post by stecino »

Tried that, "No Bueno"
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Executing POST statement

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Executing POST statement

Post 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
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Executing POST statement

Post by stecino »

I have bash script that uses curl to execute, but I don't know how to configure it within Nagios
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Executing POST statement

Post 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'
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked