Nagios 配置文件解析

运维 系统运维
在为自己的操作系统配置Nagios-监控系统时,我们有必要学习下Nagios的配置文件,让我们来看看他的具体内容!

Nagios配置文件在Nagios安装和配置时显得尤为重要,让我们来具体的看看他的内容!

 

Nagios 

图-Nagios

  主配置文件[--prefix/nagios/etc/nagios.cfg]:

 

  1.   # NAGIOS.CFG - Sample Main Config File for Nagios 3.0.6  
  2.  
  3.   # Read the documentation for more information on this configuration  
  4.  
  5.   # file. I've provided some comments here, but things may not be so  
  6.  
  7.   # clear without further explanation.  
  8.  
  9.   # Last Modified: 10-15-2008  
  10.  

 

  # LOG FILE

 

  1.   # This is the main log file where service and host events are logged  
  2.  
  3.   # for historical purposes. This should be the first option specified  
  4.  
  5.   # in the config file!!!  
  6.  

 

  # 这个变量用于设定Nagios在何处创建其日志文件。

  # 它应该是你主配置文件里面的***个变量,当Nagios找到你配置文件并发现配置里有错误时会向该文件中写入错误信息。

  # 如果你使能了日志回滚,Nagios将在每小时、每天、每周或每月对日志进行回滚。

  log_file=/usr/local/nagios/var/nagios.log

  # OBJECT CONFIGURATION FILE(S)

  # 对象的配置文件

 

  1.   # These are the object configuration files in which you define hosts,  
  2.  
  3.   # host groups, contacts, contact groups, services, etc.  
  4.  
  5.   # You can split your object definitions across several config files  
  6.  
  7.   # if you wish (as shown below), or keep them all in a single config file.  
  8.  

 

  # 该变量用于指定一个包含有将用于Nagios监控对象的对象配置文件。

  # 对象配置文件中包括有主机、主机组、联系人、联系人组、服务、命令等等对象的定义。

  # 配置信息可以切分为多个文件并且用cfg_file=语句来指向每个待处理的配置文件

  # You can specify individual object config files as shown below:

  # 您可以指定单个对象的配置文件, 如下所示:

 

  1.   cfg_file=/usr/local/nagios/etc/objects/commands.cfg  
  2.  
  3.   cfg_file=/usr/local/nagios/etc/objects/contacts.cfg  
  4.  
  5.   cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg  
  6.  
  7.   cfg_file=/usr/local/nagios/etc/objects/templates.cfg  
  8.  
  9.   # Definitions for monitoring the local (Linux) host  
  10.  

 

  # 定义监测本地( Linux )主机

 

  1.   cfg_file=/usr/local/nagios/etc/objects/localhost.cfg  
  2.  
  3.   # Definitions for monitoring a Windows machine  
  4.  

 

  # 定义监测( windows )主机

 

  1.   #cfg_file=/usr/local/nagios/etc/objects/windows.cfg  
  2.  
  3.   # Definitions for monitoring a router/switch 
  4.  

 

  # 定义监测路由器或交换机

 

  1.   #cfg_file=/usr/local/nagios/etc/objects/switch.cfg  
  2.  
  3.   # Definitions for monitoring a network printer  
  4.  

#p#
 

 

  # 定义监测打印机

 

  1.   #cfg_file=/usr/local/nagios/etc/objects/printer.cfg  
  2.  
  3.   # You can also tell Nagios to process all config files (with a .cfg  
  4.  
  5.   # extension) in a particular directory by using the cfg_dir  
  6.  
  7.   # directive as shown below:  
  8.  

 

  # 您也可以告诉Nagios处理所有配置文件(带有.cfg扩展名)在特定的目录使用cfg_dir指令如下所示:

 

  1.   #cfg_dir=/usr/local/nagios/etc/servers  
  2.  
  3.   #cfg_dir=/usr/local/nagios/etc/printers  
  4.  
  5.   #cfg_dir=/usr/local/nagios/etc/switches  
  6.  
  7.   #cfg_dir=/usr/local/nagios/etc/routers  
  8.  

 

  配置文件里的变量:

  日志文件

  格式: log_file=

  样例: log_file=/usr/local/nagios/var/nagios.log

  说明:

  这个变量用于设定Nagios在何处创建其日志文件。它应该是你主配置文件里面的***个变量,当Nagios找到你配置文件并发现配置里有错误时会向该文件中写入错误信息。如果你使能了日志回滚,Nagios将在每小时、每天、每周或每月对日志进行回滚。

  对象配置文件

  格式: cfg_file=

  样例:

 

  1.   cfg_file=/usr/local/nagios/etc/hosts.cfg  
  2.  
  3.   cfg_file=/usr/local/nagios/etc/services.cfg  
  4.  
  5.   cfg_file=/usr/local/nagios/etc/commands.cfg  
  6.  

 

  说明:

  该变量用于指定一个包含有将用于Nagios监控对象的对象配置文件。对象配置文件中包括有主机、主机组、联系人、联系人组、服务、命令等等对象的定义。配置信息可以切分为多个文件并且用cfg_file=语句来指向每个待处理的配置文件.

  对象配置目录:

  格式: cfg_dir=

  样例:

 

  1.   cfg_dir=/usr/local/nagios/etc/commands  
  2.  
  3.   cfg_dir=/usr/local/nagios/etc/services  
  4.  
  5.   cfg_dir=/usr/local/nagios/etc/hosts  
  6.  

 

  说明:

  该变量用于指定一个目录,目录里包含有将用于Nagios监控对象的对象配置文件。所有的在这个目录下的且以.cfg为扩展名的文件将被作为配置文件来处理。另外,Nagios将会递归该目录下的子目录并处理其子目录下的全部配置文件。你可以把配置放入不同的目录并且用cfg_dir=语句来指向每个待处理的目录。

总结:在我们学习了Nagios 配置文件的具体内容后,别忘了应用到自己的Nagios,使他更好的为你服务!

【编辑推荐】

 

 

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

2011-03-28 15:52:16

Nagios配置文件

2011-04-01 16:30:49

Nagios

2011-03-25 17:13:37

Nagios配置文件

2010-05-31 11:10:37

Nagios pnp

2011-03-23 15:13:08

Nagios配置文件

2011-03-23 13:29:46

配置Nagios系统

2011-03-22 13:37:29

Nagios安装

2010-02-22 10:18:18

WCF配置文件

2021-07-05 12:09:58

Python编程语言

2022-11-10 09:05:18

Lua配置文件

2021-07-13 05:47:40

GroovyJSON软件开发

2009-12-21 11:19:50

WCF配置文件

2010-03-18 18:17:01

Python 配置文件

2011-09-08 16:07:13

Widget配置文件

2010-02-03 09:19:31

Python模块

2021-07-08 21:19:04

BashLinux

2020-10-20 10:12:00

Windows

2011-01-19 14:00:21

2011-01-13 16:27:26

Linux配置文件

2010-12-27 14:59:31

Outlook 配置文
点赞
收藏

51CTO技术栈公众号