Hi Assaf,

Thanks for your answer. I tried it but it looks wrong too:

critical/config: Error: Error while evaluating expression: Tried to access
undefined script variable 'host'
Location: in
/etc/icinga2/zones.d/global-templates/templates/idealo_host-01.conf:
22:9-22:12
/etc/icinga2/zones.d/global-templates/templates/idealo_host-01.conf(20):
notes_url     = "https://content-backend.idealo.de/issues/issues/?jql=text~";
+ display_name
/etc/icinga2/zones.d/global-templates/templates/idealo_host-01.conf(21):
/etc/icinga2/zones.d/global-templates/templates/idealo_host-01.conf(22):
if (  host.groups == "*production*" ) {

^^^^
/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"]

Regards,
Christian


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 - 21
E-Mail: christian.mor...@idealo.de
Geschäftsführer:
Dr. Albrecht von Sonntag, Dr. Philipp-Christopher Peitsch
HRB 76749 – Amtsgericht Berlin-Charlottenburg
[image: idealo Logo] <http://www.idealo.de/>





2017-06-07 12:00 GMT+02:00 <icinga-users-requ...@lists.icinga.org>:

> Send icinga-users mailing list submissions to
>         icinga-users@lists.icinga.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.icinga.org/mailman/listinfo/icinga-users
> or, via email, send a message with subject or body 'help' to
>         icinga-users-requ...@lists.icinga.org
>
> You can reach the person managing the list at
>         icinga-users-ow...@lists.icinga.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of icinga-users digest..."
>
>
> Today's Topics:
>
>    1. Re: Template Host and If statements (Assaf Flatto)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 6 Jun 2017 17:26:42 +0300
> From: Assaf Flatto <ici...@flatto.net>
> To: Icinga User's Corner <icinga-users@lists.icinga.org>
> Subject: Re: [icinga-users] Template Host and If statements
> Message-ID: <3da8262f-7644-172c-590c-2446ffaf9...@flatto.net>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>
> 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
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.icinga.org/pipermail/icinga-users/
> attachments/20170606/4162d000/attachment-0001.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> icinga-users mailing list
> icinga-users@lists.icinga.org
> https://lists.icinga.org/mailman/listinfo/icinga-users
>
>
> ------------------------------
>
> End of icinga-users Digest, Vol 42, Issue 2
> *******************************************
>
_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to