向主机应用服务 - NAGIOS
Apply a service to a host - NAGIOS
我是 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
}
我尝试使用以下方法验证 conf 文件:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
但是我得到这个错误:
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
不是吗?
有什么想法吗?
好吧,所以没什么...
基本上我忘了把 'use linux-server' 放在我的 hosts.cfg 中所以它失败了,因为它缺少几个强制属性,例如 max_check_attempts
.
hosts.cfg:
define host {
use linux-server
host_name nas_01
alias NAS Eth02
address 192.168.1.16
}
services.cfg:
define service {
use generic-service
host_name nas_01
service_description HTTP Check
check_command check_http
}
非常感谢@Rohlik,他让我走上了正确的道路!
干杯
我是 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
}
我尝试使用以下方法验证 conf 文件:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
但是我得到这个错误:
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
不是吗?
有什么想法吗?
好吧,所以没什么...
基本上我忘了把 'use linux-server' 放在我的 hosts.cfg 中所以它失败了,因为它缺少几个强制属性,例如 max_check_attempts
.
hosts.cfg:
define host {
use linux-server
host_name nas_01
alias NAS Eth02
address 192.168.1.16
}
services.cfg:
define service {
use generic-service
host_name nas_01
service_description HTTP Check
check_command check_http
}
非常感谢@Rohlik,他让我走上了正确的道路!
干杯