Avatar of RAH104
RAH104

asked on 

Nagios Configuration

Hello,

I'm trying to configure Nagios however am having endless number of errors and this is taking a very long time.  Could someone please look over this configuration and perhaps test to ensure it is working because I can't really test it locally.  I have attached localhost.conf.  It's important that this is working so I can send to my client and no more back and forth with errors.

Thanks.
###############################################################################
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
#
# Last Modified: 11-27-2006
#
# NOTE: This config file is intended to servce as an *extremely* simple 
#       example of how you can create your object configuration file(s).
#
###############################################################################
 
 
 
###############################################################################
###############################################################################
#
# TIME PERIODS
#
###############################################################################
###############################################################################
 
# This defines a timeperiod where all times are valid for checks, 
# notifications, etc.  The classic "24x7" support nightmare. :-)
 
define timeperiod{
        timeperiod_name 24x7
        alias           24 Hours A Day, 7 Days A Week
        sunday          00:00-24:00
        monday          00:00-24:00
        tuesday         00:00-24:00
        wednesday       00:00-24:00
        thursday        00:00-24:00
        friday          00:00-24:00
        saturday        00:00-24:00
        }
 
 
# 'workhours' timeperiod definition
define timeperiod{
	timeperiod_name	workhours
	alias		"Normal" Working Hours
	monday		09:00-17:00
	tuesday		09:00-17:00
	wednesday	09:00-17:00
	thursday	09:00-17:00
	friday		09:00-17:00
	}
 
 
# 'nonworkhours' timeperiod definition
define timeperiod{
	timeperiod_name	nonworkhours
	alias		Non-Work Hours
	sunday		00:00-24:00
	monday		00:00-09:00,17:00-24:00
	tuesday		00:00-09:00,17:00-24:00
	wednesday	00:00-09:00,17:00-24:00
	thursday	00:00-09:00,17:00-24:00
	friday		00:00-09:00,17:00-24:00
	saturday	00:00-24:00
	}
 
 
# 'none' timeperiod definition
define timeperiod{
	timeperiod_name	none
	alias		No Time Is A Good Time
	}
 
 
 
###############################################################################
###############################################################################
#
# COMMANDS
#
###############################################################################
###############################################################################
 
# NOTE: Sample command definitions can now be found in the sample commands.cfg 
#       file
 
 
 
 
###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################
 
# In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host.
 
define contact{
        contact_name                    nagios-admin
        alias                           Nagios Admin
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-by-email
        host_notification_commands      host-notify-by-email
        email                           wyatt@wyattnetworks.com
        }
 
 
 
###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################
 
# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.
 
define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagios-admin
        }
 
 
 
###############################################################################
###############################################################################
#
# HOSTS
#
###############################################################################
###############################################################################
 
# Generic host definition template - This is NOT a real host, just a template!
 
define host{
        name                            12monkeys.wyattnetworks.com    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
	        max_check_attempts              3
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
 
define host{
        name                            ns.lowcostdomains.com    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
	        max_check_attempts              3
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
 
define host{
        name                            ns2.lowcostdomains.com    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
	        max_check_attempts              3
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
 
define host{
        name                            ml2.myemail.com    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
	        max_check_attempts              3
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
 
define host{
        name                            ml3.myemail.com    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
	        max_check_attempts              3
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
 
define host{
        name                            ml4.myemail.com    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
	        max_check_attempts              3
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
 
define host{
        name                            mailserver.lowcostdomains.com    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
	        max_check_attempts              3
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
 
define host{
        name                            neo.lowcostdomains.com    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
	        max_check_attempts              3
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
 
define host{
        name                            5thelement.lowcostdomains.com    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
	notification_period		24x7		; Send host notifications at any time
	        max_check_attempts              3
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
 
 
 
 
# Since this is a simple configuration file, we only monitor one host - the
# local host (this machine).
 
define host{
        use                     12monkeys.wyattnetworks.com            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               12monkeys.wyattnetworks.com
        alias                   12monkeys.wyattnetworks.com
        address                 69.4.242.110
        }
 
define host{
        use                     ns.lowcostdomains.com            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ns.lowcostdomains.com
        alias                   ns.lowcostdomains.com
        address                 69.4.242.108
        }
 
define host{
        use                     ns2.lowcostdomains.com            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ns2.lowcostdomains.com
        alias                   ns2.lowcostdomains.com
        address                 69.4.242.100
        }
 
define host{
        use                     ml2.myemail.com            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ml2.myemail.com 
        alias                   ml2.myemail.com
        address                 69.4.242.102
        }
 
define host{
        use                     ml3.myemail.com            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ml3.myemail.com
        alias                   ml3.myemail.com
        address                 69.4.242.103
        }
 
define host{
        use                     ml4.myemail.com            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ml4.myemail.com
        alias                   ml4.myemail.com
        address                 69.4.242.104
        }
 
define host{
        use                     mailserver.lowcostdomains.com            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               mailserver.lowcostdomains.com
        alias                   mailserver.lowcostdomains.com
        address                 69.4.242.105
        }
 
define host{
        use                     neo.lowcostdomains.com            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               neo.lowcostdomains.com
        alias                   neo.lowcostdomains.com
        address                 69.4.242.106
        }
 
define host{
        use                     5thelement.lowcostdomains.com            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               5thelement.lowcostdomains.com
        alias                   5thelement.lowcostdomains.com
        address                 69.4.242.108
        }
 
 
 
###############################################################################
###############################################################################
#
# HOST GROUPS
#
###############################################################################
###############################################################################
 
# We only have one host in our simple config file, so there is no need to
# create more than one hostgroup.
 
define hostgroup{
        hostgroup_name  all
        alias           all
        members         12monkeys.wyattnetworks.com,ns.lowcostdomains.com,ns2.lowcostdomains.com,ml2.myemail.com,ml3.myemail.com,ml4.myemail.com,mailserver.lowcostdomains.com,neo.lowcostdomains.com,5thelement.lowcostdomains.com 
        }
 
 
 
###############################################################################
###############################################################################
#
# SERVICES
#
###############################################################################
###############################################################################
 
# Generic service definition template - This is NOT a real service, just a template!
 
 
define service{
     name      all ; The 'name' of this service template, referenced in other service definitions
     active_checks_enabled      1 ; Active service checks are enabled
     passive_checks_enabled 1 ; Passive service checks are enabled/accepted
     parallelize_check      1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
     obsess_over_service      1 ; We should obsess over this service (if necessary)
     check_freshness      0 ; Default is to NOT check service 'freshness'
     notifications_enabled      1 ; Service notifications are enabled
     event_handler_enabled      1 ; Service event handler is enabled
     flap_detection_enabled      1 ; Flap detection is enabled
     process_perf_data      1 ; Process performance data
     retain_status_information      1 ; Retain status information across program restarts
     retain_nonstatus_information      1 ; Retain non-status information across program restarts
     max_check_attempts              3
 
     register      1 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
 
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             SSH
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_ssh
        }
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             DNS
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_dns
        }
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             SMTP
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_smtp
        }
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             POP3
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_pop
        }
 
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             HTTP
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_http
        }
 
 
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             FTP
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_ftp
        }

Open in new window

Microsoft Server OSLinuxWeb Servers

Avatar of undefined
Last Comment
Nikita79
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Please post some of the errors you are getting. Then some expert might be better able to help you
Avatar of RAH104
RAH104

ASKER

Well the last error was this:

Error: Service description, host name, or check command is NULL
Error: Could not register service (config file '/usr/local/etc/nagios/localhost.cfg', starting on line 282)

It's just everytime I fix an error there's another one so the whole thing really needs looked over.
Avatar of Nikita79
Nikita79
Flag of France image

First all your templates are the same, just use one template, I called it host_template. I added the following lines to the template :
  check_period                 24x7
  contact_groups               admins
  notification_options         d,u,r
  max_check_attempts           3

These parameters are required in a host definition as explained in this doc :
[http://nagios.sourceforge.net/docs/2_0/xodtemplate.html#host]
You should tune values.

Then update the use parameter in your host definitions like this :
  use        host_template



define host{
  name                         host_template
  notifications_enabled        1
  event_handler_enabled        1
  flap_detection_enabled       1
  failure_prediction_enabled   1
  process_perf_data            1
  retain_status_information    1
  retain_nonstatus_information 1
  notification_period          24x7
  notification_interval        30
  notification_options         d,u,r
  max_check_attempts           3
  check_period                 24x7
  contact_groups               admins
  register                     0
}
 

Open in new window

Avatar of RAH104
RAH104

ASKER

Sorry, I'm not sure how to do that - please advise.  Thanks.
Avatar of Nikita79
Nikita79
Flag of France image

I have updated the hosts section by removing all templates and replace them by only one template.
This new template includes the required parameters that was missing in your file.

Then I updated each host definitions to use this template.

Try this file and let me know if there is more errors, I do not have lot of time right now to verify the all file but maybe I could in few hours.
###############################################################################
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
#
# Last Modified: 11-27-2006
#
# NOTE: This config file is intended to servce as an *extremely* simple 
#       example of how you can create your object configuration file(s).
#
###############################################################################
 
 
 
###############################################################################
###############################################################################
#
# TIME PERIODS
#
###############################################################################
###############################################################################
 
# This defines a timeperiod where all times are valid for checks, 
# notifications, etc.  The classic "24x7" support nightmare. :-)
 
define timeperiod{
        timeperiod_name 24x7
        alias           24 Hours A Day, 7 Days A Week
        sunday          00:00-24:00
        monday          00:00-24:00
        tuesday         00:00-24:00
        wednesday       00:00-24:00
        thursday        00:00-24:00
        friday          00:00-24:00
        saturday        00:00-24:00
        }
 
 
# 'workhours' timeperiod definition
define timeperiod{
	timeperiod_name	workhours
	alias		"Normal" Working Hours
	monday		09:00-17:00
	tuesday		09:00-17:00
	wednesday	09:00-17:00
	thursday	09:00-17:00
	friday		09:00-17:00
	}
 
 
# 'nonworkhours' timeperiod definition
define timeperiod{
	timeperiod_name	nonworkhours
	alias		Non-Work Hours
	sunday		00:00-24:00
	monday		00:00-09:00,17:00-24:00
	tuesday		00:00-09:00,17:00-24:00
	wednesday	00:00-09:00,17:00-24:00
	thursday	00:00-09:00,17:00-24:00
	friday		00:00-09:00,17:00-24:00
	saturday	00:00-24:00
	}
 
 
# 'none' timeperiod definition
define timeperiod{
	timeperiod_name	none
	alias		No Time Is A Good Time
	}
 
 
 
###############################################################################
###############################################################################
#
# COMMANDS
#
###############################################################################
###############################################################################
 
# NOTE: Sample command definitions can now be found in the sample commands.cfg 
#       file
 
 
 
 
###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################
 
# In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host.
 
define contact{
        contact_name                    nagios-admin
        alias                           Nagios Admin
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-by-email
        host_notification_commands      host-notify-by-email
        email                           wyatt@wyattnetworks.com
        }
 
 
 
###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################
 
# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.
 
define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagios-admin
        }
 
 
 
###############################################################################
###############################################################################
#
# HOSTS
#
###############################################################################
###############################################################################
 
# Generic host definition template - This is NOT a real host, just a template!
 
define host{
  name                         host_template
  notifications_enabled        1
  event_handler_enabled        1
  flap_detection_enabled       1
  failure_prediction_enabled   1
  process_perf_data            1
  retain_status_information    1
  retain_nonstatus_information 1
  notification_period          24x7
  notification_interval        30
  notification_options         d,u,r
  max_check_attempts           3
  check_period                 24x7
  contact_groups               admins
  register                     0
}
 
 
# Since this is a simple configuration file, we only monitor one host - the
# local host (this machine).
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               12monkeys.wyattnetworks.com
        alias                   12monkeys.wyattnetworks.com
        address                 69.4.242.110
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ns.lowcostdomains.com
        alias                   ns.lowcostdomains.com
        address                 69.4.242.108
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ns2.lowcostdomains.com
        alias                   ns2.lowcostdomains.com
        address                 69.4.242.100
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ml2.myemail.com 
        alias                   ml2.myemail.com
        address                 69.4.242.102
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ml3.myemail.com
        alias                   ml3.myemail.com
        address                 69.4.242.103
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ml4.myemail.com
        alias                   ml4.myemail.com
        address                 69.4.242.104
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               mailserver.lowcostdomains.com
        alias                   mailserver.lowcostdomains.com
        address                 69.4.242.105
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               neo.lowcostdomains.com
        alias                   neo.lowcostdomains.com
        address                 69.4.242.106
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               5thelement.lowcostdomains.com
        alias                   5thelement.lowcostdomains.com
        address                 69.4.242.108
        }
 
 
 
###############################################################################
###############################################################################
#
# HOST GROUPS
#
###############################################################################
###############################################################################
 
# We only have one host in our simple config file, so there is no need to
# create more than one hostgroup.
 
define hostgroup{
        hostgroup_name  all
        alias           all
        members         12monkeys.wyattnetworks.com,ns.lowcostdomains.com,ns2.lowcostdomains.com,ml2.myemail.com,ml3.myemail.com,ml4.myemail.com,mailserver.lowcostdomains.com,neo.lowcostdomains.com,5thelement.lowcostdomains.com 
        }
 
 
 
###############################################################################
###############################################################################
#
# SERVICES
#
###############################################################################
###############################################################################
 
# Generic service definition template - This is NOT a real service, just a template!
 
 
define service{
     name      all ; The 'name' of this service template, referenced in other service definitions
     active_checks_enabled      1 ; Active service checks are enabled
     passive_checks_enabled 1 ; Passive service checks are enabled/accepted
     parallelize_check      1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
     obsess_over_service      1 ; We should obsess over this service (if necessary)
     check_freshness      0 ; Default is to NOT check service 'freshness'
     notifications_enabled      1 ; Service notifications are enabled
     event_handler_enabled      1 ; Service event handler is enabled
     flap_detection_enabled      1 ; Flap detection is enabled
     process_perf_data      1 ; Process performance data
     retain_status_information      1 ; Retain status information across program restarts
     retain_nonstatus_information      1 ; Retain non-status information across program restarts
     max_check_attempts              3
 
     register      1 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
 
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             SSH
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_ssh
        }
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             DNS
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_dns
        }
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             SMTP
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_smtp
        }
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             POP3
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_pop
        }
 
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             HTTP
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_http
        }
 
 
 
define service{
        use                             all         ; Name of service template
        
        hostgroup_name                  all
        service_description             FTP
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_ftp
        }

Open in new window

Avatar of RAH104
RAH104

ASKER

Thank you, here's the latest error:

Performing sanity check of nagios configuration: FAILED

Nagios 2.12
Copyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org)
Last Modified: 05-19-2008
License: GPL

Reading configuration data...

Error: Service description, host name, or check command is NULL
Error: Could not register service (config file '/usr/local/etc/nagios/localhost.cfg', starting on line 275)


***> 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.

If you do have time later to read over it please do, that would be greatly appreciated - thanks.
Avatar of Nikita79
Nikita79
Flag of France image

set register value to 0 at line 290 in my post :
register      0
Avatar of RAH104
RAH104

ASKER

I'll wait for you to look over the whole code first - I don't want my client to recieve another buggy version of this configuration file.  Thanks.
Avatar of Nikita79
Nikita79
Flag of France image

You may also check the configuration using -v switch to nagios command like this :
/usr/local/nagios/bin/nagios -v

as describe in this documentation : http://nagios.sourceforge.net/docs/2_0/verifyconfig.html

Replace  by the path to your main configuration file.

Like this that does not impact your running Nagios process, this command just check the configuration.

I don't have environment  to check this config, but if you replace 1 by 0 at line 290 as I said before, it should be ok. All required parameter seams to be there in services part.
Avatar of RAH104
RAH104

ASKER

Performing sanity check of nagios configuration: FAILED

Nagios 2.12
Copyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org)
Last Modified: 05-19-2008
License: GPL

Reading configuration data...

Running pre-flight check on configuration data...

Checking services...
Error: Service check command 'check_ssh' specified in service 'SSH' for host '12monkeys.wyattnetworks.com' not defined anywhere!
Error: Service check command 'check_ssh' specified in service 'SSH' for host '5thelement.lowcostdomains.com' not defined anywhere!
Error: Service check command 'check_ssh' specified in service 'SSH' for host 'mailserver.lowcostdomains.com' not defined anywhere!
Error: Service check command 'check_ssh' specified in service 'SSH' for host 'ml2.myemail.com' not defined anywhere!
Error: Service check command 'check_ssh' specified in service 'SSH' for host 'ml3.myemail.com' not defined anywhere!
Error: Service check command 'check_ssh' specified in service 'SSH' for host 'ml4.myemail.com' not defined anywhere!
Error: Service check command 'check_ssh' specified in service 'SSH' for host 'neo.lowcostdomains.com' not defined anywhere!
Error: Service check command 'check_ssh' specified in service 'SSH' for host 'ns.lowcostdomains.com' not defined anywhere!
Error: Service check command 'check_ssh' specified in service 'SSH' for host 'ns2.lowcostdomains.com' not defined anywhere!
       Checked 54 services.
Checking hosts...
       Checked 9 hosts.
Checking host groups...
       Checked 1 host groups.
Checking service groups...
       Checked 0 service groups.
Checking contacts...
       Checked 1 contacts.
Checking contact groups...
       Checked 1 contact groups.
Checking service escalations...
       Checked 0 service escalations.
Checking service dependencies...
       Checked 0 service dependencies.
Checking host escalations...
       Checked 0 host escalations.
Checking host dependencies...
       Checked 0 host dependencies.
Checking commands...
       Checked 22 commands.
Checking time periods...
       Checked 4 time periods.
Checking extended host info definitions...
       Checked 0 extended host info definitions.
Checking extended service info definitions...
       Checked 0 extended service info definitions.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   9

***> One or more problems was encountered while running the pre-flight check...


    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.
Avatar of Nikita79
Nikita79
Flag of France image

This is because you ran the sanity check with your localhost.conf as parameter instead of the main conf file. The default main conf file is /usr/local/nagios/etc/nagios.cfg or /etc/nagios/nagios.conf depending on the way you installed it.
Avatar of RAH104
RAH104

ASKER

Hello,

My client simply put localhost.cfg in the correct location and ran the following command:
/usr/local/etc/rc.d/nagios.sh start
Avatar of Nikita79
Nikita79
Flag of France image

I have updated services part of the file by moving all common values in the template. That means all changes made in the generic_service template will be applied to all services.

I tested it :
debian:/etc/nagios2# nagios2 -v /etc/nagios2/nagios.cfg

Nagios 2.6
Copyright (c) 1999-2006 Ethan Galstad (http://www.nagios.org)
Last Modified: 11-27-2006
License: GPL

Reading configuration data...

Running pre-flight check on configuration data...

Checking services...
        Checked 54 services.
Checking hosts...
        Checked 9 hosts.
Checking host groups...
        Checked 1 host groups.
Checking service groups...
        Checked 0 service groups.
Checking contacts...
        Checked 1 contacts.
Checking contact groups...
        Checked 1 contact groups.
Checking service escalations...
        Checked 0 service escalations.
Checking service dependencies...
        Checked 0 service dependencies.
Checking host escalations...
        Checked 0 host escalations.
Checking host dependencies...
        Checked 0 host dependencies.
Checking commands...
        Checked 116 commands.
Checking time periods...
        Checked 4 time periods.
Checking extended host info definitions...
        Checked 0 extended host info definitions.
Checking extended service info definitions...
        Checked 0 extended service info definitions.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

###############################################################################
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
#
# Last Modified: 11-27-2006
#
# NOTE: This config file is intended to servce as an *extremely* simple 
#       example of how you can create your object configuration file(s).
#
###############################################################################
 
 
 
###############################################################################
###############################################################################
#
# TIME PERIODS
#
###############################################################################
###############################################################################
 
# This defines a timeperiod where all times are valid for checks, 
# notifications, etc.  The classic "24x7" support nightmare. :-)
 
define timeperiod{
        timeperiod_name 24x7
        alias           24 Hours A Day, 7 Days A Week
        sunday          00:00-24:00
        monday          00:00-24:00
        tuesday         00:00-24:00
        wednesday       00:00-24:00
        thursday        00:00-24:00
        friday          00:00-24:00
        saturday        00:00-24:00
        }
 
 
# 'workhours' timeperiod definition
define timeperiod{
	timeperiod_name	workhours
	alias		"Normal" Working Hours
	monday		09:00-17:00
	tuesday		09:00-17:00
	wednesday	09:00-17:00
	thursday	09:00-17:00
	friday		09:00-17:00
	}
 
 
# 'nonworkhours' timeperiod definition
define timeperiod{
	timeperiod_name	nonworkhours
	alias		Non-Work Hours
	sunday		00:00-24:00
	monday		00:00-09:00,17:00-24:00
	tuesday		00:00-09:00,17:00-24:00
	wednesday	00:00-09:00,17:00-24:00
	thursday	00:00-09:00,17:00-24:00
	friday		00:00-09:00,17:00-24:00
	saturday	00:00-24:00
	}
 
 
# 'none' timeperiod definition
define timeperiod{
	timeperiod_name	none
	alias		No Time Is A Good Time
	}
 
 
 
###############################################################################
###############################################################################
#
# COMMANDS
#
###############################################################################
###############################################################################
 
# NOTE: Sample command definitions can now be found in the sample commands.cfg 
#       file
 
 
 
 
###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################
 
# In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host.
 
define contact{
        contact_name                    nagios-admin
        alias                           Nagios Admin
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-by-email
        host_notification_commands      host-notify-by-email
        email                           wyatt@wyattnetworks.com
        }
 
 
 
###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################
 
# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.
 
define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagios-admin
        }
 
 
 
###############################################################################
###############################################################################
#
# HOSTS
#
###############################################################################
###############################################################################
 
# Generic host definition template - This is NOT a real host, just a template!
 
define host{
  name                         host_template
  notifications_enabled        1
  event_handler_enabled        1
  flap_detection_enabled       1
  failure_prediction_enabled   1
  process_perf_data            1
  retain_status_information    1
  retain_nonstatus_information 1
  notification_period          24x7
  notification_interval        30
  notification_options         d,u,r
  max_check_attempts           3
  check_period                 24x7
  contact_groups               admins
  register                     0
}
 
 
# Since this is a simple configuration file, we only monitor one host - the
# local host (this machine).
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               12monkeys.wyattnetworks.com
        alias                   12monkeys.wyattnetworks.com
        address                 69.4.242.110
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ns.lowcostdomains.com
        alias                   ns.lowcostdomains.com
        address                 69.4.242.108
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ns2.lowcostdomains.com
        alias                   ns2.lowcostdomains.com
        address                 69.4.242.100
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ml2.myemail.com 
        alias                   ml2.myemail.com
        address                 69.4.242.102
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ml3.myemail.com
        alias                   ml3.myemail.com
        address                 69.4.242.103
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               ml4.myemail.com
        alias                   ml4.myemail.com
        address                 69.4.242.104
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               mailserver.lowcostdomains.com
        alias                   mailserver.lowcostdomains.com
        address                 69.4.242.105
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               neo.lowcostdomains.com
        alias                   neo.lowcostdomains.com
        address                 69.4.242.106
        }
 
define host{
        use                     host_template            ; Name of host template to use
							; This host definition will inherit all variables that are defined
							; in (or inherited by) the freebsd-server host template definition.
        host_name               5thelement.lowcostdomains.com
        alias                   5thelement.lowcostdomains.com
        address                 69.4.242.108
        }
 
 
 
###############################################################################
###############################################################################
#
# HOST GROUPS
#
###############################################################################
###############################################################################
 
# We only have one host in our simple config file, so there is no need to
# create more than one hostgroup.
 
define hostgroup{
        hostgroup_name  all
        alias           all
        members         12monkeys.wyattnetworks.com,ns.lowcostdomains.com,ns2.lowcostdomains.com,ml2.myemail.com,ml3.myemail.com,ml4.myemail.com,mailserver.lowcostdomains.com,neo.lowcostdomains.com,5thelement.lowcostdomains.com 
        }
 
 
 
###############################################################################
###############################################################################
#
# SERVICES
#
###############################################################################
###############################################################################
 
# Generic service definition template - This is NOT a real service, just a template!
 
define service{
     name                               generic_service
     active_checks_enabled              1
     passive_checks_enabled             1
     parallelize_check                  1
     obsess_over_service                1
     check_freshness                    0
     notifications_enabled              1
     event_handler_enabled              1
     flap_detection_enabled             1
     process_perf_data                  1
     retain_status_information          1
     retain_nonstatus_information       1
     notification_interval              30
     is_volatile                        0
     check_period                       24x7
     normal_check_interval              3
     retry_check_interval               1
     max_check_attempts                 3
     notification_period                24x7
     notification_options               w,u,c,r
     contact_groups                     admins
     register                           0
}
  
 
define service{
        use                             generic_service         ; Name of service template
        
        hostgroup_name                  all
        service_description             SSH
        check_command                   check_ssh
        }
 
define service{
        use                             generic_service         ; Name of service template
        
        hostgroup_name                  all
        service_description             DNS
        check_command                   check_dns
        }
 
define service{
        use                             generic_service         ; Name of service template
        
        hostgroup_name                  all
        service_description             SMTP
        check_command                   check_smtp
        }
 
define service{
        use                             generic_service         ; Name of service template
        
        hostgroup_name                  all
        service_description             POP3
        check_command                   check_pop
        }
 
 
define service{
        use                             generic_service         ; Name of service template
        
        hostgroup_name                  all
        service_description             HTTP
        check_command                   check_http
        }
 
 
 
define service{
        use                             generic_service         ; Name of service template
        
        hostgroup_name                  all
        service_description             FTP
        check_command                   check_ftp
        }

Open in new window

Avatar of RAH104
RAH104

ASKER

The same error is given.
ASKER CERTIFIED SOLUTION
Avatar of Nikita79
Nikita79
Flag of France image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Linux
Linux

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

71K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo