配置 新的Nagios

运维 系统运维
安装好了Nagios,为了更好的应用,我们得学会配置Nagios!

配置Nagios需要许多配置如:要配置联系人和联系人组等。

  在缺省情况下,所有的 Nagios 配置文件都位于 /etc/nagios 目录。为了方便起见,可能将与 Apache 相关的配置文件符号链接到 Apache 配置目录。可以将配置分为多个文件,每个文件用于配置中不同的部分。

  首先需要设置的组件是联系人和联系人组。联系人是那些接收主机或服务停止运行的通知的人员。在缺省情况下,Nagios 提供了寻呼机和电子邮件通知方式。通过扩展,允许通过 Jabber 和许多其他方式进行通知,这在某些情况下是非常方便的。

  联系人存储在 contacts.cfg 文件中,并且定义如下:

  清单 1. 配置 1:基本联系人信息

 

  1.   define contact{  
  2.  
  3.   contact_name jdoe  
  4.  
  5.   alias John Due  
  6.  
  7.   service_notification_commands notify-by-email  
  8.  
  9.   host_notification_commands host-notify-by-emailes  
  10.  
  11.   email john.doe@yourcompany.com  
  12.  
  13.   }  
  14.  

 

  将联系人划分成组:在主机或服务状态发生更改时,Nagios 并不指定需要通知的人员,而是通知相关的组。有时甚至可以对某个人员进行多次定义,以指定不同的通知命令或地址,然后向用户所在的联系组添加联系该人员的所有方式(请参见清单 2)。

  清单 2. 配置 2:分组的联系人

 

  1.   define contactgroup{  
  2.  
  3.   contactgroup_name server-admins  
  4.  
  5.   alias Server Administrators  
  6.  
  7.   members jdoe,albundy  
  8.  
  9.   }  
  10.  

 

  下一个步骤是配置需要由 Nagios 进行监视的主机。应该添加所有包含监视或检查是否正处于活动状态的服务的主机。存储主机信息的配置文件是 hosts.cfg。下面是一个主机定义的示例:

#p#

  清单 3. 配置 3:添加新主机

 

  1.   define host{  
  2.  
  3.   host_name ubuntu_1_2  
  4.  
  5.   alias Ubuntu test server  
  6.  
  7.   address 192.168.1.2  
  8.  
  9.   check_command check-host-alive  
  10.  
  11.   max_check_attempts 20  
  12.  
  13.   notifications_enabled 1  
  14.  
  15.   event_handler_enabled 0  
  16.  
  17.   flap_detection_enabled 0  
  18.  
  19.   process_perf_data 1  
  20.  
  21.   retain_status_information 1  
  22.  
  23.   retain_nonstatus_information 1  
  24.  
  25.   notification_interval 60  
  26.  
  27.   notification_period 24x7  
  28.  
  29.   notification_options d,u,r  
  30.  
  31.   }  
  32.  

 

  Nagios 配置的最后一步是为配置的主机定义服务。这个示例使用了一个预定义的“ping”Nagios 插件,它将发送 Internet 控制信息协议(Internet Control Message Protocol,ICMP)回显请求以确定主机是否有响应。

  清单 4. 配置 4:添加新服务

 

  1.   define service{  
  2.  
  3.   use service-template  
  4.  
  5.   host_name ubuntu_1_2  
  6.  
  7.   service_description PING  
  8.  
  9.   check_period 24x7  
  10.  
  11.   contact_groups server-admins  
  12.  
  13.   notification_options c,r  
  14.  
  15.   check_command check_ping!300.0,20%!1000.0,60%  
  16.  
  17.   }  
  18.  

 

  在完成了这个配置工作之后,重新启动您的 Nagios 守护进程,稍等几秒钟让 Nagios 进行初始化,然后,证实 Web 管理接口中 ping 服务的可见性。

通过文章的描述,我们知道了配置Nagios的四大点,希望大家能掌握它们!

【编辑推荐】

 

责任编辑:赵鹏 来源: 网络转载
相关推荐

2011-03-21 09:17:06

Nagios

2011-03-22 10:10:21

Nagios配置

2010-05-31 11:10:37

Nagios pnp

2011-03-28 13:57:57

2011-03-25 17:13:37

Nagios配置文件

2011-03-31 16:05:18

Redhat配置nagios

2011-08-22 12:25:02

nagios

2011-03-22 13:37:29

Nagios安装

2011-11-08 21:58:01

Nagios 配置 流

2011-03-25 10:37:17

2011-03-25 16:49:33

nagios服务

2011-03-23 13:29:46

配置Nagios系统

2010-05-31 10:22:31

Nagios pnp

2011-03-28 15:22:00

nagios

2011-03-23 15:13:08

Nagios配置文件

2011-03-24 13:00:30

2010-05-31 12:22:13

Nagios pnp

2011-03-31 16:05:18

Redhat配置nagios

2011-03-23 14:43:10

Nagiosnagios.cfg

2011-03-24 09:15:54

Nagios飞信
点赞
收藏

51CTO技术栈公众号