【发布时间】:2020-04-13 14:28:07
【问题描述】:
我是 Nagios 新手,在阅读了几篇关于主机、服务、命令定义的文档后,我遇到了一个非常愚蠢的错误,我无法通过。
我遵循了这个教程:Official Nagios Tuto
这是我的 nagios.cfg 代码(只是一个示例,不是所有的 conf):
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/timperiodds.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
现在是我的 hosts.cfg:
define host {
host_name nas_01
alias NAS Eth0
address 192.168.1.x ; I did not put 'x' ;)
}
最后是我的 services.cfg:
define service {
use generic-service ; Inherit default values from a template
host_name nas_01
service_description HTTP
check_command check_http
}
我尝试使用:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 验证 conf 文件
但我收到此错误:
Error: Invalid max_check_attempts value for host 'nas_01'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/hosts.cfg', starting on line 7)
如果我尝试将我的主机定义放在我的 services.cfg 中,我会遇到以下错误:
Warning: Duplicate definition found for host 'nas_01' (config file '/usr/local/nagios/etc/objects/services.cfg', starting on line 7)
Error: Could not add object property in file '/usr/local/nagios/etc/objects/services.cfg' on line 9.
Error: Invalid max_check_attempts value for host 'nas_01'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/hosts.cfg', starting on line 7)
Error processing object config files!
max_check_attempts 似乎有些可疑之处?
有什么想法吗?
【问题讨论】:
-
您的定义似乎是正确的。您确定
hosts.cfg在/usr/local/nagios/etc/objects/目录中吗? -
是的,它是....
-rw-rw-r-- 1 nagios nagios 6.6k Apr 12 17:07 commands.cfg-rw-rw-r-- 1 nagios nagios 1.8k Apr 12 17:07 contacts.cfg-rw-rw-r-- 1 nagios nagios 286 Apr 12 17:07 hosts.cfg-rw-rw-r-- 1 nagios nagios 4.7k Apr 12 17:07 localhost.cfg-rw-rw-r-- 1 nagios nagios 522 Apr 12 17:07 services.cfg-rw-rw-r-- 1 nagios nagios 13k Apr 12 17:07 templates.cfg-rw-rw-r-- 1 nagios nagios 3.5k Apr 12 17:07 timeperiods.cfg -
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg应该显示所有主机的数量。你能验证这个数字是否正确吗? -
我看不到任何带有
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg的主机列表 这是我发出的检查 conf 的命令,它给了我之前显示的错误。我可以给你所有的输出,但我怀疑它会有用。可能是空格/制表符错误吗?我尝试了几个conf但没有成功。 -
尝试将您的主机定义(代码)放入
services.cfg文件中。
标签: monitoring nagios