I believe your if statement is incorrect
try:

 if (  host.groups == "*production*" )


On 02/06/17 15:07, Christian Moreno Moreno wrote:
Hi,

we have the next template for the virtualhosts:

template Host "virtual-generic-host" {
  max_check_attempts = 3
  check_interval = 1m
  retry_interval = 30s
  enable_perfdata = true
  check_command = "hostalive"

   vars.notification.sms.users  = ["bereitschaft_sms"]
   vars.notification.mail.users = ["it-ops-systems"]

}

but I would like do the next if Statement:

template Host "virtual-generic-host" {
  max_check_attempts = 3
  check_interval = 1m
  retry_interval = 30s
  enable_perfdata = true
  check_command = "hostalive"
notes_url = "https://content-backend.idealo.de/issues/issues/?jql=text~ <https://content-backend.idealo.de/issues/issues/?jql=text%7E>" + display_name

       if ( "production" in host.groups ) {
          vars.notification.sms.users  = ["bereitschaft_sms"]
          vars.notification.mail.users = ["it-ops-systems"]
        }
else {
          vars.notification.sms.users  = ["null"]
          vars.notification.mail.users = ["null"]
      }
}

We need that only Production do notifications and we wouldnt like to insert the null values for every virtualhost.
The problem is that looks like if these Statements are not permit:

*Location: in /etc/icinga2/zones.d/global-templates/templates/template_host-01.conf: 22:29-22:32 /etc/icinga2/zones.d/global-templates/templates/template_host-01.conf(21): /etc/icinga2/zones.d/global-templates/templates/template_host-01.conf(22):        if ( "production" in host.groups ) {
                                                                                
        ^^^^
/etc/icinga2/zones.d/global-templates/templates/idealo_host-01.conf(23):           vars.notification.sms.users  = ["bereitschaft_sms"] /etc/icinga2/zones.d/global-templates/templates/idealo_host-01.conf(24):           vars.notification.mail.users = ["it-ops-systems"]

critical/config: Error: Error while evaluating expression: Tried to access undefined script variable 'host'*



Has someone one idea?

Regards,
Christian Moreno

Christian Moreno Moreno
System Engineer Offers

idealo internet GmbH
Ritterstraße 11
10969 Berlin, Deutschland
Tel.: +49 (0)30 40 30 10 33
Fax: +49 (0)30 221 94 33 <tel:%2B49%20%280%2930%20221%2094%2033> - 21
E-Mail: christian.mor...@idealo.de <mailto:christian.mor...@idealo.de>
Geschäftsführer:
Dr. Albrecht von Sonntag, Dr. Philipp-Christopher Peitsch
HRB 76749 – Amtsgericht Berlin-Charlottenburg
idealo Logo <http://www.idealo.de/>

















_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users


_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to