Table of Contents
Sending Alerts from Munin
As of Munin 1.2 there is a generic interface for sending warnings and errors from Munin. If a Munin plugin discovers that a plugin has a data source breaching its defined limits, Munin is able to alert the administrator either through simple command line invocations or through a monitoring system like Nagios.
Note that if the receiving system can cope with only a limited number of messages at the time, the configuration directive contact.contact.max_messages may be useful.
When sending alerts, you might find good use in the variables available from Munin.
Alerts through Nagios
How to set up Nagios and Munin to communicate has been thoroughly described in HowToContactNagios.
Alerts without external systems
Email Alert
To send email alerts directly from Munin use a command such as this:
contact.email.command |mail -s "Munin-notification for ${var:group} :: ${var:host}" your@email.address.here
For an example with explanation please look at:
http://edseek.com/archives/2006/07/13/munin-alert-email-notification/
Syslog Alert
To send syslog message with priority use a command such as this:
contact.syslog.command logger -p user.crit -t "Munin-Alert"
Alerts to or through external scripts
To run a script (in this example, 'script') from Munin use a command such as this in your munin.conf. Make sure that:
- There is NO space between the '>' and the first 'script'
- 'script' is listed twice and
- The munin user can find the script -- by either using an absolute path or putting the script somewhere on the PATH -- and has permission to execute the script.
contact.person.command >script script
This syntax also will work (this time, it doesn't matter if there is a space between '|' and the first 'script' ... otherwise, all the above recommendations apply):
contact.person.command | script script
Either of the above will pipe all of Munin's warning/critical output to the specified script. Below is an example script to handle this input and write it to a file:
#!/usr/bin/env ruby
File.open('/tmp/munin_alerts.log', 'a') do |f| #append
f.puts Time.now
for line in $stdin
f.puts line
end
end
The alerts getting piped into your script will look something like this:
localhost :: localdomain :: Inode table usage
CRITICALs: open inodes is 32046.00 (outside range [:6]).
