The cause for making clamsmtp-stats was that we enjoyed the good looking graphs amavis-stats could produce from the amavis logs. Later we decided to replace sendmail + amavisd-new combo on our mailserver, and switched to clamsmtp. But for clamsmtp we couldn't find a solution that creates graphs like those. First attempts to recreate all from scratch were not to mention, and we looked at the sources of amavis-stats, to see how did they do it. We realized soon that a simple modification of some regular expressions makes analysing our clamsmtp logs possible. Then came the idea not to patch amavis- stats, but to clean anything amavis related, and to specialize the code for clamsmtp, and maybe later to optimize and rewrite the perl and php code. The first release of clamsmtp-stats is based on the 0.1.12-7.4 version of amavis-stats
clamsmtp-stats is clamsmtp graph generator based on rrdtool. It produces
graphs of clean emails and infected emails broken down by virus, from
clamsmtp log entries (such as /var/log/mail.log).
The RRD files are created and updated by a perl script. Since the script uses the date/time values from the log entries it can be run (ir)regularly from cron(8) or by hand as desired. Graphs are generated by a php script.
We developed this version on Ubuntu Server, so i document the packages. To use this tool you basically need a working clamsmtp installation, the rrdtool or the php4-rrdtool package.
The perl script uses librrds-perl and the libio-compress-zlib-perl package.
Graphs are generated by php in combination with either the command-line rrdtool or the php4-rrdtool shared library so you need the php package.
See our static demo page
You can download the pre-packaged tgz or deb package in
our download area
or use CVS to download the most fresh "nightly-relase"
These features are mainly ideas for the future, any ideas for features are welcome.
Q. What is the best way to handle rotated (*.gz) logfiles?
How do I get all of the history in the graphs and not just the latest log?
A. clamsmtp-stats doesn't handle .tar archives at the moment. What it expects is just the name of a single uncompressed, or gzip comressed file. So when I first install it on a machine I usually do the following to get the history:
clamsmtp$ ls mail.info*
mail.info mail.info.0 mail.info.1.gz mail.info.2.gz mail.info.3.gz
clamsmtp$ /usr/sbin/clamsmtp-stats -r mail.info.3.gz
clamsmtp$ /usr/sbin/clamsmtp-stats -r mail.info.2.gz
clamsmtp$ /usr/sbin/clamsmtp-stats -r mail.info.1.gz
clamsmtp$ /usr/sbin/clamsmtp-stats -r mail.info.0
clamsmtp$ /usr/sbin/clamsmtp-stats -r mail.info
You have to manually run clamsmtp-stats on each file in the correct chronological order
Q. The rrd files seem to get generated ok but I when I try and display the web page I get the error: clamsmtp-stats::error: rrd_graph(): 127
A. I believe that the error code 127 is returned from bash when it can't find the program to execute. I guess in this case that your web user (www-data or www or web) is unable to find the "rrdtool" executable. Perhaps it is not in the standard location, or the path for that user is not set?
You could try the following to see if the tool can be found.
root# su -c env - www-data | grep PATH
root# su -c rrdtool - www-data
Q. The rrd files seem to get generated ok but I when I try and display the web page I get the error: clamsmtp-stats::error: rrd_graph(): 1
A. I believe that the error code 1 is returned from rrdtool when it can't find the directory for storing the image files. You should check that the image directory exists.
Q. The rrd files seem not to be generated and I get the error: clamsmtp-stats::error: rrd_graph(): 1
A. If you happen to use it for the first time, please try to clear the contents of the /var/lib/clamsmtp-stats/ directory and re-run the "First time run".
Copyright (C) 2007, Gergely Nagy & Tamas David
clamsmtp-stats is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Gergely Nagy - nagy.gergely at gnanet dot net - sysadmin with a little programming knowledge
Tamas David - david.tamas at phpheaven dot hu - enthusiastic php programer
Mark Lawrence - nomad at null dot net - the original author of amavis-stats
Dale Walsh - buildsmart at daleenterprise dot com - who continues amavis-stats