领事模板,如果其他条件

Kasun Rathnayaka

我有下面的领事模板。

{{ range service "mysql_slave.mysql" "any" }}
host_name                      {{.Node}}
command                        check_nrpe!check_procs_1
{{end}}

我想添加主机名是否匹配“ database-1”,然后命令“ check_procs_1”,其他命令“ check_procs_2”

输出

host_name                      node_server
command                        check_nrpe!check_procs_2

host_name                      database-1
command                        check_nrpe!check_procs_1

host_name                      webserver
command                        check_nrpe!check_procs_2
Kasun Rathnayaka

要解决此问题,我们可以使用以下修复程序。

{{ range service "mysql_slave.mysql" "any" }}

  {{ if eq .Node "database-1" }}

  host_name                      {{.Node}}
  command                        check_nrpe!check_procs_1

  {{else}}

  host_name                      {{.Node}}
  command                        check_nrpe!check_procs_2

  {{end}}

{{end}}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章