Simply mysql quota check
Hi there,
I'm setting up a new email server with Dovecot(2.2.9) and MySQL.
My Dovecot configuration:
#/etc/dovecot/conf.d/90-quota.conf service quota-warning { executable = script /usr/local/bin/quota-warning.sh user = dovecot unix_listener quota-warning { user = vmail } }
plugin { quota = maildir:User quota quota_warning = storage=95%% quota-warning 95 %u@%d quota_warning2 = storage=80%% quota-warning 80 %u@%d args = /etc/dovecot/dovecot-sql.conf.ext }
#/etc/dovecot/dovecot-sql.conf.ext
password_query =
SELECT username AS user, value AS password
FROM mailboxes WHERE username = '%n@%d'
user_query =
SELECT username, domain,
CONCAT('*:storage=', SUBSTRING_INDEX(quota, 'm', 1)*1048576) AS userdb_quota_rule
FROM mailboxes, domains WHERE mailboxes.username = '%n@%d'
AND domains.domain = '%d'
My idea is when a message is delivered, the dovecot to check quota in the mysql according to the value received in the "user_query" but he does not. It shows a value of 2GB that I don't know where it gets.
I execute a manual query in mysql to know the quota my test user and checked that are 5GB, but when I see the dovecot, it shows 2G.
SELECT username, domain, CONCAT('*:bytes=', SUBSTRING_INDEX(quota, 'm', 1)*1048576) AS userdb_quota_rule FROM mailboxes, domains WHERE mailboxes.username = 'junix@domain.com' AND domains.domain = 'domain.com'
+-------------------+----------------+--------------------+ | username | domain | userdb_quota_rule | +-------------------+----------------+--------------------+ | junix@domain.com | domain.com | *:bytes=5242880000 | +-------------------+----------------+--------------------+
$ sudo doveadm quota get -u junix Quota name Type Value Limit % User quota STORAGE 10 2097152 0 User quota MESSAGE 1 -
How would the setting to simply verify the quota of users as userdb_quota_rule this query?
BR,
Alfredo Jr.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Wed, 1 Oct 2014, Alfredo Saldanha wrote:
#/etc/dovecot/dovecot-sql.conf.ext password_query =
SELECT username AS user, value AS password
FROM mailboxes WHERE username = '%n@%d'user_query =
SELECT username, domain,
CONCAT('*:storage=', SUBSTRING_INDEX(quota, 'm', 1)*1048576) AS userdb_quota_rule
FROM mailboxes, domains WHERE mailboxes.username = '%n@%d'
AND domains.domain = '%d'My idea is when a message is delivered, the dovecot to check quota in the mysql according to the value received in the "user_query" but he does not. It shows a value of 2GB that I don't know where it gets.
I execute a manual query in mysql to know the quota my test user and checked that are 5GB, but when I see the dovecot, it shows 2G.
SELECT username, domain, CONCAT('*:bytes=', SUBSTRING_INDEX(quota, 'm', 1)*1048576) AS userdb_quota_rule FROM mailboxes, domains WHERE mailboxes.username = 'junix@domain.com' AND domains.domain = 'domain.com'
- your manual query uses '*:bytes=', whereas your conf uses '*:storage='.
- you return the value as userdb_quota_rule, but it must read quota_rule in the user_query. In the password_query fields are prefixed by userdb_ .
See http://wiki2.dovecot.org/Quota/Configuration
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUBVCzxqnz1H7kL/d9rAQIneAgAukcibxJoQdtwdmrxHbXmKgQsCG22itH5 9VSFGigiPjXg/F1hkj7jHC/xB5uh2M8ayMos+hPxaJkKC4AKYEZu1QEwXAX2qrvN DXt7uPZHLJSMtlWCVb5s6h+v6K3JnbWRrjI4CIfYqB8i8MHKBWei0K02QZcOUOfy KeD7lAIPRuZPnIEiWYREpalRMGeQzZ69SHEmhxDx7VFO5FanlHDxdCwmO7qHoJen ZuNpUWMf5i5czxcDhHjLdtGODv005LFDCXhj48SqI17WzD3mPjJegOCjym6RfKmU RT+PtKieBkzygT1YzvjJbHISFxJSryVg8c48tCb0FgjkNKWXq/KsPg== =wzY8 -----END PGP SIGNATURE-----
participants (2)
-
Alfredo Saldanha
-
Steffen Kaiser