1

With cURL, I can successfully log into the website I want have Nagios test by passing --cookies.

Something like this: curl --cookie "user=4reqrerqwr;userlogin=123adsfjlk324" http://mysite.com/home/index.aspx -v | grep Welcome

I know it is successful because, 1, I can visually see the rendered code and 2, the grep search for Welcome would only be seen if the authentication was successful.

I am trying to mimic this in Nagios with check_http like so:

./check_http -H mysite.com -u http://mysite.com/home/index.aspx -f follow 
       -s Welcome -k 'Cookie: user=4reqrerqwr;userlogin=123adsfjlk324' -v

One big difference I see is that in cURL the cookie is set on 1 line but the verbose response from check_http shows the cookie on two lines.

Cookie: user=4reqrerqwr;userlogin=123adsfjlk324  

vs.

Cookie: user=4reqrerqwr  
userlogin=123adsfjlk324

I am open to suggestions and of course alternatives. I have checked out WebInject but this seems to be SO close I hate to drop it.

Lastly, I have tried check_curl, and extended it to support cookies. This DOES work but I am getting (null) on the responses and the grep never causes Nagios to fail regardless of a valid result being returned.

splattne
  • 28,508
  • 20
  • 98
  • 148
af-at-work
  • 670
  • 1
  • 6
  • 12

1 Answers1

2

Try passing

check_http ...  -k "Cookie: user=4reqrerqwr" -k "Cookie: userlogin=123adsfjlk324"
splattne
  • 28,508
  • 20
  • 98
  • 148
Eric B
  • 31
  • 2
  • Thanks! I tried that too, but still get the cookie spread over two lines. Cookie: user=4reqrerqwr userlogin=123adsfjlk324 – af-at-work Aug 04 '11 at 18:29
  • I do believe I have tried -k "Cookie: user=4reqrerqwr" -k "Cookie: userlogin=123adsfjlk324" as well, but I will try again just in case. Cheers. – af-at-work Aug 05 '11 at 14:52
  • The second Cookie: does not make it.. – af-at-work Aug 05 '11 at 15:14
  • It looks like Nagios sees the ; as the start of a comment so ignore anything after that. I tried to variablize the entire comment string in a user macro but I always get the same result. It looks like a bug in Nagios. – af-at-work Aug 08 '11 at 21:15
  • http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=328984 – af-at-work Aug 08 '11 at 21:22