Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using nagios to monitor various services in our production environment. But for one such service, I noticed that nagios is showing "OK" state despite the service being down and not running. I'm using check_http plugin to achieve the same. On running the check command on cli of the server, I get the result as below. I notice that the exit status code returned is 2, which indicates a CRITICAL state for nagios. But, instead the state being shown is "OK". Any pointers on how to deal with this problem is greatly appreciated. Thanks in advance.

me@myserver:~$ check_http -H localhost -p 8180 -u /SomeService/services?_wadl

Connection refused

HTTP CRITICAL - Unable to open TCP socket

me@myserver:~$ echo $?

2

share|improve this question
    
Please post the relevant 'check_command' line from the nagios configuration file of the host. The command is under the service definition. –  Daniel t. Nov 29 '13 at 21:16

2 Answers 2

Thanks for the pointers keith and Daniel. I figured out the solution to the problem.

The check command URL path parameter configured in the NConf was

/SomeService/services?_wadl&_type=xml

But on checking /var/log/syslog on the server, I could find the URL path actually being executed was /SomeService/services?_wadl ( Pls note the stripping of "type=xml" part).

On running the check command with these two URL paths separately, I noticed that, I had to hit an "Enter" key to get the exit status of the command with URL containing "type=xml", which explains why nagios never got the exit status 2. While the other URL returned the exit status without any manual intervention.

me@myserver:$ check_http -H localhost -p 8180 -u /SomeService/services?_wadl&_type=xml

[1] 3543

me@myserver:$ Connection refused

HTTP CRITICAL - Unable to open TCP socket

[Hit Enter and then I get my exit status]

[1]+ Exit 2 check_http -H localhost -p 8180 -u /SomeService/services?_wadl

me@myserver:$ check_http -H localhost -p 8180 -u /SomeService/services?_wadl

Connection refused

HTTP CRITICAL - Unable to open TCP socket

[I instantly got my exit status without manual intervention]

On changing the URL path in the Nconf to /SomeService/services?_wadl, I started getting correct exit status and nagios started reporting CRITICAL when the service actually went down. But I'm still wondering, why does check_http plugin wait for a user intervention to return the exit code when the URL contains a "&_type=xml"?

share|improve this answer
    
In your manual testing, the & is causing the job to background. You have to escape this so the shell doesn't process it. –  Keith Dec 5 '13 at 15:11

Your manual test doesn't match what Nagios is doing.

Most likely, you're passing ARGs to check_http that are being ignored. Compare the command definition for the service check_command you're using with your manual test.

If you haven't already, be sure to read the docs page on Macros and How They Work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.