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.
8 Comments
big thanks for this easy-to-use howto. munin is a very usefull tool!
thx
beanie
Thanks for to-the-point guide .. worked with gnokii .. for sending SMS
thanks
Nirav
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)?
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.
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).
Thanks! Works great!
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
Thanks a lot for this howto :)