nagios.cfg 文件文档所需的选项?

nagios.cfg 文件文档所需的选项?

我正在阅读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

通常,当未指定配置选项时,它将被分配一个默认值。是的,您发布的链接没有说明选项是否是可选的。但是,会指定默认值。如果这样的值适合您的需求,则您不需要将其包含在配置中,或者您可以将其注释掉。

相关内容