MRTG Email Notifications And Alerts
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" firstname.lastname@example.org
Roger Keays is an artist, an engineer, and a student of life. He has no fixed address and has left footprints on 40-something different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, the proper use of semicolons, and finding good food.