Postfix - MRTG grafy
Upozorneni: Pro spravnou funkcni perlovych scriptu potrebujete knihovnu File::Tail kterou najdete bud na www.cpan.org nebo v ManDraku pouzijte prikaz
urpmi perl-File-Tail
Jakmile mate tuto knohovnu nainstalovanou pak si staci je stahnout tyto skripty:
update-mailstats.plmailstats.plmrtg-mailstats.plTyto soubory nahrajte do adresare /usr/local/bin a nastavne spravne prava.
chmod 755 update-mailstats.pl
chmod 755 mailstats.pl
chmod 755 mrtg-mailstats
HOWTO
-----
1. nez spustite update-mailstats.pl program je potreba ho nejprve editovat a nastavit spravnou cestu k mail login na
$mail_log = '/var/log/mail/info' ;
pak jiz muzete tento soubor spustit na pozadi:
update-mailstats.pl &
(you probably want to write a wrapper script to restart it in case it ever gets killed.)
this updates a file called /tmp/stats.db (adjust to suit your needs) with the inbound and outbound mail stats.
the logic of this script is extremely simple (and probably far from perfect):
if the line contains "status=sent" then figure out the transport from the "relay=" part of the line. if relay= contains "[" then assume it's
an IP address, and transport is smtp. otherwise, transport is whatever the "relay=" bit says.
if line contains "smtpd.*client=" then we've received a message via smtp. if line contains "pickup.*(sender|uid)=" then we've received a message from a local user.
very simple, mostly works. i'm sure there are cases which it doesn't catch. if you can improve it, let me know.
to tell the truth, it doesn't matter if it's 100% accurate or not. the point is to give a pretty graph of some meaningless numbers to
management types. they love it :)
2. Ted je dobre provest kontrolu raw rad, ktere budeme zpracovavat pomoci MRTG:
$ mailstats.pl
RECEIVED:local 162
RECEIVED:smtp 4253
SENT:local 4101
SENT:smtp 5118
3. a jako posledni vec je pridat do konfiguraku MRTG tyto radkymrtg.cfg:
#---------------------------------------------------------------#
# MRTG mail cfg: Postfix mailstats plotting with MRTG #
#---------------------------------------------------------------#
Target[postfix]: `/usr/local/bin/mrtg-mailstats.pl`
MaxBytes[postfix]: 10000
Options[postfix]: gauge, growright
Title[postfix]: Postfix Statistics
PageTop[postfix]:Postfix Statistics
WithPeak[postfix]: dwmy
YLegend[postfix]: No. of messages
ShortLegend[postfix]: messages
LegendI[postfix]: Incoming:
LegendO[postfix]: Outgoing:
#---------------------------------------------------------------#
this runs the mrtg-mailstats.pl programs which totals the RECEIVED and SENT lines output by mailstats.pl and then outputs it in a form suitable for MRTG. it keeps the previous RECEIVED and SENT counts in /tmp/mailstats.old
« Zpět na seznam