Quota warnings

Leon Kolchinsky leonk at construct.haifa.ac.il
Mon Jan 15 05:48:36 EST 2007


> Hello!
> I run a Cyrus IMAP server v2.3.7 and I've set this in imapd.conf:
> 
> quotawarn: 80
> enable_quota_warnings: yes
> 
> This seems to work fine with IMAP clients, but when someone use MS
> Outlook or Outlook Express and poll mail with POP3, there's no quota
> warning showing up.
> 
> Is there some way to fix this? Perhaps the server generates a mail in
> the inbox for the users, so POP clients also get warned.
> --
> 
> Anders Norrbring
> Norrbring Consulting
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/x-pkcs7-signature
> Size: 3241 bytes
> Desc: S/MIME Cryptographic Signature
> Url : http://lists.andrew.cmu.edu/pipermail/info-
> cyrus/attachments/20070113/97c62e46/smime.bin


Hi,

Below is a reference I've made a while ago, when configuring quota warnings
on my system. Use it on your own system with proper adjustments.

You'll have to at least change this "102400" value in quota.pl file (to
reflect proper default quota on your system and get right results - list of
users with a non-standard quota set):

  if (($quota > 102400)) { # check the Kb non std. accounts have above the
default quota
    $chargable=$quota - 102400;
    print ACCOUNTING "$user, $chargable, $date\n";
  }

The beauty of this configuration is that it works for both IMAP and POP3
users, and adds blocking feature (till the next run of the script in case
user fixed the overquota problem) on the MTA level for users that have an
overquota usage.



*************************************************
Quota system configuration (check,warn,block & release):
1) 
# cd /usr/lib/cyrus 
# mkdir quota
# cd quota/
# touch mailwarn.message
# touch mailfull.message
# touch quotas.tmp

Now copy quota.pl to /usr/lib/cyrus/quota

# chmod u+x quota.pl

after the first run of quota.pl

# cd /usr/lib/cyrus/quota 
# chown cyrus quotas.tmp


2) vi mailfull.message:
Dear user,

your mailbox is full!

Sincerely,
your administrator

3) vi mailwarn.message
Dear user,

your mailbox is almost full!

Sincerely,
your administrator

4) vi quota.pl:
change the # The From: line will need customizing.
change all mydomain.ac.il.... to your domainname
change the 102400 (100MB) to the default for almost all users.

5) 

a) create mailboxfull file in /etc/postfix directory and make a cronjob:

crontab -e (as root):
*/30 * * * * /usr/lib/cyrus/quota/quota.pl 

b) Add "check_recipient_access regexp:/etc/postfix/mailboxfull"
approximately to this location in main.cf:

smtpd_recipient_restrictions =
            permit_mynetworks,
            permit_sasl_authenticated,
            reject_unauth_destination,
            check_recipient_access regexp:/etc/postfix/mailboxfull,
            reject_invalid_hostname,
            reject_non_fqdn_sender,
            reject_non_fqdn_recipient,
            reject_unknown_sender_domain,
            reject_unknown_recipient_domain,

c) PLEASE NOTE:
If you want to nullify the counters (and repopulate them with the updated
data), you should delete these
2 files alltogether: quotafull.dat, quota.log

NOTE THAT: 
quota.log - when and to whom the warning has been sent with the description
of the occasion 
(full or nearly full mailboxes)
quotafull.dat - the list of e-mails warnings have been sent to
account.log - the list of accounts with quota more than the default one
quotas.tmp - temp file with usage statistics of all mailboxes

6) Now you can check, and may be even put symbolic link to the web:
a) # Log file of all the mailboxes we are interested in
/usr/lib/cyrus/quota/quota.log

b) # Store the clients who are using more than the std quota
/usr/lib/cyrus/quota/account.log

for list of users with quota bigger than default (100MB) - as mentioned in
4.) and how much more their quota than the default.


WEB INTERFACE TO SHOW THE QUOTAS:
------------------------------
1) In the Apache:
vi /etc/apache2/default-server.conf (add these lines):
#
# Configure http://mydomain.ac.il/quota/
#
<Directory "/srv/www/htdocs/quota">
    AddDefaultCharset Off
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
2)
# mkdir /srv/www/htdocs/quota

Make symbolic links to the data files in /srv/www/htdocs/quota/:
# ln -s /usr/lib/cyrus/quota/account.log account.txt
# ln -s /usr/lib/cyrus/quota/quota.log quota.txt
# ln -s /etc/postfix/mailboxfull mailboxfull.txt

Make the index file for /srv/www/htdocs/quota/ directory:
# vi /srv/www/htdocs/quota/index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<title>This page is for administrator eyes only</title>
</head>

<body>
<p>
The list of all accounts using more quota than the default accounts (and
number of KB it exceeds the default)<br/>
<a href="account.txt">account.txt</a> </p>
<p>
When and to whom the warning has been sent with the description of the
occasion (full or nearly full mailboxes): <br/>
<a href="quota.txt">quota.txt</a> </p>
<p>
The list of full mailboxes (which are blocked for now): <br/>
<a href="mailboxfull.txt">mailboxfull.txt</a> </p>

</body>
</html>

--------------------------------

Go to http://mydomain.ac.il/quota/

***************************************************************

Enjoy.


Best Regards,
Leon Kolchinsky
-------------- next part --------------
A non-text attachment was scrubbed...
Name: quota.pl
Type: application/octet-stream
Size: 7539 bytes
Desc: not available
Url : http://lists.andrew.cmu.edu/pipermail/info-cyrus/attachments/20070115/612b918a/quota-0001.obj


More information about the Info-cyrus mailing list