Add three lines to your mrtg.cfg:
ThreshMaxI[serverA.MySQL]: 25000
ThreshProgI[serverA.MySQL]: /usr/local/bin/mrtg_threshprogi.sh
ThreshProgOKI[serverA.MySQL]: /usr/local/bin/mrtg_threshprogoki.sh
This particular string "MySQL" in fact can be changed to whatever: CPU, network traffic, web page requests etc. (see my custom MRTG collectors).
Then lets write a script to manage crossed thresholds:
/usr/local/bin/mrtg_threshprogi.sh
#!/bin/bash
echo "" | mail -s "[MRTG] $1 exceeded; allowed: ${2}, current: $3" root
/usr/local/bin/mrtg_threshprogoki.sh
#!/bin/bash
echo "" | mail -s "[MRTG] $1 returned to $2" root
Simple and effective.
If mrtg.cfg strings are the same as directory name convention, you can attach
/var/www/ssl/mrtg/MySQL/serverA.MySQL-day.png
to the e-mail:
# $1 == "serverA.cpu" => srv == "serverA"; meter == "cpu"
# optionally: METER=`echo $meter | tr /a-z/ /A-Z/` changes "cpu" to "CPU"
IFS=. read srv meter <<< $1
mutt -x -s "[MRTG] $1 exceeded; allowed: ${2}, current: $3" \
-a /saltstone/httpd/html_ssl/info/mrtg/${meter}/${SUBJECT}-day.png root
No comments:
Post a Comment