在 .conf 文件中监控 IP 的正确语法,Icinga2

在 .conf 文件中监控 IP 的正确语法,Icinga2

我目前有代码

object Host "rqbhost" {
address = "xx.xx.xx.xx"
check_command = "hostalive"
}

object Service "ping4" {
host_name = "rqbhost"
check_command = "ping4"
}

object Service "http" {
host_name = "rqbhost"
check_command = "http"
}

这不允许我启动 icinga 服务,错误日志也没有告诉我为什么它们不正确。我尝试过 icinga2 的文档,但对于像我这样简单的任务来说,它毫无帮助。

错误日志在这里

:/etc/icinga2/conf.d/services.conf(25):  */
:/etc/icinga2/conf.d/services.conf(26): apply Service "ping4" {
:^^^^^^^^^^^^^^^^^^^^^
:/etc/icinga2/conf.d/services.conf(27):   import "generic-service"
:/etc/icinga2/conf.d/services.conf(28):
:[2016-07-08 13:59:24 +0000] critical/config: 1 error
:icinga2.service: control process exited, code=exited status=1

答案1

Ping4 不是我安装的服务。它在 icinga2 文档页面上被列为示例。在 Icinga2 中监控主机是否处于活动状态(仅此而已)的语法如下。

object Host "NAME" { /*ID of the ip/location/host you want to monitor*/
address = "xxx.xxx.xxx.xxx" /*IP address of the host*/
check_command = "hostalive" /*checks if alive*/
}
object Service "http" { /*checks for service http and its status*/
host_name = "NAME" /*which host you want to see*/
check_command = "http"/*checks if http is up*/
}

如果该内容位于您的 /etc/icinga2/conf.d/ 中,则将其保存为 FILENAME.conf

使用 systemctl restart icinga2 重新启动,新主机将可在 Web 界面中监控。

相关内容