ops-center / searchlight

🔦 Alerts for Kubernetes
https://appscode.com/products/searchlight
Apache License 2.0
321 stars 24 forks source link

Unknown : var "icinga.checkInterval" is not registered in SearchlightPlugin #397

Closed mmta closed 6 years ago

mmta commented 6 years ago

searchlight isn't generating a correct icinga2 conf for webhook. This is on Version = 7.0.0.

My web hook runs OK like this:

bash-4.3# ./hyperalert check_webhook --check_command="check-ssh" --webhook_url="http://check-ssh.icinga.svc/check-ssh" --key.0="cmd" --val.0="id" --key.2="server" --val.2="k8sworker1c" --icinga.checkInterval=30
OK : uid=0(root) gid=0(root) groups=0(root)

But the config generated by searchlight is:

bash-4.3# cat /etc/icinga2/custom.d/check-ssh.conf
object CheckCommand "check-ssh" {
  import "plugin-check-command"
  command = [ PluginDir + "/hyperalert", "check_webhook"]

  arguments = {
        "--webhook_url" = "http://check-ssh.icinga.svc/check-ssh"
        "--check_command" = "check-ssh"
        "--key.0" = "cmd"
        "--val.0" = "$cmd$"
        "--key.1" = "icinga.checkInterval"
        "--val.1" = "$service.check_interval$"
        "--key.2" = "server"
        "--val.2" = "$server$"
  }
}bash-4.3#

And here's what happen when I try to emulate that CheckCommand. The same message also occurs on the icingaweb2 page (UNKNOWN status).

bash-4.3# ./hyperalert check_webhook --check_command="check-ssh" --webhook_url="http://check-ssh.icinga.svc/check-ssh" --key.0="cmd" --val.0="id" --key.2="server" --val.2="k8sworker1c" --icinga.checkInterval=30 --key.1="icinga.checkInterval" --val.1="30"
*Unknown : var "icinga.checkInterval" is not registered in SearchlightPlugin*
bash-4.3#

So maybe this block needs to exclude icinga.checkInterval? https://github.com/appscode/searchlight/blob/d5e04e0a6be5c750c659d24a42b6e1742c971daa/pkg/plugin/check_command.go#L87-L90

tamalsaha commented 6 years ago

Thanks @mmta . If you would like to send a pr, please do.