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.
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:
... and you would also have to have "localhost" as the address for this host.
(But a timeout of 1 second is kind of short.)
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
).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:
$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.