Fresh Install Nagios 4 "Error in configuration file"

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by t3dus »

rkennedy wrote:The config you posted looks fine, did you modify it to have the host_name google.com already then?
I want to change it from google.com now but it complains. I guess maybe i need to just delete that file and recreate it?
rkennedy wrote:Do you have DNS configured on your Centos 7 machine?
Yes

Code: Select all

# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.6.48  netmask 255.255.240.0  broadcast 192.168.15.255
        inet6 fe80::215:5dff:fe00:571c  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:00:57:1c  txqueuelen 1000  (Ethernet)
        RX packets 3224  bytes 458491 (447.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 89  bytes 12477 (12.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
rkennedy wrote:What is the result of a ping http://www.google.com from the command line?
Right now it's just configured as automatic but i want to assign it a manual IP at some point but I just haven't done it yet.

It pings google just fine from the command line.

Code: Select all

# ping google.com
PING google.com (167.142.232.59) 56(84) bytes of data.
64 bytes from 167.142.232.59: icmp_seq=1 ttl=58 time=7.49 ms
64 bytes from 167.142.232.59: icmp_seq=2 ttl=58 time=4.88 ms
64 bytes from 167.142.232.59: icmp_seq=3 ttl=58 time=5.13 ms
64 bytes from 167.142.232.59: icmp_seq=4 ttl=58 time=4.90 ms
64 bytes from 167.142.232.59: icmp_seq=5 ttl=58 time=6.15 ms
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by rkennedy »

Try creating a new config, calling this "yahoo.cfg" - with every service definition you have, you also need a host definition. As an example, I just replaced everything from google.com -> yahoo.com. You should now be monitoring both search engines.

Code: Select all

# Define a host for the local machine

define host{
        use                     linux-server            ; Name of host template to use
                                                        ; This host definition will inherit all variables that are defined
                                                        ; in (or inherited by) the linux-server host template definition.
        host_name               yahoo.com
        alias                   yahoo.com
        address                 www.yahoo.com
        }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Define a service to "ping" the local machine

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       yahoo.com
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }

# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       yahoo.com
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }
Former Nagios Employee
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by t3dus »

Done but both google.com and yahoo.com appear to be down even though I can ping both from the command line.
nagios.png
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by t3dus »

t3dus wrote:Done but both google.com and yahoo.com appear to be down even though I can ping both from the command line.
nagios.png
Added one of our company websites though and that works fine. Guess I don't care to monitor google.com and yahoo.com anyways but still weird why i can't.

Where would i find out how to setup e-mail notifications now.
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by t3dus »

Ok so I deleted the following two lines

Code: Select all

cfg_file=/usr/local/nagios/etc/objects/matthome.cfg
cfg_file=/usr/local/nagios/etc/objects/yahoo.cfg
from

Code: Select all

sudo nano /usr/local/nagios/etc/nagios.cfg
but now when I verify i get this error

Code: Select all

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

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Error: Could not find any host matching 'yahoo.com' (config file '/usr/local/nagios/etc/objects/globalid.cfg', starting on line 32)
Error: Failed to expand host list 'yahoo.com' for service 'HTTP' (/usr/local/nagios/etc/objects/globalid.cfg:32)
   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.
How do I get past that? I don't care to monitor yahoo or google so i don't want them in that file as hosts
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by rkennedy »

The error message is pointing to your globalid.cfg file.

Can you post this file? /usr/local/nagios/etc/objects/globalid.cfg
Former Nagios Employee
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by t3dus »

rkennedy wrote:The error message is pointing to your globalid.cfg file.

Can you post this file? /usr/local/nagios/etc/objects/globalid.cfg
yeah it's pointing to that p robably because i removed it from

Code: Select all

sudo nano /usr/local/nagios/etc/nagios.cfg
anyways here it is

Code: Select all

# Define a host for the local machine

define host{
        use                     linux-server            ; Name of host template to use
                                                        ; This host definition will inherit all variables that are defined
                                                        ; in (or inherited by) the linux-server host template definition.
        host_name               GID Web
        alias                   global-id-group.com
        address                 www.global-id-group.com
        }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Define a service to "ping" the local machine

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       yahoo.com
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }

# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       yahoo.com
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by t3dus »

I just noticed it had yahoo.com listed in it in two spots so i updated it with

Code: Select all

  GNU nano 2.3.1                                       File: /usr/local/nagios/etc/objects/globalid.cfg                                                                            Modified

# Define a host for the local machine

define host{
        use                     linux-server            ; Name of host template to use
                                                        ; This host definition will inherit all variables that are defined
                                                        ; in (or inherited by) the linux-server host template definition.
        host_name               GID Web
        alias                   global-id-group.com
        address                 www.global-id-group.com
        }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Define a service to "ping" the local machine

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       GID Web
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }

# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       GID Web
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }
but now i get this for an error

Code: Select all

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

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Error: Could not find any host matching 'google.com' (config file '/usr/local/nagios/etc/objects/homeg3kxyz.cfg', starting on line 32)
Error: Failed to expand host list 'google.com' for service 'HTTP' (/usr/local/nagios/etc/objects/homeg3kxyz.cfg:32)
   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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by rkennedy »

You have a host_name of 'GID Web' and a service using the host_name 'yahoo.com'. This is the issue.

Code: Select all

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       yahoo.com
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }
Former Nagios Employee
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: Fresh Install Nagios 4 "Error in configuration file"

Post by t3dus »

Ok I just fixed both problems. The config files were wrong in two spot on each one.
Locked