我有四种设备类型: apache11、apache12、apache22和apache24。前两个使用密码"4597“,第二个使用密码”9634“。所有这些the服务器都有相同的管理用户,“金鱼”。
这就是我认为应该有效的逻辑。
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"
}我得到的错误是:
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): }我所要做的就是为一组机器使用一个密码,对另一组机器使用不同的密码。
发布于 2017-06-22 17:01:01
它总是“如果”跟随“如果”
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"
}https://serverfault.com/questions/856903
复制相似问题