We help IT Professionals succeed at work.

What is the error i this Nagios config file?

Medium Priority
330 Views
Last Modified: 2012-05-12
Nagios just installed, works fine.  I added this line to my nagios.cfg;

cfg_file=/etc/nagios/objects/test-devs.cfg

Open in new window


Works fine if the test-devs.cfg is empty,  I tossed this into the config file, what is wrong?

define host{
        use             linux-server            ;
        host_name       172.16.55.71            ;
        alias           Test Server 01          ;
        address         172.16.55.71            ;
        }

define hostgroup{
        hostgroup_name  linux-servers           ;
        alias           Linux Servers           ;
        }

define service{
        use                             172.16.55.71.services   ;
        host_name                       172.16.55.71            ;
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }

Open in new window

I checked the existing config files, there is no linux-hosts actually defined anywhere and Nagios starts up fine, until I just add my own test host.
Comment
Watch Question

Author

Commented:
I get the error


Running configuration check... CONFIG ERROR!  Restart aborted.  Check your Nagios configuration.

Nagios log has not a single error listed.

Sanga CollinsSystems Admin
CERTIFIED EXPERT

Commented:
;

at the end of most of the lines is probably where your issue is coming from

Ps instead of using
cfg_file=/etc/nagios/objects/test-devs.cfg

you can use
cfg_dir=/etc/nagios/hosts


then move the file test-devs.cfg from the objects directory to the hosts directory so that you can keep configuration objects and regular host / service defenition files seperated.

Author

Commented:
So, the items in the config file look correct?

Author

Commented:
Here is my /etc/nagios/nagios.cfg

# OBJECT CONFIGURATION FILE(S)
# These are the object configuration files in which you define hosts,
# host groups, contacts, contact groups, services, etc.
# You can split your object definitions across several config files
# if you wish (as shown below), or keep them all in a single config file.

# You can specify individual object config files as shown below:
cfg_file=/etc/nagios/objects/commands.cfg
cfg_file=/etc/nagios/objects/contacts.cfg
cfg_file=/etc/nagios/objects/timeperiods.cfg
cfg_file=/etc/nagios/objects/templates.cfg

# Definitions for monitoring the local (Linux) host
cfg_file=/etc/nagios/objects/localhost.cfg

# Definitions for monitoring a Windows machine
#cfg_file=/etc/nagios/objects/windows.cfg

# Definitions for monitoring a router/switch
#cfg_file=/etc/nagios/objects/switch.cfg

# Definitions for monitoring a network printer
#cfg_file=/etc/nagios/objects/printer.cfg

#cfg_file=/etc/nagios/objects/ups.cfg
cfg_file=/etc/nagios/objects/test-devs.cfg

Open in new window


So, I followed what I saw in localhost.cfg

###############################################################################
###############################################################################
#
# HOST DEFINITION
#
###############################################################################
###############################################################################

# 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               localhost
        alias                   localhost
        address                 127.0.0.1
        }



###############################################################################
###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################
###############################################################################

# Define an optional hostgroup for Linux machines

define hostgroup{
        hostgroup_name  linux-servers ; The name of the hostgroup
        alias           Linux Servers ; Long name of the group
        members         localhost     ; Comma separated list of hosts that belong to this group
        }

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


# Define a service to "ping" the local machine

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

Open in new window


Why would mine not work and localhost work?  It would be helpful if Nagios actually entered an error into its logfile....
Sanga CollinsSystems Admin
CERTIFIED EXPERT

Commented:
What error do you get when you run the nagios configuration validation as shown below?

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Systems Admin
CERTIFIED EXPERT
Commented:
for your setup it would be

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

Author

Commented:
Not quite what I needed, but close enough.  ty ;)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.