Условная логика Icinga2

У меня четыре типа устройств: apache11, apache12, apache22 и apache24. Первые два используют пароль« 4597 », а вторые два используют пароль« 9634 ». All of these webservers have the same admin user, "kingfish."

Here's the logic I thought should work.

apply Service "HTTP/80: Apache Status" {
  import "generic-service"
  check_interval = 10m
  retry_interval = 3m
  check_command = "check-custom-apache"
  vars.gsuser = "kingfish"

    if ( host.vars.devtype == "apache22" || host.vars.devtype == "apache24" ) {
        vars.gspass = "9634"
    } else ( host.vars.devtype == "apache11" || host.vars.devtype == "apache12" ) {
        vars.gspass = "4597"
    }
  assign where host.vars.devtype == "apache22"
  assign where host.vars.devtype == "apache24"
  assign where host.vars.devtype == "apache11"
  assign where host.vars.devtype == "apache12"
}

The error I'm getting is:

critical/config: Error: syntax error, unexpected '(', expecting if (T_IF) or '{'
Location: in /etc/icinga2/zones.d/global-templates/xrs-services.conf: 62:12-62:12
/etc/icinga2/zones.d/global-templates/xrs-services.conf(60):     if ( host.vars.devtype == "apache22" || host.vars.devtype == "apache24" ) {
/etc/icinga2/zones.d/global-templates/xrs-services.conf(61):       vars.gspass = "9634"
/etc/icinga2/zones.d/global-templates/xrs-services.conf(62):     } else ( host.vars.devtype == "apache11" || host.vars.devtype == "apache11" ) {
                                                                        ^
/etc/icinga2/zones.d/global-templates/xrs-services.conf(63):       vars.gspass = "4597"
/etc/icinga2/zones.d/global-templates/xrs-services.conf(64):     }

All I'm trying to accomplish is to use one password for one group of machines and a different one for another group of machines.

0
задан 20 June 2017 в 21:53
1 ответ

Всегда будет «иначе, если» следует за «если»

if ( host.vars.devtype == "apache22" || host.vars.devtype == "apache24" ) {
    vars.gspass = "9634"
} else if ( host.vars.devtype == "apache11" || host.vars.devtype == "apache12" ) {
vars.gspass = "4597"
}
0
ответ дан 5 December 2019 в 07:58

Теги

Похожие вопросы