Verify Configuration

While trying to verify my configuration I receive the following error:

Error: Unexpected token or statement in file ‘/usr/local/nagios/etc/cgi.cfg’ on line 15.

Here are the first 16 lines of the cgi.cfg file:

############################################################

CGI.CFG - Sample CGI Configuration File for Nagios

Last Modified: 10-08-2003

############################################################

MAIN CONFIGURATION FILE

This tells the CGIs where to find your main configuration file.

The CGIs will read the main and host config files for any other

data they might need.

main_config_file=/usr/local/nagios/etc/nagios.cfg

If anyone has any suggestions I would appreciate them.

Your main_config_file line looks the same as mine for my 2.0b3 config.
What version are you using?
What command did you use for verifying your config?
You could also try commenting out that line and then typing it in again.

I am using Red Hat 9 and Nagios 2.0b3. The command I used was
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

I am not sure why it does not work. Did you make your own cgi.cfg or steal the sample one?

AFAIT your line matches the one in my config and the docs. The only thing I can think of happening in that case is that some weird invisible character snuck its way in. Try commenting out the current line and typing it again the next line down.

Alaster

I had an entry in nagios.cfg that was telling nagios there were objects defined in cgi.cfg. I removed that line from nagios.cfg and am able to start Nagios. Now my problem is that when I try to access http:/nagios/nagios with a valid username and password setup in .htaccess and my /usr/local/nagios/etc/passwords file I can not get authenticated.

Authentication for the web interface takes three parts working together:

  1. Webserver based authentication; must have working config. Your use is probobly using basic auth. and an htpasswd file. Make sure these are all correct.

  2. Nagios user. Each user of the web interface must have a contact defined by the same name as is used to login.

  3. CGI permissions. cgi.cfg configures permissions for who can access what. Make sure these match what you need.

What part of this scheme is not working? Can you get passed the prompt from the web broweser?

I am not getting passed the prompt from the web browser. I have created new .htaccess and .htpasswd files and am having the same problem. I have my web interface user set up the same as my Nagios user. I have also given my user permissions in the cgi.cfg file.

Your apache config should include something like the following:

Alias /nagios /usr/local/nagios/share
<Directory “/usr/local/nagios/share”>
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all

The most pertinant line here is the AllowOverride. If this exists please post the relevant parts of your apache config and the .htaccess file (please do NOT post the .htpasswd file).

Here is my http.conf Nagios section:

Nagios alias for nagios/nagios

ScriptAlias /nagios/cgibin /usr/local/nagios/sbin
<Directory “/usr/local/nagios/sbin”>
AllowOverride All
order allow,deny
allow from all
Options ExecCGI

Alias /nagios /usr/local/nagios/share
<Directory “/usr/local/nagios/share”>
AllowOverride All
order allow,deny
allow from all

Here are my .htaccess entries:

AuthUserFile /usr/local/nagios/etc/.htpasswd
AuthName "Testing .htaccess"
AuthType Basic
Require valid-user

If you need to see anything else let me know.

Did you put .htaccess in both /usr/local/nagios/share and /usr/local/nagios/sbin?

Yes.

I changed the group of the .htpasswd file to apache and was able to authenticate and access Nagios. Nagios is now functioning properly. Thanks for your help.

You have said 2 different things here. Is your user and passwords in
"AuthUserFile /usr/local/nagios/etc/.htpasswd"
or in
"I try to access http:/nagios/nagios with a valid username and password setup in .htaccess and my /usr/local/nagios/etc/passwords file I can not get authenticated."

Something doesn’t look right here.

I didn’t state that clearly. the username and password were setup in .htpasswd, the passwords file was the first one I tried. After that didn’t work I changed the name to start working with the hidden .htpasswd file. While the .htpasswd file was owned by root and the root group I could not access http:/nagios/nagios. Once I changed the group for .htpasswd to apache, I was able to gain access to Nagios using .htaccess authorization.