我想在icinga2中使用check_nwc_health check编写一个测试/检查条件,以获得avm dect 200电源插座的一些状态信息,其中提供有关连接设备(如电视、服务器、冰箱、洗衣机、烘干机等(的连接状态、通电、能耗等信息。
检查几乎准备好了,但缺少一点,因此脚本不能只提供一个带有选项--name的设备的状态。在shell cli上,它正在工作。命令如下所示:
https://labs.consol.de/assets/downloads/nagios/check_nwc_health-7.12.1.2.tar.gz
[icinga@centos7 icinga2]# /usr/lib64/nagios/plugins/check_nwc_health --hostname 10.10.10.3 --port 49000 --community 'Umligro:-)' --mode smart-home-device-status --name 'Wäschetrockner' --verbose
OK - device Wschetrockner ok
device Wschetrockner is connected and switched on
使用--name选项的输出是正确的。
现在icinga-config:
host.conf:
object Host "fritzbox-7390.fritz.box" {
check_command = "hostalive"
address = "10.10.10.3"
vars.os_type = "FritzOS"
vars.avm_port = "49000"
vars.avm_passwort = "Umligro:-)"
vars.avm_mode_status = "smart-home-device-status"
vars.avm_consumption_warning = "80"
vars.avm_consumption_critical = "95"
}
commands.conf:
object CheckCommand "check_fritzbox-7390" {
import "plugin-check-command"
command = [ PluginDir + "/check_nwc_health" ]
"--hostname" = "$avm_host$"
"--port" = "$avm_port$"
"--community" = "$avm_passwort$"
"--mode" = "$avm_mode$"
"--name" = {
value = "--name $avm_device_name$"
description = "Name of smart home device"
skip_key = true
required = true
}
"--verbose" = ""
}
}
services.conf:
apply Service "fritz-device-status-Geschirrspüler_Haus" {
import "generic-service"
check_command = "check_fritzbox-7390"
vars.avm_host = "$address$"
vars.avm_mode = "smart-home-device-status"
vars.avm_device_name = "Geschirrspüler Haus"
vars.avm_consumption_warning = "$nwc_health_warning$"
vars.avm_consumption_critical = "$nwc_health_critical$"
assign where host.vars.os_type == "FritzOS"
}
apply Service "fritz-device-status-Wäschetrockner" {
import "generic-service"
check_command = "check_fritzbox-7390"
vars.avm_host = "$address$"
vars.avm_mode = "smart-home-device-status"
vars.avm_device_name = "Wäschetrockner"
vars.avm_consumption_warning = "$nwc_health_warning$"
vars.avm_consumption_critical = "$nwc_health_critical$"
assign where host.vars.os_type == "FritzOS"
}
icinga web界面输出如下:
fritzbox-7390.fritz.box
fritz-device-status-Geschirrspüler_Haus
UNKNOWN 07-22-2020 15:25:34 0d 0h 35m 55s 1/5 (#0) Unknown option: name Geschirrspüler Haus
fritz-device-status-Wäschetrockner
UNKNOWN 07-22-2020 15:25:04 0d 0h 35m 55s 1/5 (#0) Unknown option: name Wäschetrockner
ping4
OK 07-22-2020 15:24:45 0d 1h 3m 1s 1/5 PING OK - Packet loss = 0%, RTA = 2.26 ms
我现在已经到了知识和神经的尽头,经过大约6个小时的搜索,我不得不放弃调试文件。
请有人帮我解决这个问题,也许这只是我忽略的一件小事。
谨致问候,Chris
您使用的插件不接受"--name";参数,所以只要从命令config中删除它就可以了。
供参考:https://exchange.icinga.com/lausser/check_nwc_health
此外,正确的语法看起来像:
"--name" = {
value = "$avm_device_name$"
description = "Name of smart home device"
}
为什么要跳过关键字,然后在参数中传递关键字本身?命令将处理此问题。