使用脚本的领事健康检查未验证

consul health check using script is not validating

在我的领事服务器和其他节点上,我添加了 3 个检查 CPU 利用率、内存利用率和硬盘利用率。我不知道为什么他们在验证期间失败。我做错了什么。

{
  "retry_join": [
    "172.20.20.31"
  ],
  "data_dir": "/tmp/consul",
  "client_addr": "0.0.0.0",
  "checks": [
    {
      "id": "check_cpu_utilization",
      "name": "CPU Utilization",
      "script": "/vagrant/provision/hc/cpu_utilization.sh",
      "interval": "10s"
    },
    {
      "id": "check_mem_utilization",
      "name": "MEM Utilization",
      "script": "/vagrant/provision/hc/mem_utilization.sh",
      "interval": "10s"
    },
    {
      "id": "check_hdd_utilization",
      "name": "HDD Utilization",
      "script": "/vagrant/provision/hc/hdd_utilization.sh",
      "interval": "10s"
    }
  ]
}

如果我验证 consul 配置文件。

consul validate common.json                             
Config validation failed: Error parsing common.json: 3 errors occurred:
    * invalid config key checks[0].script
    * invalid config key checks[1].script
    * invalid config key checks[2].script

我的consul版本是1.8.3

定义脚本检查的正确方法是在检查定义中使用 args 参数。

{
    "id": "check_cpu_utilization",
    "name": "CPU Utilization",
    "args": ["/vagrant/provision/hc/cpu_utilization.sh"],
    "interval": "10s"
}

Check Definitions 页面上的示例还展示了 args 字段的用法。