Nagios 配置文件解析
创始人
2024-07-24 08:00:44
0

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,使他更好的为你服务!

【编辑推荐】

  • Nagios安装笔记
  • Suse 9 安装Nagios过程
  • Nagios扩展的主机和服务监测
  • Nagios编译安装之配置Apache服务
  • Nagios的配置文件
  • Nagios插件plugins配置和安装

 

 

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...