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

Re: Executing POST statement

Post by stecino »

I ran it, it's asking for a password. Which I don't remember. May I ask what will this give me?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Executing POST statement

Post by abrist »

Did you replace "testdude" and "password" in
abrist wrote:'username=testdude&password=password'
with your username and password (for the post)? If so, then something you trying to do requires root or elevated privileges to run as it worked when you ran it from the cli as the "root" user. Lets check the permissions on "check_http":

Code: Select all

ls -la /path/to/plugins/check_http
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 »

Here is what I have

[nagios@stageutil01 libexec]$ ls -al | grep http
-rwxr-xr-x 1 nagios nagios 321432 May 12 2010 check_http

The username and password is used as part of the POST data that's passed into the applications API
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Executing POST statement

Post by abrist »

Alright. So if you run the command as "root" it works, but if you run it as "nagios" is fails waiting for login credentials? I ask because most service check plugins in nagios run as the "nagios" user, not "root".
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 »

I was able to switch to nagios

-bash-3.00$ ./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.120 second response time |time=0.120300s;2.000000;4.000000;0.000000 size=1590B;;;0
-bash-3.00$ id
uid=10003(nagios) gid=888(nagios)

It works as well
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Executing POST statement

Post by abrist »

Does you check work without the "?" at the end of the uri option? I ask because it was missing earlier in your config post.

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
"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 »

I updated my command definition, it fails both with ? and without ?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Executing POST statement

Post by abrist »

Can you post the command definition for "check_http" from your commands.cfg file?
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 »

I ended up creating a separate command definition called check_http_POST and changed my service definition to reference this command and it worked.
Locked