Host HTTP error


Hello all,

I have been having this error from nagios when it checks the local host HTTP. I have looked it up on the internet to see if I could find something, but unfortunately I went without any luck. Here is the error that I am getting from the local host: … nntpa4.png

This has been concurrent error since I first installed Nagios on my linux machine. Is there anything that I can configure on the linux box to get it back to the green label in Nagios?



Its being stopped because of permissions or authorisation is required on the web page you are trying to check. Perhaps you could create an “authorization-free” test page for it to check instead? Or, you could give check_http a valid username and password with the -a parameter (you’d probably want to set these up as, say $USER2$ and $USER3$ in resource.cfg to keep them out of view when someone looks at the configuration via the web interface)

[Edit: also make sure the nagios user/group has read permissions on the file you are trying to read]




I was talkin about the local host HTTP service, where nagios is installed. It shouldnt have to have a password in order to access the localhost HTTP info should it?

[EDIT: Never mind on the remote host, it fixed itself.]


Yeah, even if you try wget on a nagios page from the server itself, you get a 401 Authorization Required, so you need to ensure you are both a) permitted and b) authorized to view the page referenced in the check.




I am actually spoke to soon in my last post about the remote host. It is giving me a critical error again from being denied access to the server. How would I go about defining the password and user name in another config file. I have set up a separate config file for my remote hosts, how would I go about defining $USER2$ and $USER3$ in a seperate config file?


I think the $USERx$ macros all need to be defined by resource.cfg, which is specified as the resource_file in nagios.cfg…
They are kept in there so the CGIs won’t read them and make them available for anyone who can view the nagios web interface…
So you’d configure in resource.cfg

$USER3$=someuser $USER4$=somepassword
and then make your new command object definition

define command{ command_name check_http_plusauth command_line $USER1$/check_http -a $USER3$:$USER4$ -I $HOSTADDRESS$ -u $ARG1$ }




I have put in the root password as well as the user “root” as well as the other extra option in my command definition for the configuration, but it is still giving me the same error as beforehand. Is there anything that I might be missing? I am starting to think that is something wrong with the configuration on my local machine…


It’s grabbing it over localhost:80 b’cos you are checking the http functionality, so you will need to use a username and password with appropriate web authorization - i.e. file permissions need to be configured readable by that apache user - as if you were trying to view the page in a browser.


I have tried 2 different users in the configuration file, but niether of them worked. How do I found out which user has the right permissions for web access. Shouldnt root be enough condsidering it has all privileges? I only use 2 users, one to log on and then “root”, which has a different password from the 1st user that is used to log on. You have any ideas?


I think maybe we are still at crossed purposes with respect to web user authentication and linux user permissions… Perhaps an easy way to fix this would be to put a test page in your …nagios/share directory and chmod/chown it as per main.html and then set the check to test against that, using the nagiosadmin username and password you use to log onto the nagios front end. That way, all permissions and authorized users are known values from the outset.


I am getting an error in nagios from the http service with the following code:

define command{ command_name check_http_plusauth command_line $USER1$/check_http -a $USER3$:$USER4$ -I $HOSTADDRESS$ -u $ARG1$ }
Here is a pic of the error in Nagios: … nntes5.png

I here is what I have in resource config:

$USER3$=nagiosadmin $USER4$=the_password

Do I have to define $ARG1$ in the service deifinition for localhost http service as $USER1$?


looks good. how have you defined the check_command variable in the service object? Like



[edit: It [i]should work with -I in the command object definition but you can also use -H $HOSTADDRESS$ for localhost]


Yeah, I put that in the command_deffintion as the varible. And in which directory should I create the main.html file, so that when Nagios looks for it, it will find it? Am I suppose to put anything in the .html file, or am I just to leave it blank?

[EDIT: My check_command defition looks like this:

And I noticed when I type in 2 “//” as in “http://”, it will block out the rest of the variable as something that will not be included or read as code for the config. So I just put in the above. Will that be a problem in the config?]



I’d put something in the test.html file, if only to check you can view it via a browser… something as simple as


will be fine. That file should be in your …nagios/share/ directory. And once you emulate the user and group permissions of main.html (in the same directory) you should then be able to browse to and after entering the username and password, see ‘Test’ displayed. You also need to change the line in the service definition to


else without http:// it will come back with a bad request error


Ok, I got several different errors. I will post code with pics for you to see. Here is the first error with the following code:

Nagios error:

The reason this happens, is becuase when I use “//” it treats all text that is writen after that the same as “;”. Here is a pic of it to show you what I mean: … nntxv4.png

And here is the next error from the following code:

Here is the pic from what Nagio returns from this line of code:

I do get the test.html page up on my browser without any errors. I also have the user name and password set in resource.cfg. So I think that is working, but not entirely correctly. Is there a setting on my local linux machine that I could configure?



So the last grab, the “Bad Request”, is to be expected without the “http://” prefix… however it surprises me that you are getting the other (139) error when using the prefix, if you compare it with the below from my working service check, there’s no significant difference:

define service{ use local-service ; Name of service template to use host_name localhost service_description HTTP check_command check_http_plusauth!http://localhost/nagios/check.html notifications_enabled 1 }
I think that the blue “text” writing you are seeing is just being overlayed by a rule on your terminal program’s interpreter (that has been told to colour anything following “//”) and so should not have any effect on the configuration itself, so that is not a problem…

What do you get from running the following at the command prompt (in libexec dir)?

./check_http -I localhost -a username:Password -u localhost/nagios/test.html


Here is the result from the command:


and you changed username:Password to reflect the correct values?


Hey man, your the best. It works finally!!! It looks so nice now, everything is green. :stuck_out_tongue: Thanks a bunch for your help, much appreciated.