MRTG Email Notifications And AlertsPosted by Roger Keays, 30 August 2011, 1:22 PM |
While searching the MRTG docs for some settings, I stumbled across the following option:
ThreshMinI (PER TARGET)
This is the minimum acceptable value for the Input (first) parameter. If the parameter falls below this value, the program specified in ThreshProgI will be run and a mail will be sent to the ThreshMailAddress if specified. If the value ends in '%' then the threshold is defined relative to MaxBytes.
Although my version of MRTG didn't support ThreshMailAddress, it was pretty simple to rig up a shell script to send email notifications when threshold values are reached.
Here is the MRTG config I added to notify me if the cpu usage exceeds 75% or the disks reach 95% capacity.
ThreshDir: /var/run/mrtg ThreshProgI[_]: /usr/local/sbin/notify ThreshProgOKI[_]: /usr/local/sbin/notify ThreshMaxI[cpu]: 75 ThreshMaxI[disk1]: 95 ThreshMaxI[disk2]: 95
Make sure you create the /var/run/mrtg directory.
Here is the /usr/local/sbin/notify shell script to send the mail.
#!/bin/sh # # This script is executed by MRTG when threshold values are reached. It # just sends an email notification to the logging address. # echo | mail -s "$1 is at $3" logging@example.com
| << Using AddThis fb:like And g:plusone Attributes With Facelets | Back to Blog | VIM Key Bindings In Ubuntu Using Xmodmap >> |
Add a comment
Please visit http://www.ninthavenue.com.au/mrtg-email-notifications-and-alerts to add your comments.