# Xmailgraph 0.2 - statistics by rrdtool of xmailserver # released under the GNU General Public License # # copyright (c) 2004-04-20 waaf.net computing gbr # # see http://dev.waaf.net/ # # Changes: # # v0.1 # 2003-10-24 Achim Schmidt # 2003-10-30 Achim Schmidt # - Now greps all logfiles of the actual year # - SNDR=EIPMAP lines inside smtp-log is recognized as spam # # 0.2 # 2003-11-30 Achim Schmidt # - Added Feature of counting viruses logged inside antivirus-**** # 2003-04-20 Achim Schmidt # - Added a line to xmailgraph.pl for grepping out "FWD" instead of "SMTP" - this # is needed, if a smarthost for smtp is set - thank to andreas_AT_bratell.com ----------------------------------------------------------------------------- Before you start: Check, that you have the following programms installed: - "grep" (from gnu-utils) and "wc" (from gnu-coreutils) - "xmailserver" with logging enabled from http://www.xmailserver.org/ - "rrdtool" (apt-get install rrdtool) from http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/ - additional xmailgraph can analyze the logfiles generated by SpamAssassin Filter from http://www.drakeconsult.com/xmail/ - additional xmailgraph can analyze the logfiles generated by AntiVirus Filter from http://www.lindeman.org/filters.html ----------------------------------------------------------------------------- Installation: 0. You can use install.sh, which includes the default-installation steps (without 5-7) If You have 0.1 running please use update.sh. If You do so, please take a look at the script to use and ajust the vars! 1. copy the xmailgraph.pl to $MAIL_ROOT/bin/ e.g. $ cp xmailgraph.pl /var/MailRoot/bin/ 2. create a directory where the graphs and the webside can be accessed e.g. $ mkdir /var/www/xmailgraph 3. copy the html- & gif-files to the directory created in 2. e.g. $ cp *.html /var/www/xmailgraph/ $ cp *.gif /var/www/xmailgraph/ 4. Create the RRDs - best under $MAIL_ROOT/logs/ so they are backuped with the normal logfiles: e.g. (change /var/MailRoot/ to your $MAIL_ROOT) - run the following commands at console: rrdtool create /var/MailRoot/logs/WN_xmail_smtp.rrd --start -601 --step 600 \ DS:sent:ABSOLUTE:1200:0:U DS:recv:ABSOLUTE:1200:0:U DS:bounce:ABSOLUTE:1200:0:U \ RRA:AVERAGE:0.5:1:198 RRA:AVERAGE:0.5:7:198 RRA:AVERAGE:0.5:35:198 RRA:AVERAGE:0.5:385:198 \ RRA:MAX:0.5:1:198 RRA:MAX:0.5:7:198 RRA:MAX:0.5:35:198 RRA:MAX:0.5:385:198 rrdtool create /var/MailRoot/logs/WN_xmail_spam.rrd --start -601 --step 600 \ DS:spam1:ABSOLUTE:1200:0:U DS:spam2:ABSOLUTE:1200:0:U \ RRA:AVERAGE:0.5:1:198 RRA:AVERAGE:0.5:7:198 RRA:AVERAGE:0.5:35:198 RRA:AVERAGE:0.5:385:198 \ RRA:MAX:0.5:1:198 RRA:MAX:0.5:7:198 RRA:MAX:0.5:35:198 RRA:MAX:0.5:385:198 rrdtool create /var/MailRoot/logs/WN_xmail_pop3.rrd --start -601 --step 600 \ DS:pop3:ABSOLUTE:1200:0:U \ RRA:AVERAGE:0.5:1:198 RRA:AVERAGE:0.5:7:198 RRA:AVERAGE:0.5:35:198 RRA:AVERAGE:0.5:385:198 \ RRA:MAX:0.5:1:198 RRA:MAX:0.5:7:198 RRA:MAX:0.5:35:198 RRA:MAX:0.5:385:198 rrdtool create /var/MailRoot/logs/WN_xmail_antivirus.rrd --start -601 --step 600 \ DS:virus:ABSOLUTE:1200:0:U \ RRA:AVERAGE:0.5:1:198 RRA:AVERAGE:0.5:7:198 RRA:AVERAGE:0.5:35:198 RRA:AVERAGE:0.5:385:198 \ RRA:MAX:0.5:1:198 RRA:MAX:0.5:7:198 RRA:MAX:0.5:35:198 RRA:MAX:0.5:385:198 5. Take a look at /var/MailRoot/bin/xmailgraph.pl and adjust the vars: my ($hostname) = "xmail.example.com"; # Hostname used inside graphs my ($dir_of_pngs) = "/var/www/xmailgraph/"; # Where to put the graphs my ($path_to_xmail_logs) = "/var/MailRoot/logs/"; # Where are the xmail-Logs my ($path_to_rrd) = "/var/MailRoot/logs/"; # Where are the RRDs located and others if needed (paths of rrdtool, ...) 6. Tell Cron-Daemon, that it should run xmailgraph.pl every 10 Minutes. e.g. add thge following line to /etc/crontab: */10 * * * * root ( /var/MailRoot/bin/xmailgraph.pl 2>/dev/null ) 7. Wait for about an hour and then go to http://$YOURHOSTNAME/xmailgraph/ or the according directory created in step 2. 8. If You run xmailgraph under Win32 you have to do the following things: - Changed the unix style my ($dir_of_pngs) = "/var/www/xmailgraph/"; To my ($dir_of_pngs) = "E\:\\Apps\\xmailgraph\\www\\"; (Double Backlashes!) - Go to Section "Create the Graphs" (Line 151 ff.) inside xmailgraph.pl and remove the \\ my ($pop3_daily) = $bin_rrdtool." graph ".$dir_of_pngs."pop3_daily.png \\ --imgformat=PNG .... will become: my ($pop3_daily) = $bin_rrdtool." graph ".$dir_of_pngs."pop3_daily.png --imgformat=PNG ... Have a lot of fun... - Achim Schmidt http://achim.schmidt.tc