简体   繁体   中英

icinga check command check_nwc_health returns “Unkown option:” but at cli the command works

i want to write a test / check condition in icinga2 using the check_nwc_health check to get some status infos of avm dect 200 electricity socket where gives informations about state of connection, power on, energy consumption etc, of the connected device (like everything you could plug in: tv, server, fridge, washing machine, dryer etc.).

The check is nearly ready, but one little thing is missing, so that the script can't give the state of only one device with the option --name. On the shell cli it is working an the command goes like this:

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

The output is correct with the --name option.

Now the 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"
}

And the icinga web interface output looks like this:

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

I am now at the end of my knowledge and my nerves and after about 6 hours of searching I have to give up on the debug files.

Please someone can help me with this problem, maybe it is just a small thing that I have overlooked.

Best regards, Chris

The plugin you are using does not accept "--name" parameter, so just remove it from command config and it should work.

For reference: https://exchange.icinga.com/lausser/check_nwc_health

Also the correct syntax would look like:

  "--name" = {
  value = "$avm_device_name$"
  description = "Name of smart home device"
}

Why to skip the key and then pass the key itself in the argument? Commands will handle this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM