Search code examples
chef-infranagioscookbook

Nagios: Error in config file - First line (NULL Value)


I'm running Nagios 3.5.1 and I'm getting an error saying there's an error in my config file.

When I run nagios -v /etc/nagios3/conf.d/hosts.cfg, I get this error

Reading configuration data... Error in configuration file '/etc/nagios3/conf.d/hosts.cfg' - Line 5 (NULL value)

Line 5 is the first like with content. Lines 1-4 are comments. When I remove 1-4, the error moves to the first line still. And commenting out the first host just moves the same error lower.

My hosts.cfg is not complicated

 define host {
   use server
   address 10.203.130.187
   host_name production-mgmt-nagios-server-20140325-10-203-130-187
   hostgroups all,linux,nagios-server
 }

and so on.

Simplifying with one host or even the example host gives the same error.

Creating a new file and typing a basic version gives the same error.

Running out of ideas and anything will be appreciated. Thank you!


Solution

  • You are correct. As per the documentation for Nagios 3.x for configuration verification you are to run the following command:

    /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    

    And assuming you have no errors or warnings that might cause issues restart Nagios. The restart command will depend on your OS Flavour.