Nagios 配置文件解析
Nagios的配置文件在Nagios安裝和配置時顯得尤為重要,讓我們來具體的看看他的內容!
圖-Nagios
主配置文件[--prefix/nagios/etc/nagios.cfg]:
- # NAGIOS.CFG - Sample Main Config File for Nagios 3.0.6
- # Read the documentation for more information on this configuration
- # file. I've provided some comments here, but things may not be so
- # clear without further explanation.
- # Last Modified: 10-15-2008
# LOG FILE
- # This is the main log file where service and host events are logged
- # for historical purposes. This should be the first option specified
- # in the config file!!!
# 這個變量用于設定Nagios在何處創建其日志文件。
# 它應該是你主配置文件里面的***個變量,當Nagios找到你配置文件并發現配置里有錯誤時會向該文件中寫入錯誤信息。
# 如果你使能了日志回滾,Nagios將在每小時、每天、每周或每月對日志進行回滾。
log_file=/usr/local/nagios/var/nagios.log
# OBJECT CONFIGURATION FILE(S)
# 對象的配置文件
- # These are the object configuration files in which you define hosts,
- # host groups, contacts, contact groups, services, etc.
- # You can split your object definitions across several config files
- # if you wish (as shown below), or keep them all in a single config file.
# 該變量用于指定一個包含有將用于Nagios監控對象的對象配置文件。
# 對象配置文件中包括有主機、主機組、聯系人、聯系人組、服務、命令等等對象的定義。
# 配置信息可以切分為多個文件并且用cfg_file=語句來指向每個待處理的配置文件
# You can specify individual object config files as shown below:
# 您可以指定單個對象的配置文件, 如下所示:
- cfg_file=/usr/local/nagios/etc/objects/commands.cfg
- cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
- cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
- cfg_file=/usr/local/nagios/etc/objects/templates.cfg
- # Definitions for monitoring the local (Linux) host
# 定義監測本地( Linux )主機
- cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
- # Definitions for monitoring a Windows machine
# 定義監測( windows )主機
- #cfg_file=/usr/local/nagios/etc/objects/windows.cfg
- # Definitions for monitoring a router/switch
# 定義監測路由器或交換機
- #cfg_file=/usr/local/nagios/etc/objects/switch.cfg
- # Definitions for monitoring a network printer
#p#
# 定義監測打印機
- #cfg_file=/usr/local/nagios/etc/objects/printer.cfg
- # You can also tell Nagios to process all config files (with a .cfg
- # extension) in a particular directory by using the cfg_dir
- # directive as shown below:
# 您也可以告訴Nagios處理所有配置文件(帶有.cfg擴展名)在特定的目錄使用cfg_dir指令如下所示:
- #cfg_dir=/usr/local/nagios/etc/servers
- #cfg_dir=/usr/local/nagios/etc/printers
- #cfg_dir=/usr/local/nagios/etc/switches
- #cfg_dir=/usr/local/nagios/etc/routers
配置文件里的變量:
日志文件
格式: log_file=
樣例: log_file=/usr/local/nagios/var/nagios.log
說明:
這個變量用于設定Nagios在何處創建其日志文件。它應該是你主配置文件里面的***個變量,當Nagios找到你配置文件并發現配置里有錯誤時會向該文件中寫入錯誤信息。如果你使能了日志回滾,Nagios將在每小時、每天、每周或每月對日志進行回滾。
對象配置文件
格式: cfg_file=
樣例:
- cfg_file=/usr/local/nagios/etc/hosts.cfg
- cfg_file=/usr/local/nagios/etc/services.cfg
- cfg_file=/usr/local/nagios/etc/commands.cfg
說明:
該變量用于指定一個包含有將用于Nagios監控對象的對象配置文件。對象配置文件中包括有主機、主機組、聯系人、聯系人組、服務、命令等等對象的定義。配置信息可以切分為多個文件并且用cfg_file=語句來指向每個待處理的配置文件.
對象配置目錄:
格式: cfg_dir=
樣例:
- cfg_dir=/usr/local/nagios/etc/commands
- cfg_dir=/usr/local/nagios/etc/services
- cfg_dir=/usr/local/nagios/etc/hosts
說明:
該變量用于指定一個目錄,目錄里包含有將用于Nagios監控對象的對象配置文件。所有的在這個目錄下的且以.cfg為擴展名的文件將被作為配置文件來處理。另外,Nagios將會遞歸該目錄下的子目錄并處理其子目錄下的全部配置文件。你可以把配置放入不同的目錄并且用cfg_dir=語句來指向每個待處理的目錄。
總結:在我們學習了Nagios 配置文件的具體內容后,別忘了應用到自己的Nagios,使他更好的為你服務!
【編輯推薦】
- Nagios安裝筆記
- Suse 9 安裝Nagios過程
- Nagios擴展的主機和服務監測
- Nagios編譯安裝之配置Apache服務
- Nagios的配置文件
- Nagios插件plugins配置和安裝