How to get tag email for specific notice while overall tag level set to err?

78 views
Skip to first unread message

staceyt...@gmail.com

unread,
Aug 31, 2015, 2:59:21 PM8/31/15
to Puppet Users
Hi all,

I am using Puppet 3.7.3 and have a question about tagmail.

My tagmail.conf is setup to send email only when there is err and above:
err, alert, emerg, crit: us...@test.com

I have a module to check javalinks:

class javalinks {

file {      
    "/usr/java/latest":
    ensure => link,
    noop   => true,
  }
}

I want the module to ensure /usr/java/latest is a link, but don't do anything (noop => true).
I want to get an email notifcation if the link is missing.

If I don't have such a link, run "puppet agent -t" on the machine will display this on console:

      Notice: /Stage[main]/Javalinks/File[/usr/java/latest]/ensure: current_value absent, should be link (noop)

Since it is "Notice" level log, I don't get any email notification.

So here is my question:

How could I get email notification for this specific Notice message, without changing my tagmail.conf log level?

Thanks,
Stacey

staceyt...@gmail.com

unread,
Sep 1, 2015, 1:21:14 PM9/1/15
to Puppet Users
Hi,

I made some progress.

1. Add the metaparameter tag => send_me_email (or any arbitrary set of tag values) to the resource you want to monitor via email.
2. Enable reports = tagmail in puppet.conf [master] section,
3. In tag.conf set tag and email address: send_me_email: us...@test.com


class javalinks {

file {      
    "/usr/java/latest":
    ensure => link,
    noop   => true,
    tag => send_me_email,
  }
}

Now I get email for this class even if my overall tag log level is set to err and above, while this class is giving Notice log.

However, there is another Notice for this class which I don't want to get email notification:

Notice: /File[/usr/java/latest]/seluser: current_value unconfined_u, should be system_u (noop)

I only want to get email for this message in this class:

Notice: /Stage[main]/Javalinks/File[/usr/java/latest]/ensure: current_value absent, should be link (noop)

So here is the quesetion:
How to tag a specify notice in a class?

Thanks,
Stacey

staceyt...@gmail.com

unread,
Sep 1, 2015, 4:43:18 PM9/1/15
to Puppet Users
Hi all,

I figured it out.

class javalinks {

file {      
    "/usr/java/latest":
    ensure => link,
    noop   => true,
    tag => send_me_email,   
  selinux_ignore_defaults => true,
  }
}

Thanks,
Zaiwen

Garrett Honeycutt

unread,
Sep 1, 2015, 9:25:22 PM9/1/15
to puppet...@googlegroups.com
On 9/1/15 1:21 PM, staceyt...@gmail.com wrote:
> Hi,
>
> I made some progress.
>
> 1. Add the metaparameter tag => send_me_email (or any arbitrary set of
> tag values) to the resource you want to monitor via email.
> 2. Enable reports = tagmail in puppet.conf [master] section,
> 3. In tag.conf set tag and email address: send_me_email: us...@test.com
>
> class javalinks {
>
> file {
> "/usr/java/latest":
> ensure => link,
> noop => true,
> tag => send_me_email,
> }
> }
>
> Now I get email for this class even if my overall tag log level is set
> to err and above, while this class is giving Notice log.
>
> However, there is another Notice for this class which I don't want to
> get email notification:
>
> Notice: /File[/usr/java/latest]/seluser: current_value unconfined_u,
> should be system_u (noop)
>
> I only want to get email for this message in this class:
> *Notice: /Stage[main]/Javalinks/File[/usr/java/latest]/ensure:
> current_value absent, should be link (noop)
>
> *So here is the quesetion:
> How to tag a specify notice in a class?
>
> Thanks,
> Stacey
>
> On Monday, August 31, 2015 at 2:59:21 PM UTC-4, staceyt...@gmail.com wrote:
>
> Hi all,
>
> I am using Puppet 3.7.3 and have a question about tagmail.
>
> My tagmail.conf is setup to send email only when there is err and above:
> *err, alert, emerg, crit: us...@test.com <mailto:us...@test.com>*
>
> I have a module to check javalinks:
>
> class javalinks {
>
> file {
> "/usr/java/latest":
> ensure => link,
> noop => true,
> }
> }
>
> I want the module to ensure /usr/java/latest is a link, but don't do
> anything (noop => true).
> I want to get an email notifcation if the link is missing.
>
> If I don't have such a link, run "puppet agent -t" on the machine
> will display this on console:
>
> * Notice: /Stage[main]/Javalinks/File[/usr/java/latest]/ensure:
> current_value absent, should be link (noop)*
>
> Since it is "Notice" level log, I don't get any email notification.
>
> So here is my question:
>
> *How could I get email notification for this specific Notice
> message, without changing my tagmail.conf log level?*
>
> Thanks,
> Stacey
>
> --

Hi Stacey,

The tag() function might be of use to you in conjunction with tagmail.

http://docs.puppetlabs.com/references/latest/function.html#tag

Best regards,
-g


--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658
Reply all
Reply to author
Forward
0 new messages