Munin alert email notification

Munin has support for sending mails when specified warning and critical thresholds are exceeded. If you aren’t already running a notification system, such as Nagios, Munin’s notification works splendidly. A few changes to munin.conf are all that’s needed.

First, you need to configure contacts, which enables the notification system.

contacts me # may be unnecessary and cause warnings
contact.me.command mail -s "Munin notification ${var:host}" user@host.tld
contact.me.always_send warning critical

Above, I define a contact entry named, aptly, me. Pick any name you would like. Next, the specific command action is defined. It’s really just a string to be executed by a shell which will receive the body of the alert message as STDIN. For sending email an appropriate command such as mail is used. Finally, mails will always be sent on any warning or critical state.

Next, recognize that alerts will only be sent for plugins that actually provide warning and critical values. A few of the default plugins do, the rest do not. What’s more, appropriate thresholds may vary by machine. Fortunately, you can define thresholds per plugin per host though how isn’t entirely explained in the documentation.

[foo.example.com]
        address 127.0.0.1
        use_node_name yes
        df._dev_sda1.warning 97
        hddtemp_smartctl.hde.critical 41
#     This won't work
#     hddtemp_smartctl.*.critical 41

In munin.conf, for each node of interest, you can define specific threshold values for a given host or override values provided by any plugin that already includes thresholds in its output. The format is plugin.fieldname.{critical,warning} value. You can find the fieldnames in the HTML graph views for fieldnames that are determined at configuration time by the plugin.

Above, the default warning threshold for the df plugin of 92 is overridden with 97. (In this case, it’s the % full output from the df command.) Additionally, a temperature threshold for critical is provided for the hddtemp_smartctl plugin, which does not specify one by default. A different value can be specified per host. I couldn’t specify thresholds globally per plugin for plugins that had no default. You must edit the plugin itself and redstribute it to monitored systems for new global defaults.

13 Comments

  1. beanie
    Posted 4/8/2007 at 1:03 pm | Permalink

    big thanks for this easy-to-use howto. munin is a very usefull tool!

    thx
    beanie

  2. Nirav
    Posted 5/15/2007 at 4:26 am | Permalink

    Thanks for to-the-point guide .. worked with gnokii .. for sending SMS

    thanks
    Nirav

  3. Posted 4/8/2009 at 9:52 am | Permalink

    With this configuration munin sends alerts for df every 5 minutes. How can I avoid that behavior? I.e. send only alert when state changes to warn or crit and skip all other similar alerts until state will change again (back to Ok or warn->crit or crit->warn etc)?

  4. Harald Korneliussen
    Posted 5/26/2009 at 4:19 am | Permalink

    The “contacts me” line causes munin-limits to spit out a lot of complaints about uninitialized values. When I remove it it appears to be fine.
    Hmmm, there really should be some syntax-checking on munin.conf to catch this sort of thing.

  5. Posted 7/23/2009 at 3:04 pm | Permalink

    A reply to Alexy — I have found that following this example or other documentation, Munin sends an alert the first time a threshold is breached, and another when the threshold is back within limits (not once every five minutes).

  6. Posted 10/25/2009 at 3:22 pm | Permalink

    Thanks! Works great!

  7. Tony Copeland
    Posted 12/19/2009 at 11:31 pm | Permalink

    My munin install v1.4.2 was emailing every five minutes and I found this active ticket.

    http://munin.projects.linpro.no/ticket/795

    It seems to fix my issue of continously getting the OKs emailed to me.

    Thanks,
    -Tony

  8. Posted 2/8/2010 at 1:43 pm | Permalink

    Thanks a lot for this howto :)

  9. AiBee
    Posted 12/17/2010 at 2:24 pm | Permalink

    One question. I have Ubuntu 9.10 server with the most updated version of munin for these release, which is 1.2.6

    I setup mail notification as you described in you blog post. User ‘munin’ has required rights to send mail via ‘mail’. Munin sees that there is a critical value, but no email is sent at all.

    Maybe yo know where could be the problem? Is this some kind of old version bug?

    Regards,
    AiBee

  10. James
    Posted 3/19/2011 at 2:12 pm | Permalink

    Hi,

    I am using munin 1.4.4 and have the problem where Munin is sending email alerts every 5 minutes once the threshold is breached. Is there any way around this? I only want 1 email when the threshold is breached and 1 email when the metric goes back within the threshold.

    Thank you so much in advance for your help. Getting so many emails is killing me!

    James

  11. Sergio
    Posted 3/25/2011 at 9:18 am | Permalink

    I am new to munin and wondered how to fit these instructions to receive an alert disk consumption

  12. Posted 1/12/2012 at 12:17 pm | Permalink

    After adding the next line in munin.conf after the appropriate node decalaration

    df._var_spool_samba.warning 96

    I get the following email:

    WARNINGs: /var/spool/samba is 95.16 (outside range [:92]).
    UNKNOWNs: is unknown
    OKs: /dev/shm is 0.00, /boot is 20.01, / is 1.46.

    Before this munin.conf editing emails looked like this:

    WARNINGs: /var/spool/samba is 95.16 (outside range [:92]).
    OKs: /dev/shm is 0.00, /boot is 20.01, / is 1.46.

    So, obviosly, config-file is not parsing correctly casuing “UNKNOWNs” line to appeare. Can someone tell me the reason of this?

    I use munin version 1.4.5

  13. Yashpal
    Posted 4/17/2012 at 1:40 am | Permalink

    Mail notification isnt working fr me. This is myn munin.conf-
    contact.me.command mail -s “Munin notification ${var:host}” yashpal.singh@infibeam.net
    contact.me.always_send warning critical

    # a simple host tree
    [localhost.localdomain]
    address 127.0.0.1
    use_node_name yes
    uptime.load.warning 0.01
    uptime.load.critical 0.02

Post a Comment

Your email is never shared. Required fields are marked *

*
*