domain quota dictionary

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

domain quota dictionary

Alex-567
Hi

I just configure dovecot with the second dictionary for the domain quota

dict {
   quotadict = mysql:/usr/local/etc/dovecot-quota.conf
   quota_domain = mysql:/usr/local/etc/dovecot-quota-domain.conf
}

plugin {
     quota = dict:user::proxy::quotadict
     quota2 = dict:domain:%d:proxy::quota_domain
}

and the dovecot-quota-domain.conf looks like this :

connect = host=xxx dbname=xxx user=xxxx password=xxxx
map {
     pattern = priv/quota/storage
     table = domain_quota
     username_field = domain
     value_field = used_quota
}

map {
   pattern = priv/quota/messages
   table = domain_quota
   username_field = domain
   value_field = messages
}

The problem is that the dictionary table gets updated only with the
first mailbox informations (quota and messages for the first mailbox
within domain that is accessed). I suppose that have something to do
with the pattern but I can't find any docs for what the pattern must
look in the case of a domain quota dictionary.
Can anybody help me with a working example or some docs.

Alex
Reply | Threaded
Open this post in threaded view
|

Re: domain quota dictionary

Alex-567
At least can anyone explain what is the "pattern" from the map definition.

On 07/14/2010 01:38 PM, alex wrote:

> Hi
>
> I just configure dovecot with the second dictionary for the domain quota
>
> dict {
> quotadict = mysql:/usr/local/etc/dovecot-quota.conf
> quota_domain = mysql:/usr/local/etc/dovecot-quota-domain.conf
> }
>
> plugin {
> quota = dict:user::proxy::quotadict
> quota2 = dict:domain:%d:proxy::quota_domain
> }
>
> and the dovecot-quota-domain.conf looks like this :
>
> connect = host=xxx dbname=xxx user=xxxx password=xxxx
> map {
> pattern = priv/quota/storage
> table = domain_quota
> username_field = domain
> value_field = used_quota
> }
>
> map {
> pattern = priv/quota/messages
> table = domain_quota
> username_field = domain
> value_field = messages
> }
>
> The problem is that the dictionary table gets updated only with the
> first mailbox informations (quota and messages for the first mailbox
> within domain that is accessed). I suppose that have something to do
> with the pattern but I can't find any docs for what the pattern must
> look in the case of a domain quota dictionary.
> Can anybody help me with a working example or some docs.
>
> Alex

Reply | Threaded
Open this post in threaded view
|

Re: domain quota dictionary

Timo Sirainen
In reply to this post by Alex-567
On Wed, 2010-07-14 at 13:38 +0300, alex wrote:

> and the dovecot-quota-domain.conf looks like this :

Looks ok.

> The problem is that the dictionary table gets updated only with the
> first mailbox informations (quota and messages for the first mailbox
> within domain that is accessed).

What exactly do you mean by this? That the initial quota is calculated
only from the first user that accesses it? Yes, that's expected. The
domain quota support is somewhat of a hack right now, and initial quota
calculation or quota recalculation isn't possible easily.

Or do you mean that even when other users later do changes, the domain
quota won't be updated?

Reply | Threaded
Open this post in threaded view
|

Re: domain quota dictionary

Alex-567
On 07/14/2010 05:20 PM, Timo Sirainen wrote:

> On Wed, 2010-07-14 at 13:38 +0300, alex wrote:
>
>> and the dovecot-quota-domain.conf looks like this :
>
> Looks ok.
>
>> The problem is that the dictionary table gets updated only with the
>> first mailbox informations (quota and messages for the first mailbox
>> within domain that is accessed).
>
> What exactly do you mean by this? That the initial quota is calculated
> only from the first user that accesses it? Yes, that's expected. The
> domain quota support is somewhat of a hack right now, and initial quota
> calculation or quota recalculation isn't possible easily.
>
> Or do you mean that even when other users later do changes, the domain
> quota won't be updated?
>
That exact : other users don't trigger domain quota modification.
This is how I reproduce this behavior :

- clear both tables :
delete from domain_quota where domain like '%example.com';
delete from quota where email like '%example.com';

- login with the first user

select * from quota where email like '%example.com';
+-------------------+------------+----------+---------------------+
| email             | used_quota | messages | last_update         |
+-------------------+------------+----------+---------------------+
| [hidden email]    |  123996992 |    21820 | 2010-07-14 17:33:26 |
+-------------------+------------+----------+---------------------+

select * from domain_quota where domain like '%example.com';
+----------------+------------+----------+---------------------+
| domain         | used_quota | messages | last_update         |
+----------------+------------+----------+---------------------+
| example.com |  123996992 |    21820 | 2010-07-14 17:33:03 |
+----------------+------------+----------+---------------------+

..so far so good

- login with the second user

select * from quota where email like '%example.com';
+---------------------+------------+----------+---------------------+
| email               | used_quota | messages | last_update         |
+---------------------+------------+----------+---------------------+
| [hidden email]      |  123996992 |    21820 | 2010-07-14 17:33:26 |
| [hidden email]    |    1798426 |        2 | 2010-07-14 17:33:58 |
+---------------------+------------+----------+---------------------+

select * from domain_quota where domain like '%example.com';
+----------------+------------+----------+---------------------+
| domain         | used_quota | messages | last_update         |
+----------------+------------+----------+---------------------+
| example.com |  123996992 |    21820 | 2010-07-14 17:33:03 |
+----------------+------------+----------+---------------------+

..domain quota usage is unchange and messages the same.  
Reply | Threaded
Open this post in threaded view
|

Re: domain quota dictionary

Timo Sirainen
On Wed, 2010-07-14 at 17:42 +0300, alex wrote:
> - login with the first user
..
> ..so far so good
>
> - login with the second user
>
> ..domain quota usage is unchange and messages the same.  

A login doesn't change quota (the first login recalculates it, because
there is no row in dict). What if the second user saves new mails or
expunges mails? That should change quota.


Reply | Threaded
Open this post in threaded view
|

Re: domain quota dictionary

Alex-567
On 07/14/2010 05:55 PM, Timo Sirainen wrote:

> On Wed, 2010-07-14 at 17:42 +0300, alex wrote:
>> - login with the first user
> ..
>> ..so far so good
>>
>> - login with the second user
>>
>> ..domain quota usage is unchange and messages the same.  
>
> A login doesn't change quota (the first login recalculates it, because
> there is no row in dict). What if the second user saves new mails or
> expunges mails? That should change quota.
>
>
Ok, I have send a mail to the second user:

select * from domain_quota where domain like '%example.com';
+----------------+------------+----------+---------------------+
| domain         | used_quota | messages | last_update         |
+----------------+------------+----------+---------------------+
| example.com    |  124042046 |    21831 | 2010-07-14 17:57:37 |
+----------------+------------+----------+---------------------+

select * from quota where email like '%example.com';
+---------------------+------------+----------+---------------------+
| email               | used_quota | messages | last_update         |
+---------------------+------------+----------+---------------------+
| [hidden email]      |  124038256 |    21830 | 2010-07-14 17:56:03 |
| [hidden email]    |    1802216 |        3 | 2010-07-14 17:57:37 |
+---------------------+------------+----------+---------------------+

The domain_quota is updated only with the new message. The two messages
and sizes, that already exists are not added to the domain quota.
Reply | Threaded
Open this post in threaded view
|

Re: domain quota dictionary

Timo Sirainen
On Wed, 2010-07-14 at 18:07 +0300, alex wrote:

> The domain_quota is updated only with the new message. The two messages
> and sizes, that already exists are not added to the domain quota.

Yes, that's what I tried to say in my previous mail. There is no easy
(automatic) way to initialize or recalculate domain quota.


Reply | Threaded
Open this post in threaded view
|

Re: domain quota dictionary

Alex-567
On 07/14/2010 06:22 PM, Timo Sirainen wrote:
> On Wed, 2010-07-14 at 18:07 +0300, alex wrote:
>
>> The domain_quota is updated only with the new message. The two messages
>> and sizes, that already exists are not added to the domain quota.
>
> Yes, that's what I tried to say in my previous mail. There is no easy
> (automatic) way to initialize or recalculate domain quota.
>
>
Thanks Timo

What will be the hard way?
A quick and nasty fix, I think, will be to do a cron script to sum sizes
and messages for every user in a domain and update the domain quota table.
Do you have another solution?

Regards
Alex
Reply | Threaded
Open this post in threaded view
|

Re: domain quota dictionary

Timo Sirainen
On Wed, 2010-07-14 at 18:29 +0300, alex wrote:
> > Yes, that's what I tried to say in my previous mail. There is no easy
> > (automatic) way to initialize or recalculate domain quota.
> >
> >
> Thanks Timo
>
> What will be the hard way?
> A quick and nasty fix, I think, will be to do a cron script to sum sizes
> and messages for every user in a domain and update the domain quota table.

Something like that, yes.

> Do you have another solution?

With v2.0 you could script it more easily with the output of:

doveadm -f tab quota get -u '*@domain.org'