我刚刚开始从头开始配置 Nagios,对此我还是个新手。
添加后我收到此错误objects/printer.cfg
Error: Could not find any hostgroup matching 'allhosts'
(config file '/etc/nagios3/objects/printer.cfg', starting on line 1)
Error processing object config files!
这就是内容printer.cfg
define host{
use generic-host ; Inherit default values from a template
host_name Printer_klen ; The name we're giving to this printer
alias Printer_klen ; A longer name associated with the printer
address 10.1.0.45 ; IP address of the printer
hostgroups allhosts ; Host groups this printer is associated with
}
define service{
use generic-service ; Inherit values from a template
host_name Printer_klen ; The name of the host the service is associated with
service_description Printer Status ; The service description
check_command check_Printer_klen!-C public ; The command used to monitor the service
normal_check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}
define service{
use generic-service
host_name Printer_klen
service_description PING
check_command check_ping!3000.0,80%!5000.0,100%
normal_check_interval 10
retry_check_interval 1
}
答案1
问题
这个错误实际上是不言自明的。
错误:找不到任何与“allhosts”匹配的主机组
你的define host{...}
块中有这一行:
hostgroups allhosts ; Host groups this printer is associated with
解决方案
您需要创建一个hostgroup
名为allhosts
.
在该文件中/etc/nagios/hostgroups.cfg
,您很可能需要添加一个定义主机组 allhosts 的节。
例子
define hostgroup{
hostgroup_name allhosts
alias All Hosts
}