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

Already set up my local net configuration to be monitored by Nagios3. I found a problem that Nagios3 reports a warning in the HTTP monitoring service of a Debian server set at ip 192.168.1.52, that has an individual virtual host and a mass virtual host for application development. I get this status message:

HTTP WARNING: HTTP/1.1 404 Not Found

I used the Nagios tools to check. servername is the name of the vhost server name I used in the Apache configuration.

/usr/lib/nagios/plugins/check_http -H servername -I 192.168.1.52

receiving this status message:

HTTP OK HTTP/1.1 200 OK - 37900 bytes in 0.504 seconds |time=0.503946s;;;0.000000 size=37900B;;;0

But when I check like this:

/usr/lib/nagios/plugins/check_http -I 192.168.1.52

I get the same status message as the warning, so I assume that I don't have Nagios completely well set up because doesn't recognize the vhosts for that server, how it should be as the check_http service shows.

Where should I look to fix that warning?

share|improve this question
1  
We need to know how the check is acutally executed by nagios. Can you give is the full service and command objects in question in your configuration? –  tore- Apr 21 '10 at 11:43

5 Answers 5

how do you define service in nagios?

it should be sth like this:

define command{
command_name    my_check_http
command_line    $USER1$/check_http -H$ARG1$ -I $HOSTADDRESS$
}

define host{
use                     generic-host
host_name               something
alias                   something
address                 192.168.1.52
# ...
}

define service{
use  generic-service
host_name something
check_http_args!nameofvhost
# ...
}
share|improve this answer
up vote 2 down vote accepted

people. Many thanks for the help but I found the answer by myself before checking any of your answers, sorry!

To solve it I made a custom command in the commands.cfg file, like this:

define command{

   command_name    custom_check_http  
   command_line    $USER1$/check_http -H $HOSTNAME$ -I $HOSTADDRESS$  

}

Not really sure about the purpose of $USER1$ but it crashes without it, with a 127 limit out of bonds error.

The host definitions were already correctly written with host_name and address (sorry for that lack of info!), simillar as the one that pQd wrote.

define host{

   host_name SERVERNAME
   alias SERVERNAME_ALIAS
   address 192.168.1.52
   ...

}

Finally the definition of the service at services_nagios2.cfg file just simple as the default ones:

define service {

   hostgroup_name                  http-servers  
   service_description             Apache  
   check_command                   custom_check_http  
   use                             generic-service  
   notification_interval           0 ; set > 0 if you want to be renotified

}

I hadnt' realized the use of variables $HOSTNAME$ and $HOSTADDRESS$ before asking this question. Thanks again for the help.

share|improve this answer

Had the "same" problem on one of our web servers. And it appeared after an update on our website was done. they also changed the headers in the IIS and that´s why the error started to appear.

solution: changed the server name to the website name; "server name" to "site.com"

share|improve this answer

I would try bypassing Nagios and use wget from the command line on your Nagios host to check the URLs you are sending to Nagios:

wget http://192.168.1.52/
wget http://servername/

From the above, I'm guessing that the first command will fail but the second one will work, which leads me to believe that your virtual server name is resolving to a different IP address. Try

dig servername

to confirm.

A general Nagios debugging tip is to try the -v option, which most plugins implement to provide verbose output. The capture_plugin script is really useful for capturing debug output when the plugin is run under Nagios.

share|improve this answer

In your services.cfg, either check the servername instead of the IP, or check the port instead of the http response.

Example of the latter:

check_command   check_tcp!80
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.