Hi,

please reply to the original thread, not the digest. It makes it really hard to 
follow history.

> On 2 Mar 2017, at 12:19, Christian Moreno Moreno <[email protected]> 
> wrote:
> 
> This is one example of one host definition:
> 
> Object Host "s406.xxx" {
>         import        "generic-host"
>         display_name=        "s406"
>         address =        "x.x.x.x"
>         vars.parent  =        "x,x"
>         groups  =         ["groupA","groupB"]
>         vars.notification.mail.users =          ["it-systems"]
>         vars["info"] = {
>                 Virtual = ["physical"]
>                 Running_VMs = ["null"]
>                 Server_Stage = ["production"]
>         }
>         vars.notification.sms.users = ["bereitschaft_sms"]
> }


Taking your notification apply rule, there’s a problem with checking the 
exclude inside the array.

 if ("it-ops-mail" in host.vars.notification.mail.users ) && 
(host.vars.notification.sms.users != "bereitschaft_sms" ) {

host.vars.notification.sms.users is an array and therefore not comparable using 
the != operator for strings. You can use !in similar to your first condition.


> 
> I was thinking about filter that with the notifications_comands and the 
> script, something like:
> 
> object NotificationCommand "mail-service-notification" {
>   import "plugin-notification-command"
> 
>   command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
> 
>   env = {
>     NOTIFICATIONTYPE = "$notification.type$"
>     SERVICEDESC = "$service.name$"
>     HOSTALIAS = "$host.display_name$"
>     HOSTADDRESS = "$address$"
>     SERVICESTATE = "$service.state$"
>     LONGDATETIME = "$icinga.long_date_time$"
>     SERVICEOUTPUT = "$service.output$"
>     NOTIFICATIONAUTHORNAME = "$notification.author$"
>     NOTIFICATIONCOMMENT = "$notification.comment$"
>     HOSTDISPLAYNAME = "$host.display_name$"
>     SERVICEDISPLAYNAME = "$service.display_name$"
>     USEREMAIL = "$user.email$"
>     SERVICENOTESURL = "$service.notes_url$"
> 
>     if ("service.vars.notification.mail.users") {
>         USERESMS = "$service.vars.notification.mail.users$"
>     } else {
>         USERESMS = "$host.vars.notification.sms.users$"
>       }
> 
>     }
> }

That condition won’t work, as you do not have access to the host or service 
object inside NotificationCommand objects at config compile runtime.

You certainly could do that inside the Notification apply rule, by setting a 
custom attribute like vars.useresms or something like that.


> 
> and then in the script use USERESMS for sone cases, but  it doesnt runs.... 
> would be possible some CASE Statement in notifications_comand.conf? 

Would the notification apply condition solve your problem?

Reading it again from your previous mail.

> We have one mail contact for the mail notifications and other for the sms 
> notifications, but now we would like get the mail notifications only if the 
> services has our sms contact defined.

This certainly would require to adjust the assign where expression to avoid 
creating a notification object for hosts which do not have the 
“bereitschaft_sms” as array member, but only “it-ops-mail”.

Kind regards,
Michael



> 
> 
> 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: [email protected]
> Geschäftsführer:
> Dr. Albrecht von Sonntag, Dr. Philipp-Christopher Peitsch
> HRB 76749 – Amtsgericht Berlin-Charlottenburg
> 
> 
> 
> 
> 
> 
> 2017-03-02 11:36 GMT+01:00 <[email protected]>:
> Send icinga-users mailing list submissions to
>         [email protected]
> 
> 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
>         [email protected]
> 
> You can reach the person managing the list at
>         [email protected]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of icinga-users digest..."
> 
> 
> Today's Topics:
> 
>    1. What's the best config to have for monitoring     S.M.A.R.T.
>       remotely ? (Horatiu N)
>    2. Auto-reply [Re: What's the best config to have for        monitoring
>       S.M.A.R.T. remotely ?] ([email protected])
>    3. Re: What's the best config to have for monitoring S.M.A.R.T.
>       remotely ? (Tim H.)
>    4. extract contact via templates (Christian Moreno Moreno)
>    5. Re: extract contact via templates (Michael Friedrich)
>    6. Re: What's the best config to have for monitoring S.M.A.R.T.
>       remotely ? (Horatiu N)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Wed, 1 Mar 2017 19:44:39 +0200
> From: Horatiu N <[email protected]>
> To: [email protected]
> Subject: [icinga-users] What's the best config to have for monitoring
>         S.M.A.R.T. remotely ?
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
> 
> Greetings,
> 
> I want to monitor several remote servers drives for SMART errors and
> also disk usage.
> 
> On icinga2, what scenario do you recommend ?
> 
> Thank you.
> 
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/pkcs7-signature
> Size: 3705 bytes
> Desc: S/MIME Cryptographic Signature
> URL: 
> <http://lists.icinga.org/pipermail/icinga-users/attachments/20170301/59e72f47/attachment-0001.bin>
> 
> ------------------------------
> 
> Message: 2
> Date: Wed, 01 Mar 2017 17:44:58 +0000
> From: [email protected]
> To: Icinga User's Corner <[email protected]>
> Subject: [icinga-users] Auto-reply [Re: What's the best config to have
>         for     monitoring      S.M.A.R.T. remotely ?]
> Message-ID: <[email protected]>
> 
> I am currently on holiday until March 13th
> 
> If you require support, please email [email protected]
> 
> Alternatively I will respond to your email upon my return
> 
> Will Tatam
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Wed, 1 Mar 2017 13:43:46 -0500
> From: "Tim H." <[email protected]>
> To: "Icinga User's Corner" <[email protected]>
> Subject: Re: [icinga-users] What's the best config to have for
>         monitoring S.M.A.R.T. remotely ?
> Message-ID:
>         <CA+c0hdG=u-Pm+OjmH=eo7jma5sin5s+34e0k-pwxq4izcx0...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> 
> Looks like nagios has a few smart monitoring plugins here:
> 
> https://www.nagios.com/solutions/smart-monitoring/
> 
> They are likely available in your distributions package manager under a
> name like "nagios-plugins".
> 
> On Wed, Mar 1, 2017 at 12:44 PM, Horatiu N <[email protected]> wrote:
> 
> > Greetings,
> >
> > I want to monitor several remote servers drives for SMART errors and also
> > disk usage.
> >
> > On icinga2, what scenario do you recommend ?
> >
> > Thank you.
> >
> >
> > _______________________________________________
> > icinga-users mailing list
> > [email protected]
> > https://lists.icinga.org/mailman/listinfo/icinga-users
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> <http://lists.icinga.org/pipermail/icinga-users/attachments/20170301/da9f067f/attachment-0001.html>
> 
> ------------------------------
> 
> Message: 4
> Date: Thu, 2 Mar 2017 09:33:23 +0100
> From: Christian Moreno Moreno <[email protected]>
> To: [email protected]
> Subject: [icinga-users] extract contact via templates
> Message-ID:
>         <CAHCD4S8f-B5=x8YpTpWKY9zXgrUrP72gu4X822+=o79ttvq...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> 
> Hi,
> 
> We have one mail contact for the mail notifications and other for the sms
> notifications, but now we would like get the mail notifications only if the
> services has our sms contact defined.
> Something like:
> 
> apply Notification "mail-icingaadmin" to Host {
>   import "mail-host-notification"
> 
>   interval = 0 // re-notification disabled
> 
>   users = host.vars.notification.mail.users
> 
>   if ("it-ops-mail" in host.vars.notification.mail.users ) &&
> (host.vars.notification.sms.users != "bereitschaft_sms" ) {
> 
>     enable_notifications = false
>   }
> 
>   assign where host.vars.notification.mail
> }
> 
> I think that this would runs... but then, if the host/service would have
> one second contact for the mail notification, then they would get it too.
> 
> Is possible to delete/extract via Apply one contact?
> 
> 
> alternative is change via Script all config files...
> 
> 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: [email protected]
> Gesch?ftsf?hrer:
> Dr. Albrecht von Sonntag, Dr. Philipp-Christopher Peitsch
> HRB 76749 ? Amtsgericht Berlin-Charlottenburg
> [image: idealo Logo] <http://www.idealo.de/>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> <http://lists.icinga.org/pipermail/icinga-users/attachments/20170302/2ff65f5d/attachment-0001.html>
> 
> ------------------------------
> 
> Message: 5
> Date: Thu, 2 Mar 2017 09:37:00 +0100
> From: Michael Friedrich <[email protected]>
> To: Icinga User's Corner <[email protected]>
> Subject: Re: [icinga-users] extract contact via templates
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=utf-8
> 
> 
> > On 2 Mar 2017, at 09:33, Christian Moreno Moreno 
> > <[email protected]> wrote:
> >
> > Hi,
> >
> > We have one mail contact for the mail notifications and other for the sms 
> > notifications, but now we would like get the mail notifications only if the 
> > services has our sms contact defined.
> > Something like:
> >
> > apply Notification "mail-icingaadmin" to Host {
> >   import "mail-host-notification"
> >
> >   interval = 0 // re-notification disabled
> >
> >   users = host.vars.notification.mail.users
> >
> >   if ("it-ops-mail" in host.vars.notification.mail.users ) && 
> > (host.vars.notification.sms.users != "bereitschaft_sms" ) {
> >
> >     enable_notifications = false
> >   }
> >
> >   assign where host.vars.notification.mail
> > }
> >
> > I think that this would runs... but then, if the host/service would have 
> > one second contact for the mail notification, then they would get it too.
> >
> > Is possible to delete/extract via Apply one contact?
> 
> How do the host objects look like?
> 
> Kind regards,
> Michael
> 
> >
> >
> > alternative is change via Script all config files...
> >
> > 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: [email protected]
> > Gesch?ftsf?hrer:
> > Dr. Albrecht von Sonntag, Dr. Philipp-Christopher Peitsch
> > HRB 76749 ? Amtsgericht Berlin-Charlottenburg
> >
> >
> >
> >
> >
> > _______________________________________________
> > icinga-users mailing list
> > [email protected]
> > https://lists.icinga.org/mailman/listinfo/icinga-users
> 
> 
> 
> ------------------------------
> 
> Message: 6
> Date: Thu, 2 Mar 2017 12:36:22 +0200
> From: Horatiu N <[email protected]>
> To: [email protected]
> Subject: Re: [icinga-users] What's the best config to have for
>         monitoring S.M.A.R.T. remotely ?
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="windows-1252"; Format="flowed"
> 
> That's not what I asked.
> 
> I meant what scenario, not what tools.
> I have icinga2 running already but i'm not monitoring remote hardware,
> only remote availability via icmp or tcp port (like http, pop, etc).
> I was thinking maybe somebody does this on a large enough scale and can
> recommend a theoretical setup based on personal experience with setup,
> maintenance, ease of configuration, scalability, automation etc.
> 
> I didn't ask about man pages or command line parameters to plugins, no
> thank you, I can read those myself.
> 
> On 3/1/2017 8:43 PM, Tim H. wrote:
> > Looks like nagios has a few smart monitoring plugins here:
> >
> > https://www.nagios.com/solutions/smart-monitoring/
> >
> > They are likely available in your distributions package manager under a
> > name like "nagios-plugins".
> >
> > On Wed, Mar 1, 2017 at 12:44 PM, Horatiu N <[email protected]
> > <mailto:[email protected]>> wrote:
> >
> >     Greetings,
> >
> >     I want to monitor several remote servers drives for SMART errors and
> >     also disk usage.
> >
> >     On icinga2, what scenario do you recommend ?
> >
> >     Thank you.
> >
> >
> >     _______________________________________________
> >     icinga-users mailing list
> >     [email protected] <mailto:[email protected]>
> >     https://lists.icinga.org/mailman/listinfo/icinga-users
> >     <https://lists.icinga.org/mailman/listinfo/icinga-users>
> >
> >
> >
> >
> > _______________________________________________
> > icinga-users mailing list
> > [email protected]
> > https://lists.icinga.org/mailman/listinfo/icinga-users
> >
> 
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/pkcs7-signature
> Size: 3705 bytes
> Desc: S/MIME Cryptographic Signature
> URL: 
> <http://lists.icinga.org/pipermail/icinga-users/attachments/20170302/916c833f/attachment.bin>
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> icinga-users mailing list
> [email protected]
> https://lists.icinga.org/mailman/listinfo/icinga-users
> 
> 
> ------------------------------
> 
> End of icinga-users Digest, Vol 39, Issue 2
> *******************************************
> 
> _______________________________________________
> icinga-users mailing list
> [email protected]
> https://lists.icinga.org/mailman/listinfo/icinga-users

_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to