1

I'm using Nagios 3.2.3 on CentOS 6.5. Everything during install and make went smoothly. I transferred over my conf files, made the appropriate changes, and did a pre-flight test against my nagios.cfg file. In my nagios.cfg file, I use cfg_dir=/usr/local/nagios/etc/conf.d and then let Nagios recursively search through that directory.

Output of /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg shows the following:

Website: http://www.nagios.org
Reading configuration data...
    Read main config file okay...
Processing object config directory '/usr/local/nagios/etc/conf.d'...
Processing object config directory '/usr/local/nagios/etc/conf.d/hostgroups.d'...
Processing object config file '/usr/local/nagios/etc/conf.d/hostgroups.d/hostgroups.cfg'...
Processing object config directory '/usr/local/nagios/etc/conf.d/commands.d'...
Processing object config file '/usr/local/nagios/etc/conf.d/commands.d/commands.cfg'...
Processing object config directory '/usr/local/nagios/etc/conf.d/templates.d'...
Processing object config file '/usr/local/nagios/etc/conf.d/templates.d/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/templates.d/printer.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/templates.d/switch.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/templates.d/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/templates.d/windows.cfg'...
Processing object config directory '/usr/local/nagios/etc/conf.d/objects'...
Processing object config file '/usr/local/nagios/etc/conf.d/objects/previews-indexes-qa.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/objects/restart_cb_sites.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/objects/hudson-slave01.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/objects/ipc-qa.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/objects/russellreynolds.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/objects/lr.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/objects/ts-01.cfg'...
Processing object config file '/usr/local/nagios/etc/conf.d/cgi.cfg'...
Error: Unexpected token or statement in file '/usr/local/nagios/etc/conf.d/cgi.cfg' on line 15.
Error processing object config files!


***> One or more problems was encountered while processing the config files...

 Check your configuration file(s) to ensure that they contain valid
 directives and data defintions.  If you are upgrading from a previous
 version of Nagios, you should be aware that some variables/definitions
 may have been removed or modified in this version.  Make sure to read
 the HTML documentation regarding the config files, as well as the
 'Whats New' section to find out what has changed.

So I check the cgi.cfg file at line 15, which points to my main_config_file=

#################################################################
#
# CGI.CFG - Sample CGI Configuration File for Nagios 3.4.4
#
# Last Modified: 06-17-2009
#
#################################################################


# 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 //line 15 here


# PHYSICAL HTML PATH
# This is the path where the HTML files for Nagios reside.  This
# value is used to locate the logo images needed by the statusmap
# and statuswrl CGIs.

physical_html_path=/usr/local/nagios/share

The nagios.cfg is purposely outside of the conf.d/ directory. The path listed is correctly as well:

[root@ip-172-31-46-232 conf.d]# locate nagios.cfg
/usr/local/nagios/etc/nagios.cfg
9
  • Add the contents of your nagios.cfg ?
    – dmourati
    Oct 13, 2014 at 16:24
  • Try commenting out statement by statement until you isolate the problem. Also, why are you using the same main_config_file for the CGIs as for nagios instead of a different file?
    – mdpc
    Oct 13, 2014 at 16:25
  • @mdpc Consistency, I suppose. That's how the original file was set up before I took over the project. I don't want to change it and break the configs (at least no more than it is now). Feel free to correct me if I'm wrong, but I also believe that is the defaults when installing/configuring nagios.
    – bbraun17
    Oct 13, 2014 at 16:35
  • @dmourati The nagios.cfg file is over 1400 lines. I don't believe I'd have the space to paste it all. Originally, the files had no structure or organization, so each host (~70) was explicitly defined via cfg_file. I commented out each line and added cfg_dir, as stated above.
    – bbraun17
    Oct 13, 2014 at 16:41
  • Any other defined variables with a path, e.g. log_file, resource_file, object_cache_file, etc. all point to the correct path.
    – bbraun17
    Oct 13, 2014 at 16:44

2 Answers 2

1

After talking with @mdpc, I double checked Nagios Documentation. It is not made clear or in your face at all, but it says this:

By default, Nagios expects the CGI configuration file to be named cgi.cfg and located in the config file directory along with the main config file.

I moved the cgi.cfg and nagios.cfg back into the same directory and it went through fine. I tried pre-flight check again and encountered the exact same error but about my resource.cfg file. Moved the config file into the same directory with the cgi and nagios files and it went through fine.

So now my directory contents of /usr/local/nagios/etc/ includes:

  • conf.d/ #contains categorized subdirectories of cfg files
  • cgi.cfg
  • nagios.cfg
  • resource.cfg

What's really frustrating is that nowhere in the Nagios documentation does it explicitly state that the cgi.cfg, nagios.cfg, and resource.cfg file all need to be within the same directory.

Thanks for the suggestions, guys.

1

I experienced the same problem - and it turned out that the problem was not that the files have to be in a specific path, but to the contrary - I was trying to use a resource.cfg file from a path that was also scanned using the cfg_dir definition - which resulted in an error as $USERX$=xxx starts with an invalid token as far as object definitions go in nagios!

On the other hand, when I included resource.cfg from another path, it all worked well!

Hope this helps someone trying to figure this out :-)

You must log in to answer this question.

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