Re: Dovecot domain quota

2014-10-13 Thread Jiri Bourek

On 13.10.2014 00:08, Gedalya wrote:

On 10/12/2014 01:28 PM, Filip Bartmann wrote:

After running `doveadm quota recalc -A` I have in my db:
---
+---++--+
| domain| bytes  | messages |
+---++--+
| debian.jd | 505758 |   81 |
+---++--+
---
whith is from accountbartm...@debian.jd  not both accounts at testing
VPS domain debian.jd. The same is with quota enforcing - quota if
enforced on the latter of the accounts in /etc/dovecot/users on
testing machine or database in production machine.

What I do wrong?

As I remember from previous conversations here, this is a limitation of
the current design.


I remember the same thing.


As a hack: you can just not run quota recalc ;-) or more realistically,
separately track user quotas individually (you really should!), and post
recalc immediately update the domain by running something like
update domain_quota set bytes=(select sum(bytes) from user_quota where
username like '%@debian.jd') where domain='debian.jd';


This won't accout for changes made during the recalc - although to my 
knowledge it's still the best solution in this type of configuration.


When I was trying to make both user and domain quotas work properly, the 
only way I figured out was to track domain quota as group quota in the 
filesystem. Forcing users/domains to have separate system user and group 
of course.


Re: Dovecot domain quota

2014-10-13 Thread Gedalya

On 10/13/2014 04:47 AM, Jiri Bourek wrote:

As a hack: you can just not run quota recalc ;-) or more realistically,
separately track user quotas individually (you really should!), and post
recalc immediately update the domain by running something like
update domain_quota set bytes=(select sum(bytes) from user_quota where
username like '%@debian.jd') where domain='debian.jd';


This won't accout for changes made during the recalc - although to my 
knowledge it's still the best solution in this type of configuration. 
We're talking about making the domain quota equal to the sum of the user 
quotas, using a single SQL statement. After execution of this statement, 
the domain quota will be correct, assuming that the user quotas are 
correct. If recalc doesn't account for changes done during the recalc, 
then that's a bug.


Re: Dovecot domain quota

2014-10-13 Thread Jiri Bourek

On 13.10.2014 11:11, Gedalya wrote:

On 10/13/2014 04:47 AM, Jiri Bourek wrote:

As a hack: you can just not run quota recalc ;-) or more realistically,
separately track user quotas individually (you really should!), and post
recalc immediately update the domain by running something like
update domain_quota set bytes=(select sum(bytes) from user_quota where
username like '%@debian.jd') where domain='debian.jd';


This won't accout for changes made during the recalc - although to my
knowledge it's still the best solution in this type of configuration.

We're talking about making the domain quota equal to the sum of the user
quotas, using a single SQL statement. After execution of this statement,
the domain quota will be correct, assuming that the user quotas are
correct. If recalc doesn't account for changes done during the recalc,
then that's a bug.


Well if I understand OP's configuration correctly, his Dovecot is not 
using per-user quotas, which means that when recalc finishes for a 
mailbox, nothing is updating information about that mailbox. I don't 
think that's a bug in recalc, just defficiency in OP's setup.


Although after reading your post again I now understood you suggested to 
add per-user quotas into his Dovecot's config too. My bad, that could work.


Dovecot domain quota

2014-10-12 Thread Filip Bartmann
I have dovecot version 2.1.7 and I have quota configured as:
---
dict {
  quota_domain = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
}
mail_plugins = quota
protocol imap {
  mail_plugins = quota quota imap_quota
}
plugin {
  quota = dict:domain:%d:proxy::quota_domain
  quota_rule = *:storage=1M
  quota_rule2 = Trash:storage=+100M
}
---
/etc/dovecot/dovecot-dict-sql.conf.ext:
---
map {
  pattern = priv/quota/storage
  table = quota_dict
  username_field = domain
  value_field = bytes
}
map {
  pattern = priv/quota/messages
  table = quota_dict
  username_field = domain
  value_field = messages
}
map {
  pattern = shared/expire/$user/$mailbox
  table = expires
  value_field = expire_stamp
  fields {
username = $user
mailbox = $mailbox
  }
}
---
But the problem is that quota table created as:
---
 CREATE TABLE `quota_dict` (
  `domain` varchar(255) NOT NULL,
  `bytes` bigint(20) NOT NULL DEFAULT '0',
  `messages` int(5) NOT NULL DEFAULT '0',
  PRIMARY KEY (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
---
counts quota only for last user as defined /etc/dovecot/users or in database 
table.
So if I have in /etc/dovecot/users (the contents is from testing VPS):
---
t...@debian.jd:{plain}radegast:8:8::/srv/mail/debian.jd/::userdb_quota_rule=*:storage=500k
bartm...@debian.jd:{plain}radegast:8:8::/srv/mail/debian.jd/::userdb_quota_rule=*:storage=500k
---
After running `doveadm quota recalc -A` I have in my db:
---
+---++--+
| domain| bytes  | messages |
+---++--+
| debian.jd | 505758 |   81 |
+---++--+
---
whith is from account bartm...@debian.jd not both accounts at testing VPS 
domain debian.jd. The same is with quota enforcing - quota if enforced on the 
latter of the accounts in /etc/dovecot/users on testing machine or database in 
production machine.

What I do wrong?
Thanks
Filip Bartmann


Re: Dovecot domain quota

2014-10-12 Thread Robert Schetterer
Am 12.10.2014 um 19:28 schrieb Filip Bartmann:
 I have dovecot version 2.1.7 and I have quota configured as:
 ---
 dict {
   quota_domain = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
 }
 mail_plugins = quota
 protocol imap {
   mail_plugins = quota quota imap_quota
 }
 plugin {
   quota = dict:domain:%d:proxy::quota_domain
   quota_rule = *:storage=1M
   quota_rule2 = Trash:storage=+100M
 }
 ---
 /etc/dovecot/dovecot-dict-sql.conf.ext:
 ---
 map {
   pattern = priv/quota/storage
   table = quota_dict
   username_field = domain
   value_field = bytes
 }
 map {
   pattern = priv/quota/messages
   table = quota_dict
   username_field = domain
   value_field = messages
 }
 map {
   pattern = shared/expire/$user/$mailbox
   table = expires
   value_field = expire_stamp
   fields {
 username = $user
 mailbox = $mailbox
   }
 }
 ---
 But the problem is that quota table created as:
 ---
  CREATE TABLE `quota_dict` (
   `domain` varchar(255) NOT NULL,
   `bytes` bigint(20) NOT NULL DEFAULT '0',
   `messages` int(5) NOT NULL DEFAULT '0',
   PRIMARY KEY (`domain`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
 ---
 counts quota only for last user as defined /etc/dovecot/users or in database 
 table.
 So if I have in /etc/dovecot/users (the contents is from testing VPS):
 ---
 t...@debian.jd:{plain}radegast:8:8::/srv/mail/debian.jd/::userdb_quota_rule=*:storage=500k
 bartm...@debian.jd:{plain}radegast:8:8::/srv/mail/debian.jd/::userdb_quota_rule=*:storage=500k
 ---
 After running `doveadm quota recalc -A` I have in my db:
 ---
 +---++--+
 | domain| bytes  | messages |
 +---++--+
 | debian.jd | 505758 |   81 |
 +---++--+
 ---
 whith is from account bartm...@debian.jd not both accounts at testing VPS 
 domain debian.jd. The same is with quota enforcing - quota if enforced on the 
 latter of the accounts in /etc/dovecot/users on testing machine or database 
 in production machine.
 
 What I do wrong?
 Thanks
 Filip Bartmann
 

domain quota may be tricky

never tested but perhaps reread

http://serverstutorial.wordpress.com/2012/12/28/configuring-domain-user-mailbox-quotas-in-dovecot-via-postfixadmin-on-ubuntu-12-04lts/

http://wiki2.dovecot.org/Quota/Configuration

Best Regards
MfG Robert Schetterer

-- 
[*] sys4 AG

http://sys4.de, +49 (89) 30 90 46 64
Franziskanerstraße 15, 81669 München

Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Marc Schiffbauer
Aufsichtsratsvorsitzender: Florian Kirstein


Re: Dovecot domain quota

2014-10-12 Thread Gedalya

On 10/12/2014 01:28 PM, Filip Bartmann wrote:

After running `doveadm quota recalc -A` I have in my db:
---
+---++--+
| domain| bytes  | messages |
+---++--+
| debian.jd | 505758 |   81 |
+---++--+
---
whith is from accountbartm...@debian.jd  not both accounts at testing VPS 
domain debian.jd. The same is with quota enforcing - quota if enforced on the 
latter of the accounts in /etc/dovecot/users on testing machine or database in 
production machine.

What I do wrong?
As I remember from previous conversations here, this is a limitation of 
the current design.

The comment in example-config/conf.d/90-quota.conf says:
# Multiple quota roots are also possible, for example this gives each user
# their own 100MB quota and one shared 1GB quota within the domain
It doesn't really support accounting for the *sum* of *multiple storage 
quotas* within a domain.
As a hack: you can just not run quota recalc ;-) or more realistically, 
separately track user quotas individually (you really should!), and post 
recalc immediately update the domain by running something like
update domain_quota set bytes=(select sum(bytes) from user_quota where 
username like '%@debian.jd') where domain='debian.jd';


Re: [Dovecot] domain quota in sql

2012-02-15 Thread Adam Szpakowski

On 15.02.2012 08:47, Robert Schetterer wrote:

Hi i am not sure what are trying to goal
with domain quota, if you setup your accounts i.e with postfixadmin etc
then its up to the gui logic , stopping postmasters to setup more
accounts ( with quotas ) as you ( the superadmin ) want.

My fault, I should add some big picture info.
We are using admin panel based on iRedMail Panel, and want to show quota 
usage on the domain level.

Quota enforcing is only on user level and this part works nicely.
What I need is to have in dbase live data which allows me to get quota 
usage on the domain level to show it in the admin panel.
The problem is, that this operation must not by db intensive. Getting 
entire db and the processing it with some script is fine for daily 
reports but not for live view.


My example with doveadm for quota recalc was only a way to show how the 
problem can be triggered. We are not using doveadm for this purpose.



For everything else user quotas usally are enough

thinkable maybe calculation of all users quotas in dict from one domain
in a sql postfix query table to stop deliver in more mail, but i dont
think this makes real sense
In future the quota enforcement on domain level could be a nice add-on, 
but for now it is not so important for us.


--
Adam Szpakowski


Re: [Dovecot] domain quota in sql

2012-02-15 Thread Robert Schetterer
Am 15.02.2012 09:07, schrieb Adam Szpakowski:
 On 15.02.2012 08:47, Robert Schetterer wrote:
 Hi i am not sure what are trying to goal
 with domain quota, if you setup your accounts i.e with postfixadmin etc
 then its up to the gui logic , stopping postmasters to setup more
 accounts ( with quotas ) as you ( the superadmin ) want.
 My fault, I should add some big picture info.
 We are using admin panel based on iRedMail Panel, and want to show quota
 usage on the domain level.
 Quota enforcing is only on user level and this part works nicely.
 What I need is to have in dbase live data which allows me to get quota
 usage on the domain level to show it in the admin panel.
 The problem is, that this operation must not by db intensive. Getting
 entire db and the processing it with some script is fine for daily
 reports but not for live view.

as workaround it should be possible to calculate filllevel
by domain with some bash script and cron sending  an info mail to you
might be not exact, but enough to see whats going on ( depends on your
real domain/mailbox setup...maildir etc)

i.e like
du -sch schetterer.org/
1,7Gschetterer.org/

or

du -sch schetterer.org/*
24K schetterer.org/@schetterer.org
431Mschetterer.org/...@schetterer.org
1,3Gschetterer.org/@schetterer.org
1,7Gsum

perhaps  the same works with getting it out from sql


 
 My example with doveadm for quota recalc was only a way to show how the
 problem can be triggered. We are not using doveadm for this purpose.
 
 For everything else user quotas usally are enough

 thinkable maybe calculation of all users quotas in dict from one domain
 in a sql postfix query table to stop deliver in more mail, but i dont
 think this makes real sense
 In future the quota enforcement on domain level could be a nice add-on,
 but for now it is not so important for us.
 


-- 
Best Regards

MfG Robert Schetterer

Germany/Munich/Bavaria


Re: [Dovecot] domain quota in sql

2012-02-15 Thread Adam Szpakowski

On 15.02.2012 09:19, Robert Schetterer wrote:

as workaround it should be possible to calculate filllevel
by domain with some bash script and cron sending  an info mail to you
might be not exact, but enough to see whats going on ( depends on your
real domain/mailbox setup...maildir etc)

[cut]
I'm affraid that this is not a viable option. It should be done quite 
often to achieve live data feel and the amount of I/O to do so on 
storage/filesystem level is staggering.


Good enough solution will be to have an additional column in db table 
with domain for each quota record. This will allow us to do something 
like this:


SELECT domain, sum(bytes) as sum_bytes, sum(messages) as sum_messages 
FROM used_quota GROUP BY domain


The missing domain info can be updated regularly via some cron script. 
This could be a workable solution.


--
Adam Szpakowski



Re: [Dovecot] domain quota in sql

2012-02-15 Thread Przemysław Orzechowski

Hi 
Im not an expert in Dovecot but what prohibits you adding a field to the
table 
Dovecot will not use it thats all 
Im not sure what version of database You are using but postgres,oracle and
never versions of mysql have something called views (could be used to hide
the additional column from dovecot if necessary) and as far as i remember
triggers that could be launched on insert, update to populate that
additional column
Other solution (not sure if applicable for Your needs) is to enable file
system quota without actually setting up any quotas/group quotas (all users
from single domain must belong to same group tho) this allows quick disk
usage check without excess disk io

On Wed, 15 Feb 2012 09:07:04 +0100, Adam Szpakowski a...@3a.pl wrote:
 On 15.02.2012 08:47, Robert Schetterer wrote:
 Hi i am not sure what are trying to goal
 with domain quota, if you setup your accounts i.e with postfixadmin etc
 then its up to the gui logic , stopping postmasters to setup more
 accounts ( with quotas ) as you ( the superadmin ) want.
 My fault, I should add some big picture info.
 We are using admin panel based on iRedMail Panel, and want to show quota

 usage on the domain level.
 Quota enforcing is only on user level and this part works nicely.
 What I need is to have in dbase live data which allows me to get quota 
 usage on the domain level to show it in the admin panel.
 The problem is, that this operation must not by db intensive. Getting 
 entire db and the processing it with some script is fine for daily 
 reports but not for live view.
 
 My example with doveadm for quota recalc was only a way to show how the 
 problem can be triggered. We are not using doveadm for this purpose.
 
 For everything else user quotas usally are enough

 thinkable maybe calculation of all users quotas in dict from one domain
 in a sql postfix query table to stop deliver in more mail, but i dont
 think this makes real sense
 In future the quota enforcement on domain level could be a nice add-on, 
 but for now it is not so important for us.

-- 
Pozdrawiam,

Przemysław Orzechowski

Administrator Sieci/Network Administrator

e: przemek.orzechow...@makolab.net

t:   +48 42 683 74 96

MakoLab S.A.

ul. Demokratyczna 46, 93-430 Łódź
www.makolab.pl

Spółka zarejestrowana w Krajowym Rejestrze Sądowym przez Sąd Rejonowy
dla Łodzi - Śródmieścia w Łodzi XX Wydział Krajowego Rejestru Sądowego
pod numerem KRS 289179. Wysokość kapitału zakładowego wynosi 707 473
PLN. Kapitał zakładowy został wpłacony w całości. NIP 7250015526, REGON
471343117

Wiadomość ta jest przeznaczona jedynie dla osoby lub podmiotu będącego
jej adresatem i może zawierać poufne lub uprzywilejowane informacje.
Zakazane jest przeglądanie, przesyłanie, rozpowszechnianie lub inne
wykorzystywanie tych informacji, jak również podejmowanie działań na ich
podstawie, przez osoby lub podmioty inne niż zamierzony adresat. Jeśli
otrzymali Państwo tę wiadomość przez pomyłkę, prosimy o poinformowanie
nadawcy i usunięcie jej z komputera.

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. 
If you received this in error, please notify the sender and delete the
material from your computer.


Re: [Dovecot] domain quota in sql

2012-02-15 Thread Timo Sirainen
On Wed, 2012-02-15 at 08:26 +0100, Adam Szpakowski wrote:
 On 15.02.2012 02:55, Timo Sirainen wrote:
  On 15.2.2012, at 3.54, Timo Sirainen wrote:
 
  Domain-quota support in Dovecot is only partial. Recalculating domain 
  quota would require more code. Last time when someone asked about this I 
  wasn't even sure how it could be implemented, but nowadays it actually 
  would be possible to do with:
  Oh, and you could actually already do this with a doveadm script:
 [cut]
 I'm using something like this, but directly on the dbase level. 
 Unfortunately such operation is quite db intensive, so I'm looking for a 
 simpler solution.

Isn't it basically one table scan? To do UPDATE .. WHERE username = '%
@domain'

 Is there a way to add domainname as another collumn in dbase? This will 
 simplify the SQL query and the GROUP BY could be used.

Not currently. Perhaps for v2.2 dict-sql redesign.

  Of course it would be nice if Dovecot internally supported this.
 I was under impression, that dovecot does support this. In examples one 
 can see:
 
 /usr/share/doc/dovecot-core/example-config/conf.d/90-quota.conf
..
 Also on dovecot2 wiki we can see (http://wiki2.dovecot.org/Quota/Dict):

Well, yeah, it kind of works, but not 100% :) Anyway, why is the rescan
a problem anyway? Does your domain quota value keep breaking? In normal
operation it should work fine.



Re: [Dovecot] domain quota in sql

2012-02-15 Thread Adam Szpakowski

On 15.02.2012 14:05, Timo Sirainen wrote:

Is there a way to add domainname as another collumn in dbase? This will
simplify the SQL query and the GROUP BY could be used.

Not currently. Perhaps for v2.2 dict-sql redesign.

It will be great feature.

Well, yeah, it kind of works, but not 100% :) Anyway, why is the rescan
a problem anyway? Does your domain quota value keep breaking? In normal
operation it should work fine.
Domain quota gathering based on config examples works funny. Its the 
best description I can get (yes, very descriptive ;) ).
There are both entries for users (user@domain) and domains. It is not 
making sense for me, so I'm assuming that its the missing percentage of 
the working part ;)


Tu sum-up the thread. I went for updating periodically the basic quota 
table with missing domain names. Working great.

Thanks all for suggestions.
--
Adam Szpakowski


[Dovecot] domain quota in sql

2012-02-14 Thread Adam Szpakowski

Hi,
I have a problem with setting up quota usage tracking for domains.
Problem is, that domain quota is always based on only one user in 
domain, the last one on whom behalf any operation was performed.

To recreate this situation, one has only to perform:
doveadm quota recalc -u USER
on a user, and the domain quota takes the value of this user quota.

Have anyone a clue what could cause this problem?

Quota tracking is set up both for users and domains.
For users quota tracking is working fine, data is saved into dbase 
without problems.

We are using dovecot 2.0.15.
Quota enforcing (rules) is NOT a part of the problem.

Important parts of config:

dict {
quota = mysql:/etc/dovecot/dovecot-dict-used-quota.conf.ext
quota2 = mysql:/etc/dovecot/dovecot-dict-used-quota-domain.conf.ext
}

plugin {
quota = dict:User quota::proxy::quota
quota2 = dict:Domain quota:%d:proxy::quota2
}

/etc/dovecot/dovecot-dict-used-quota.conf.ext
map {
  pattern = priv/quota/storage
  table = used_quota
  username_field = username
  value_field = bytes
}
map {
  pattern = priv/quota/messages
  table = used_quota
  username_field = username
  value_field = messages
}

/etc/dovecot/dovecot-dict-used-quota-domain.conf.ext
map {
  pattern = priv/quota/storage
  table = used_quota_domain
  username_field = domain
  value_field = bytes
}
map {
  pattern = priv/quota/messages
  table = used_quota_domain
  username_field = domain
  value_field = messages
}

--
Adam Szpakowski


Re: [Dovecot] domain quota in sql

2012-02-14 Thread Timo Sirainen
On 14.2.2012, at 23.29, Adam Szpakowski wrote:

 Hi,
 I have a problem with setting up quota usage tracking for domains.
 Problem is, that domain quota is always based on only one user in domain, the 
 last one on whom behalf any operation was performed.
 To recreate this situation, one has only to perform:
 doveadm quota recalc -u USER
 on a user, and the domain quota takes the value of this user quota.
 
 Have anyone a clue what could cause this problem?

Domain-quota support in Dovecot is only partial. Recalculating domain quota 
would require more code. Last time when someone asked about this I wasn't even 
sure how it could be implemented, but nowadays it actually would be possible to 
do with:

 - set domain's quota to 0
 - iterate *@domain users via userdb
 - for each user get the user's quota and add it to domain quota



Re: [Dovecot] domain quota in sql

2012-02-14 Thread Timo Sirainen
On 15.2.2012, at 3.54, Timo Sirainen wrote:

 Domain-quota support in Dovecot is only partial. Recalculating domain quota 
 would require more code. Last time when someone asked about this I wasn't 
 even sure how it could be implemented, but nowadays it actually would be 
 possible to do with:

Oh, and you could actually already do this with a doveadm script:

 - set domain's quota to 0

update .. | mysql

 - iterate *@domain users via userdb

doveadm user '*@domain'

 - for each user get the user's quota and add it to domain quota

doveadm quota get -u $user | some grep+sed magic | mysql

Of course it would be nice if Dovecot internally supported this.

Re: [Dovecot] domain quota in sql

2012-02-14 Thread Adam Szpakowski

On 15.02.2012 02:55, Timo Sirainen wrote:

On 15.2.2012, at 3.54, Timo Sirainen wrote:


Domain-quota support in Dovecot is only partial. Recalculating domain quota 
would require more code. Last time when someone asked about this I wasn't even 
sure how it could be implemented, but nowadays it actually would be possible to 
do with:

Oh, and you could actually already do this with a doveadm script:

[cut]
I'm using something like this, but directly on the dbase level. 
Unfortunately such operation is quite db intensive, so I'm looking for a 
simpler solution.


Is there a way to add domainname as another collumn in dbase? This will 
simplify the SQL query and the GROUP BY could be used.



Of course it would be nice if Dovecot internally supported this.
I was under impression, that dovecot does support this. In examples one 
can see:


/usr/share/doc/dovecot-core/example-config/conf.d/90-quota.conf:

# Multiple quota roots are also possible, for example this gives each user
# their own 100MB quota and one shared 1GB quota within the domain:
plugin {
  #quota = dict:user::proxy::quota
  #quota2 = dict:domain:%d:proxy::quota_domain
}

Also on dovecot2 wiki we can see (http://wiki2.dovecot.org/Quota/Dict):

If username is left empty, the logged in username is used (this is 
typically what you want). Another useful username is '%d' for supporting 
domain-wide quotas.



--
Adam Szpakowski


Re: [Dovecot] domain quota in sql

2012-02-14 Thread Robert Schetterer
Am 15.02.2012 08:26, schrieb Adam Szpakowski:
 On 15.02.2012 02:55, Timo Sirainen wrote:
 On 15.2.2012, at 3.54, Timo Sirainen wrote:

 Domain-quota support in Dovecot is only partial. Recalculating domain
 quota would require more code. Last time when someone asked about
 this I wasn't even sure how it could be implemented, but nowadays it
 actually would be possible to do with:
 Oh, and you could actually already do this with a doveadm script:
 [cut]
 I'm using something like this, but directly on the dbase level.
 Unfortunately such operation is quite db intensive, so I'm looking for a
 simpler solution.
 
 Is there a way to add domainname as another collumn in dbase? This will
 simplify the SQL query and the GROUP BY could be used.
 
 Of course it would be nice if Dovecot internally supported this.
 I was under impression, that dovecot does support this. In examples one
 can see:
 
 /usr/share/doc/dovecot-core/example-config/conf.d/90-quota.conf:
 
 # Multiple quota roots are also possible, for example this gives each user
 # their own 100MB quota and one shared 1GB quota within the domain:
 plugin {
   #quota = dict:user::proxy::quota
   #quota2 = dict:domain:%d:proxy::quota_domain
 }
 
 Also on dovecot2 wiki we can see (http://wiki2.dovecot.org/Quota/Dict):
 
 If username is left empty, the logged in username is used (this is
 typically what you want). Another useful username is '%d' for supporting
 domain-wide quotas.
 
 

Hi i am not sure what are trying to goal
with domain quota, if you setup your accounts i.e with postfixadmin etc
then its up to the gui logic , stopping postmasters to setup more
accounts ( with quotas ) as you ( the superadmin ) want.

For everything else user quotas usally are enough

thinkable maybe calculation of all users quotas in dict from one domain
in a sql postfix query table to stop deliver in more mail, but i dont
think this makes real sense

sorry if i missunderstand your question..
-- 
Best Regards

MfG Robert Schetterer

Germany/Munich/Bavaria


[Dovecot] domain quota dictionary

2010-07-14 Thread alex

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= password=
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


Re: [Dovecot] domain quota dictionary

2010-07-14 Thread alex

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= password=
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




Re: [Dovecot] domain quota dictionary

2010-07-14 Thread Timo Sirainen
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?



Re: [Dovecot] domain quota dictionary

2010-07-14 Thread alex

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 |
+---++--+-+
| m...@example.com|  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 |
+-++--+-+
| m...@example.com  |  123996992 |21820 | 2010-07-14 17:33:26 |
| r...@example.com|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. 


Re: [Dovecot] domain quota dictionary

2010-07-14 Thread 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.




Re: [Dovecot] domain quota dictionary

2010-07-14 Thread alex

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 |
+-++--+-+
| m...@example.com  |  124038256 |21830 | 2010-07-14 17:56:03 |
| r...@example.com|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.


Re: [Dovecot] domain quota dictionary

2010-07-14 Thread 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.




Re: [Dovecot] domain quota dictionary

2010-07-14 Thread alex

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


Re: [Dovecot] domain quota dictionary

2010-07-14 Thread 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'