youbo1 发表于 2019-1-14 08:43:14

nagios2

  

  ① 监控对象
  ② 配置选项

  ③ 报警选项
  

  =================================
  定义监控对象

  

  nagios.cfg

  # vi nagios.cfg
http://s3.运维网.com/wyfs02/M01/2B/5E/wKiom1OHeiCRgcmmAACLxNNeSiU292.jpg
# mkdir servers && cd servers
# vi hosts.cfg      (修改过nagios的配置文件,生效需要重启nagios)
define host{
    use linux-server
    host_name 0.180
    alias web1
    address 192.168.0.180
    hostgroup 192.168.0

}


define hostgroup{
      hostgroup_namezg_linux-servers
      alias         Linux Web Servers
      members         192.168
      }

# vi services{
    use linux-server
    host_name 0.180
    service_description HTTP
    check_command check_http!80

}



检查配置文件是否有错误;

# bin/nagios -v etc/nagios.cfg


# vi /etc/nrpe.cfg


server_port=5666
#server_address=192.168.1.1
allowed_hosts=127.0.0.1,192.168.0.180,117.34.73.193
nrpe_user=nagios
nrpe_group=nagios


# DEBUGGING OPTION
# This option determines whether or not debugging messages are logged to the
# syslog facility.
# Values: 0=debugging off, 1=debugging on
debug=0



# Command definitions that this daemon will run.

#
# Note: Any plugins that are used in the command lines must reside
# on the machine that this daemon is running on!

#The examples below assume that you have plugins installed in

# a /usr/local/nagios/libexec directory.
command=/usr/local/nagios/libexec/check_users 5 10
command=/usr/local/nagios/libexec/check_load 5 10 15 20 25 30
command=/usr/local/nagios/libexec/check_disk 80 95 /dev/hda1
command=/usr/local/nagios/libexec/check_disk 80 95 /dev/hdb1
command=/usr/local/nagios/libexec/check_procs 5 10 Z
command=/usr/local/nagios/libexec/check_procs 150 200



  

  

=================================
配置文件选项

  

  cgi.cfg

  # vi cgi.cfg
  选项:show_context_help=
  默认:0
  说明:是否启用帮助信息。(默认:禁用显示帮助信息)

  

  选项:use_authentication=

  默认:1
  说明:设定访问CGI程序时,是否启用认证。
  

  选项:use_ssl_authentication=

  默认:0
  说明:设定是否使用x509证书认证。
  

  选项:default_user_name

  默认:guest
  说明:定义一个默认用户,用来访问 CGI ;这是一个替代 web 基本身份认证的方法。

  

  选项:authorized_for_system_commands

  默认:nagiosadmin
  说明:
  

  nagios.cfg

  # vi nagios.cfg
  选项:log_file=

  默认:
  说明:指定日志文件;必须是该配置文件的第一个选项。
  

  

  选项:cfg_file= ( & cfg_dir= )

  默认:
  说明:对象配置文件。
  

  

  选项:object_cache_file=
  默认:
  说明:配置对象缓存文件。在启动或重启时读入。
  

  

  选项:status_update_interval=10

  默认:10秒
  说明:指定 nagios 查询监控对象的间隔,状态文件更新间隔时间。

  

  

  选项:nagios_user=nagios

  默认:
  说明:
  

  选项:nagios_group=nagios

  默认:
  说明:
  

  选项:log_rotation_method=

  默认:d
  说明:设置日志轮换的方法。(不论换;每小时开始轮换;……周六午夜……)
  

  选项:log_archive_path

  默认:
  说明:设置归档日志存储的目录。设定日志轮换的情况下,归档日志将会被存储在该目录。
  

  选项:use_syslog=

  默认:1
  说明:是否将日志信息记录到 syslog 设备。

  

  选项:log_notifications=

  默认:1
  说明:是否记录“报警通知”。
  

  选项:log_service_retries=

  默认:1
  说明:是否将检测服务重试的信息进行记录。
  

  选项:enable_notifications=
  默认:1
  说明:启用报警通知

  

  

  =================================
  报警相关选项
  

  nagios.cfg:enable_notifications
  templates.cfg > service | host:notifications_enabled
  templates.cfg > service | host:notification_options

  templates.cfg > service | host:notification_interval

  templates.cfg > service | host:notification_period

  templates.cfg > contact:almost

  与关系

  

  




页: [1]
查看完整版本: nagios2