View Single Post
Old 19th September 2012, 18:11
m.naumann m.naumann is offline
Junior Member
Join Date: Sep 2012
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts

So my installation is done, following Falko's great how-to to the point.

I've created a mail domain, and a mail user on this domain. I've used an e-mail client on another computer to connect to this servers' IMAP and Submission ports, and have sent and received e-mail, amounting to several megabytes of mail traffic on both protocols / ports.

Then I checked the mail traffic statistics for this user on ISPConfig's web interface. It listed 0. Which is understandable, since, most likely, these statistics are not updated real-time but by a regularly running cronjob.

So I looked at the newly configured system and found (running
crontab -l
as root) a daily (or rather nightly, running at 00:30 by default) ISPConfig cron job which runs this file:
This PHP script imports the servers' ISPConfig related configuration and some helper classes (such as for structured databases access). After that, it contains multiple sections which each start with a comment. The first such section is
// store the mailbox statistics in the database
The code in this section searches all mail users' maildir locations for a file called
Example for mail account someuser@domain.tld:
So for each user, if ispconfig_mailsize exists, it renames it to "ispconfig_mailsize_save" then reads the file line by line, type casting each line to integer, and summing them up. It then add this value to any traffic previously recorded for this user (and stored in the mysql database, in table "mail_traffic") during the running month, if any, and stores this new value in the database

For each user where ispconfig_mailsize does not exist, nothing is done.

In my case, no such file exists (after sending large e-mails with file attachments in and out).

There are other sections in this file, labelled as follows:
// Create webalizer statistics
// Create awstats statistics
// Make the web logfiles directories world readable to enable ftp access
// Manage and compress web logfiles and create traffic statistics
// Rotate the ispconfig.log file
// Cleanup website tmp directories
// Cleanup logs in master database (only the "master-server")
// enforce traffic quota (run only on the "master-server")
// deactivate virtual servers (run only on the "master-server")
// Create website backups
None of these seem to refer to mail traffic accounting.

So what's the mechanism which creates the "ispconfig_mailsize" files in the first place?
# rgrep 'ispconfig_mailsize' /usr/local/
/usr/local/ispconfig/server/plugins-available/			// if(is_file($data['old']['maildir'].'.ispconfig_mailsize'))exec('mv -f '.escapeshellcmd($data['old']['maildir']).'.ispconfig_mailsize '.escapeshellcmd($data['new']['maildir']));
/usr/local/ispconfig/server/cron_daily.php:	if(@is_file($rec['maildir'].'/ispconfig_mailsize')) {
/usr/local/ispconfig/server/cron_daily.php:		rename($rec['maildir'].'/ispconfig_mailsize',$rec['maildir'].'/ispconfig_mailsize_save');
/usr/local/ispconfig/server/cron_daily.php:		$lines = file($rec['maildir'].'/ispconfig_mailsize_save');
/usr/local/ispconfig/server/cron_daily.php:		if(@is_file($rec['maildir'].'/ispconfig_mailsize_save')) unlink($rec['maildir'].'/ispconfig_mailsize_save');
/usr/local/ispconfig/server/plugins-enabled/			// if(is_file($data['old']['maildir'].'.ispconfig_mailsize'))exec('mv -f '.escapeshellcmd($data['old']['maildir']).'.ispconfig_mailsize '.escapeshellcmd($data['new']['maildir']));
/usr/local/ispconfig/server/plugins-available/ is a symbolic link to /usr/local/ispconfig/server/plugins-enabled/ which only contains one reference to this filename, but the line is commented out.
/usr/local/ispconfig/server/cron_daily.php is the file we already discussed above, it does not create these files either.

Maybe the file is created by Dovecot or some other daemon, based on modifications ISPConfig may have made to their configuration files during installation?
# rgrep 'ispconfig_mailsize' /etc/
grep: /etc/fonts/conf.d/30-defoma.conf: No such file or directory
Apparently that's not the case either. Maybe it's somewhere next to the mail storage:
# rgrep 'ispconfig_mailsize' /var/vmail/
/var/vmail/.mailfilter:`echo $SIZE >> /var/vmail/$HOST/$USER/ispconfig_mailsize`
Aha, so this is something. So some searching on the web will tell you that maildrop is a mail filter/mail delivery agent, which comes with the Courier MTA by default, but can also be used standalone, as well as in combination with Dovecot:

Is maildrop packaged for Debian 6?
# apt-cache search maildrop
courier-maildrop - Courier mail server - mail delivery agent
getmail4 - mail retriever with support for POP3, IMAP4 and SDPS
maildrop - mail delivery agent with filtering abilities
rdeliver - A fully functioning mail filter with RubyFilter
sensible-mda - Mail Delivery Agent wrapper
spamprobe - Bayesian spam filter
OK, there are both the Courier one and a standalone maildrop package. Are any of these installed (and hopefully configured, too) now that I followed Falko's how-to?
# dpkg -l maildrop courier-maildrop
No packages found matching maildrop.
No packages found matching courier-maildrop.
Hmm, no. Maybe another installed package provides the "maildrop" command?
# which maildrop
Apparently not.

So I'm not sure how mail (IMAP4r2, POP3, SMTP via Submission port) traffic accounting could work with this setup. Could you please elaborate, Falko? Did I miss something obvious (or not so obvious)?

Thank you very much in advance.

Last edited by m.naumann; 20th September 2012 at 14:21. Reason: Re-reading my post, I realise it may have sounded a bit demanding or challenging - this wasn't intended - sorry about it!
Reply With Quote