![nagios.cfg 文件文档所需的选项?](https://linux22.com/image/569826/nagios.cfg%20%E6%96%87%E4%BB%B6%E6%96%87%E6%A1%A3%E6%89%80%E9%9C%80%E7%9A%84%E9%80%89%E9%A1%B9%EF%BC%9F.png)
我正在阅读nagios.cfg
文件文档,但找不到其中说明哪些选项是必需的,哪些选项是可选的。所有这些都是可选的吗?如果不是,我在哪里可以找到哪些是可选的?
http://nagios.sourceforge.net/docs/nagioscore/3/en/configmain.html
答案1
备份配置文件:
# cp -a /usr/local/nagios/etc/nagios.cfg /usr/local/nagios/etc/nagios.cfg.bak
注释掉所有选项:
# sed -i 's/^/#/' /usr/local/nagios/etc/nagios.cfg
并验证配置数据:
# nagios -v /usr/local/nagios/etc/nagios.cfg
你会看到类似这样的内容:
Checking services...
Error: There are no services defined!
Checked 0 services.
Checking hosts...
Error: There are no hosts defined!
Checked 0 hosts.
Checking contacts...
Error: There are no contacts defined!
Checked 0 contacts.
...
Total Warnings: 0
Total Errors: 3
因此,您需要包含一些配置文件,其中至少定义了一个主机、一些服务和一个联系人:
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
...
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
重新验证:
Checking services...
Checked 8 services.
Checking hosts...
Checked 1 hosts.
Checking contacts...
Checked 34 contacts.
...
Total Warnings: 0
Total Errors: 0
答案2
通常,当未指定配置选项时,它将被分配一个默认值。是的,您发布的链接没有说明选项是否是可选的。但是,会指定默认值。如果这样的值适合您的需求,则您不需要将其包含在配置中,或者您可以将其注释掉。