Difference between revisions of "Email Statistics"

From SME Server
Jump to navigationJump to search
(Update for new version)
Line 22: Line 22:
 
'''WARNING''': Make sure that these files are accessible before executing the above commands!  If you are unable to access http://mirror.contribs.org/smeserver/contribs/bread/mailstats/ the above commands will create empty files, overwriting existing versions.
 
'''WARNING''': Make sure that these files are accessible before executing the above commands!  If you are unable to access http://mirror.contribs.org/smeserver/contribs/bread/mailstats/ the above commands will create empty files, overwriting existing versions.
  
=====Change Email Recipient=====
+
=====Configuration=====
The email recipient is specified in the spamfilter-stats-7.pl file, currently (v0.6.11) at line 108, using:
+
The latest release (v0.6.15) supports several SME database options:
 +
* Status
 +
config setprop mailstatus Status ("enabled"|"disabled")
 +
* Column Headings (enable, supress or only show if nonzero)
 +
config setprop mailstats <column header> ("yes"|"no"|"auto")
 +
* QpsmtpCodes
 +
config setprop mailstats QpsmtpdCodes ("enabled"|"disabled")
 +
* SpamAssassin Rules
 +
config setprop mailstats SARules ("enabled"|"disabled")
 +
* JunkMailList
 +
config setprop mailstats JunkMailList  ("enabled"|"disabled")
 +
* SpamAssassin Rule Percent Threshold for report cutoff
 +
config setprop mailstats SARulePercentThreshold (0.5)
 +
* Email to send report
 +
config setprop mailstats Email (admin) - email to send report
 +
 
 +
In older versions, the email recipient is specified in the spamfilter-stats-7.pl file, using:
 
   $opt{'mail'}    = "admin";
 
   $opt{'mail'}    = "admin";
 
which will deliver email to the local 'admin' account on your SME server.  Configure email forwarding in server-manager::Collaboration::Users::admin to deliver the emails to another location.
 
which will deliver email to the local 'admin' account on your SME server.  Configure email forwarding in server-manager::Collaboration::Users::admin to deliver the emails to another location.

Revision as of 15:06, 10 October 2007

Email Statistics

How to get statistics about the performance of your mail server

Built-In Statistical Reports

Server-Manager

Some email statistics can be seen from server-manager under "Administration", "Mail log file analysis"

qplogsumm.pl

SME 7.2 and later include the 'logterse' plugin to qpsmtpd as well as the 'qplogsumm.pl' statistics script. 'qplogsumm.pl' updates /var/log/qpsmtpd/state with per-plugin statistics for any qpsmtpd plugin that appears in a qpsmtpd logterse entry each time the qpsmtpd log is rotated.

Normally, SME conceals the /var/log/???/state files from 'View log files' in the server-manager. You can expose /var/log/qpsmtpd/state using the instructions shown here: http://bugs.contribs.org/process_bug.cgi

Contribs & Addons

Brian Read's spamfilter-stats-7.pl

Brian Read's mailstats.pl script analyzes your qpsmtpd log files and sends a daily email to "admin" summarizing that day's email activity.

Download & Installation
wget -O /etc/cron.d/mailstats.cron \
http://mirror.contribs.org/smeserver/contribs/bread/mailstats/mailstats.cron
wget -O /usr/bin/spamfilter-stats-7.pl \
http://mirror.contribs.org/smeserver/contribs/bread/mailstats/spamfilter-stats-7.pl

WARNING: Make sure that these files are accessible before executing the above commands! If you are unable to access http://mirror.contribs.org/smeserver/contribs/bread/mailstats/ the above commands will create empty files, overwriting existing versions.

Configuration

The latest release (v0.6.15) supports several SME database options:

  • Status
config setprop mailstatus Status ("enabled"|"disabled")
  • Column Headings (enable, supress or only show if nonzero)
config setprop mailstats <column header> ("yes"|"no"|"auto")
  • QpsmtpCodes
config setprop mailstats QpsmtpdCodes ("enabled"|"disabled")
  • SpamAssassin Rules
config setprop mailstats SARules ("enabled"|"disabled")
  • JunkMailList
config setprop mailstats JunkMailList  ("enabled"|"disabled")
  • SpamAssassin Rule Percent Threshold for report cutoff
config setprop mailstats SARulePercentThreshold (0.5)
  • Email to send report
config setprop mailstats Email (admin) - email to send report

In older versions, the email recipient is specified in the spamfilter-stats-7.pl file, using:

 $opt{'mail'}     = "admin";

which will deliver email to the local 'admin' account on your SME server. Configure email forwarding in server-manager::Collaboration::Users::admin to deliver the emails to another location.

Handling @*.u Logfiles

Multilog occasionally generates log files that end in ".u" instead of ".s". The multilog manual says this:

  • .s: This file is completely processed and safely written to disk.
  • .u: This file was being created at the moment of an outage. It may have been truncated. It has not been processed.

While these files should not be generated under normal circumstances, they are (as attested by personal experience, forum posts and bug reports). In order to include these files when reporting email statistics, you will need to modify /etc/cron.d/mailstats.cron by changing

0    0   *    *   *    root    perl /usr/bin/spamfilter-stats-7.pl /var/log/qpsmtpd/*.s /var/log/qpsmtpd/current

to

0    0   *    *   *    root    perl /usr/bin/spamfilter-stats-7.pl /var/log/qpsmtpd/*.[us] /var/log/qpsmtpd/current

or

0    0   *    *   *    root    perl /usr/bin/spamfilter-stats-7.pl /var/log/qpsmtpd/@* /var/log/qpsmtpd/current

qplogtail

qplogtail is a script intended to help monitor /var/log/qpsmtpd/current and extract a concise but meaningful display of what the server is up to.

qplogtail extracts 5 kinds of information:

  1. Normal connections:
    28545 Accepted connection 4/30 from 86.139.2.73 ...
  2. Errors in violation of Instances:
    5146 Too many connections: 40 >= 40. Waiting one second.
  3. Errors in violation of InstancesPerIP:
    5320 hosts_allow plugin: Too many connections from 212.100.229.201: 6 > 5Denying connection.
  4. Messages blocked by any qpsmtpd plugin:
    15751 logging::logterse plugin: ` 82.210.181.241 241-pra-6.acn.waw.pl 241-pra-6.acn.waw.pl <Glasteinzhza@ask-it-here.com> dnsbl 903 http://www.spamhaus.org/query/bl?ip=82.210.181.241 msg denied before queued
  5. Messages queued for delivery:
    15587 logging::logterse plugin: ` 128.220.32.40 miami.deuvis.com miami.deuvis.com <aapple@deuvis.com> <c.wolf@ncxr.org> queued <200709270344.l8R3iq0b010299@deuvis.com> No, hits=-2.6 required=5.0_

Each smtp transaction will generate two lines of output containing:

msgid   remote_ip   x/40
msgid   remote_ip   dispostion   details

Sample output:

# qplogtail
14185   213.37.31.24    dnsbl   msg denied before queued
14262   64.233.184.243  1/40
14262   64.233.184.243  queued  No, hits=-101.1 required=5.0_
14320   71.8.114.81     1/40
14320   71.8.114.81     dnsbl   msg denied before queued
14349   200.63.233.145  1/40
14349   200.63.233.145  dnsbl   msg denied before queued

To install:

cd /usr/local/bin
wget -O qplogtail http://bugs.contribs.org/attachment.cgi?id=1379
chmod 755 qplogtail

To run:

qplogtail


Direct comments or questions to Bugzilla:3418