3

I just installed nagios on a server machine, only to be greeted with a critical error on the HTTP service.

the error is

HTTP CRITICAL - Socket timeout after 10 seconds 

I searched for this error and got the suggestion to run check_http with a longer timeout. so I appended -t 20 in file commands.cfg, next to "check_http" command. restarted nagios but i still get an error (for the new timeout).

Then searched some more. The error seems common, so I start thinking I may have some other problem.

I tried running check_http on my own:

root@srv$ /usr/libexec/nagios/check_http -H localhost -N -p 80 -t 1

HTTP OK: HTTP/1.1 200 OK - 846 bytes in 0.003 second response time |time=0.003080s;;;0.000000 size=846B;;;0

The response seems alright, but I know little about http.

Any clues?

EDIT: the command definition for check_http , taken from /etc/nagios/objects/commands.cfg is

# 'check_http' command definition
define command{
        command_name    check_http
        command_line    $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
        }

I am not sure how to check what are the values of the variables $HOSTADDRESS$ and more importantly $ARG1$.

then the definition of the service is

define service{
    use                             local-service         ; Name of service template to use
    host_name                       localhost
    service_description             HTTP
    check_command                   check_http
    notifications_enabled           1
    }

the distribution is slackware 14.0 64bit.

13
  • 1
    Try running check_http -H with the FQDN which is what nagios will apply.
    – mdpc
    Aug 7, 2013 at 16:20
  • @mdpc check_http -H stargaze.skails.home. the FQDN is just an internal domain name. I hope this is what you were seeking ?:)
    – nass
    Aug 7, 2013 at 17:31
  • it respons just like before...
    – nass
    Aug 7, 2013 at 17:41
  • Is the nagios host the SAME as your http host? You have to be running the test from the nagios host.
    – mdpc
    Aug 7, 2013 at 17:42
  • 1
    and where's the service definition? if you don't know what ARG1 is, you need to read nagios.sourceforge.net/docs/3_0/macros.html
    – Keith
    Aug 8, 2013 at 20:38

3 Answers 3

1

Your check command doesn't match your manual test.

If you want Nagios to perform the check in the same way that you're testing it manually, your service definition would have to be like this due to the way your check command is defined:

define service{
    use                             local-service
    host_name                       localhost
    service_description             HTTP
    check_command                   check_http!-N -p 80 -t 1
    notifications_enabled           1
}

... and you would also have to have "localhost" as the address for this host.

(But a timeout of 1 second is kind of short.)

0

The check_http plugin just does the equivalent of trying to load a webpage from an external IP. Check to make sure that you can load the webpage in your browser, and that the plugin works on the command line with the exact same host definition you've specified in the configuration files (FQDN or IP number).

If you're really checking localhost, try it with 127.0.0.1, and also try to use something like wget to check that localhost is really allowed to load webpages from itself (wget http://127.0.0.1). This will also work for other sites (wget http://www.yourdomain.com).

2
  • ok I tried wget http://xxx.xxx, where xxx.xxx is the following. 127.0.0.1: works fine (=downloads index.html), localhost: works and dls fine index.html, stargaze.skails.home: again works and dls index.html, stargaze, the same. 192.168.112.112: the same...
    – nass
    Aug 7, 2013 at 17:39
  • 1
    OK, then you probably need to check your definitions. But double check with check_http -H stargaze.skails.home and if that succeeds, there's possibly something wrong with your definitions--possibly host, or the check_http defaults. Aug 7, 2013 at 18:57
0

The variables you ask $HOSTADDRESS$ $HOSTNAME$ and so on is like asking for the field ADDRESS of the HOST definition, same for $SERVICEXXXX$. The $ARG1$ is what it expect after the ! in your command definition as already stated.

In this particular case:

check_command                   check_http!-N -p 80 -t 1

$ARG1$ = -N -p 80 -t 1 //-p 80 is not necesary as 80 is the default for http.

Hope this help you to understand Nagios Macros.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .