lq2003 发表于 2009-10-23 13:02

nagios!!!!not defined anywhere!

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

Nagios Core 3.2.0
Copyright (c) 2009 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2009
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
Processing object config file '/usr/local/nagios/etc/dd/contactgroups.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/hostgroups.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/services.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/timeperiods.cfg'...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
Error: Service check command 'check-host-alive' specified in service 'check-host-alive' for host 'nagios-server' not defined anywhere!
Error: Service check command 'check-host-alive' specified in service 'check-host-alive' for host 'rhel5-77' not defined anywhere!
Error: Service check command 'check-host-alive' specified in service 'check-host-alive' for host 'rhel5-99' not defined anywhere!
      Checked 3 services.
Checking hosts...
Error: Host check command 'check-host-alive' specified for host 'nagios-server' is not defined anywhere!
Error: Host check command 'check-host-alive' specified for host 'rhel5-77' is not defined anywhere!
Error: Host check command 'check-host-alive' specified for host 'rhel5-99' is not defined anywhere!
      Checked 3 hosts.
Checking host groups...
      Checked 1 host groups.
Checking service groups...
      Checked 0 service groups.
Checking contacts...
Error: Service notification command 'service-notify-by-email' specified for contact 'nagiosadmin' is not defined anywhere!
Error: Host notification command 'host-notify-by-email' specified for contact 'nagiosadmin' is not defined anywhere!
      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 0 commands.
Checking time periods...
      Checked 1 time periods.
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:   8

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

# cat commands.cfg
define command{
      command_name    check_nrpe
      command_line    $USE 1$/check_nrpe -H $HOSTADD ESS$ -c $A G1$
      }

#host-notify-by-sms
define command {
       command_name      host-notify-by-sms
       command_line      /usr/local/bin/sms_send "Host $HOSTSTATE$ alert for $HOSTNAME$! on '$DATETIME$' " $CONTACTPAGER$
       }


define command{
      command_name check-host-alive
      command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
      }

define command{
      command_name host-notify-by-email
      command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState:$
HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Al
ert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
      }

哪位碰到过这个问题,请指明改正错误配置,谢谢!!

mars531706 发表于 2009-10-23 15:13

Checking services...
Error: Service check command 'check-host-alive' specified in service 'check-host-alive' for host 'nagios-server' not defined anywhere!

check-host-alive服务没有定义
Error: Service check command 'check-host-alive' specified in service 'check-host-alive' for host 'rhel5-77' not defined anywhere!
Error: Service check command 'check-host-alive' specified in service 'check-host-alive' for host 'rhel5-99' not defined anywhere!
同上


Host check command 'check-host-alive' specified for host 'nagios-server' is not defined anywhere!
Error: Host check command 'check-host-alive' specified for host 'rhel5-77' is not defined anywhere!
Error: Host check command 'check-host-alive' specified for host 'rhel5-99' is not defined anywhere!
三台主机都没有定义

nagios里面主要是将定义的配置文件分类列出,nagios作为主要配置文件。
然后分别定义template.cfg、timeperiod.cfg、contact.cfg分别配置,每台host.cfg单独配置,然后用cfg_file='hosts.cfg'导入到nagios主配置文件里面去。

lq2003_cu 发表于 2009-10-23 20:21

# cat contactgroups.cfg
define contactgroup {
      contactgroup_name lq2003
      alias system administrator group
      members nagiosadmin
}

lq2003_cu 发表于 2009-10-23 20:21

# cat contacts.cfg
define contact {
      contact_name nagiosadmin
      alias system administrator
      service_notification_period 24x7
      host_notification_period 24x7
      service_notification_options w,u,c,r
      host_notification_options d,u,r
      service_notification_commands service-notify-by-email
      host_notification_commands host-notify-by-email
      email liqiang@channelsoft.com
             }

lq2003_cu 发表于 2009-10-23 20:22

# cat hostgroups.cfg
define hostgroup {
         hostgroup_name lq2003
         alias          test
         members rhel5-77,rhel5-99,nagios-server
         }


# cat hosts.cfg
define host {
       host_name nagios-server
       alias   nagios-server
       address   192.168.1.45
       contact_groups lq2003
       check_command check-host-alive
       max_check_attempts 5
       notification_interval 10
       notification_period 24x7
       notification_options d,u,r
       }

define host {
       host_name rhel5-99
       alias   rhel5-99
       address 192.168.1.99
       contact_groups lq2003
       check_command check-host-alive
       max_check_attempts 5
       notification_interval 10
       notification_period 24x7
       notification_options d,u,r
       }
define host {
       host_name rhel5-77
       alias   rhel5-77
       address 192.168.1.77
       contact_groups lq2003
       check_command check-host-alive
       max_check_attempts 5
       notification_interval 10
       notification_period 24x7
       notification_options d,u,r
       }

lq2003_cu 发表于 2009-10-23 20:23

# cat services.cfg
define service {
      host_name nagios-server
      service_description check-host-alive
      check_period 24x7
      max_check_attempts 4
      normal_check_interval 3
      retry_check_interval 2
      contact_groups lq2003
      notification_interval 10
      notification_period 24x7
      notification_options w,u,c,r
      check_command check-host-alive
      }
define service {
      host_name rhel5-77
      service_description check-host-alive
      check_period 24x7
      max_check_attempts 4
      normal_check_interval 3
      retry_check_interval 2
      contact_groups lq2003
      notification_interval 10
      notification_period 24x7
      notification_options w,u,c,r
      check_command check-host-alive
      }
define service {
      host_name rhel5-99
      service_description check-host-alive
      check_period 24x7
      max_check_attempts 4
      normal_check_interval 3
      retry_check_interval 2
      contact_groups lq2003
      notification_interval 10
      notification_period 24x7
      notification_options w,u,c,r
      check_command check-host-alive
      }

lq2003_cu 发表于 2009-10-23 20:25

# cattimeperiods.cfg
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
      }

lq2003_cu 发表于 2009-10-23 20:27

的确不好意思啊!

这个问题困扰了我好久,真的查不出来是那里的问题!!谢谢各位

lq2003_cu 发表于 2009-10-23 20:28

# cat hosts.cfg
                                                                                                      
define host{

         host_name                                    nagios-server

         alias                                        nagios-server

         address                                    192.168.1.45

      #   parents                                    server-backbone
         check_command                           check-host-alive

          check_interval                            5

          retry_interval                            1

          max_check_attempts                        5

          check_period                              24x7

          process_perf_data                         0

          retain_nonstatus_information            0

          contact_groups                            lq2003

          notification_interval                     30

          notification_period                     24x7

          notification_options                      d,u,r

          }
define host{

         host_name                                    rhel5-99

         alias                                        rhel5-99

         address                                    192.168.1.99

      #   parents                                    server-backbone
         check_command                           check-host-alive

          check_interval                            5

          retry_interval                            1

          max_check_attempts                        5

          check_period                              24x7

          process_perf_data                         0

          retain_nonstatus_information            0

          contact_groups                            lq2003

          notification_interval                     30

          notification_period                     24x7

          notification_options                      d,u,r

          }
define host{

         host_name                                    rhel5-77

         alias                                        rhel5-77

         address                                    192.168.1.77

      #   parents                                    server-backbone
         check_command                           check-host-alive

          check_interval                            5

          retry_interval                            1

          max_check_attempts                        5

          check_period                              24x7

          process_perf_data                         0

          retain_nonstatus_information            0

          contact_groups                            lq2003

          notification_interval                     30

          notification_period                     24x7

          notification_options                      d,u,r

          }

mars531706 发表于 2009-10-23 23:02


Processing object config file '/usr/local/nagios/etc/dd/contactgroups.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/hostgroups.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/services.cfg'...
Processing object config file '/usr/local/nagios/etc/dd/timeperiods.cfg'...
   Read object config files okay...


你的command.cfg文件是定义了check-host-alive命令,但是你的command.cfg文件有包含进nagios.cfg主配置文件么?

nagios里面最基本的几个对象:command、template、service、contact、timeperiod最好都是分开写配置文件,然后cfg_file="*.cfg"的方式导入到主配置文件中去
页: [1] 2
查看完整版本: nagios!!!!not defined anywhere!