quota-warning: possible to have size also?
Hello Community,
My dovecot setup works fine with quotas and quota-warning.
I have a questions though: when running the warning script, the example foundis it possible to pass the *quota size *as argument also? This would be useful with per-user quota.
e.g. /some/script xx% username *xxxbytes* (order is not relevant of course)
Thank you for your help.
Cheers
On 2017-03-05 19:13, dovecot@avv.solutions wrote:
I have a questions though: when running the warning script, the example foundis it possible to pass the *quota size *as argument also? This would be useful with per-user quota.
e.g. /some/script xx% username *xxxbytes* (order is not relevant of course)
+1 and quota-limit as well.
Hi,
I'am using a Maildir++ based quota setting which creates a maildirsize file in every Maildir. The first two lines of this file are the maximum quota in bytes then the actual consumption in bytes and number of messages, like so :
1073741824S 379317999 5169
This means this user has a quota of 1Gb and he is using ~ 379 Mb (you have to divide by 1024 to be more precise)
Since the script receieves the user as second argument, you can deduce it's current quota size and restriction by reading the maildirsize file (if you have it). I think you can do the same if your quota is in the database (querying).
This a piece of script I wrote once that shows the value of quota used and quota max (both in megas and perecent) that might help you if you know your way through bash scripting :
root@messagerie[10.10.10.19] ~/SCRIPTS/MAIL # cat showquota.single
mega=$((1024*1024)) inbox="${1%@*}" maildir="/var/vmail/domain.tld/$inbox" backup="/var/vmail/backup.domain.tld/$inbox" [ ! -e $maildir ] && echo "Boite email inexistante. Veuillez vérifier encore une fois l'orthogrape de $inbox@domain.tld" && exit 1 function get_quota { mailfolder="$1" maildirsize="$mailfolder/maildirsize" fields=$(echo $(head -2 $maildirsize)) max="${fields%%S*}" cur="$(echo $fields | cut -f2 -d ' ')" ratio=$(echo "scale=2; $cur * 100 / $max" | bc) cur=$(echo "scale=2; $cur / $mega" | bc) max=$(echo "scale=2; $max / $mega" | bc) echo "$cur Mo / $max Mo ( $ratio% )" } echo Quota sur la boite aux lettres "$inbox" get_quota "$maildir" echo Quota sur les archives get_quota "$backup" echo "-------------------------------------------------------------------------" root@messagerie[10.10.10.19] ~/SCRIPTS/MAIL #
--Yassine.
Am 06.03.2017 um 10:39 schrieb chaouche yacine:
Hi,
I'am using a Maildir++ based quota setting which creates a maildirsize file in every Maildir. The first two lines of this file are the maximum quota in bytes then the actual consumption in bytes and number of messages, like so :
1073741824S 379317999 5169
This means this user has a quota of 1Gb and he is using ~ 379 Mb (you have to divide by 1024 to be more precise)
Since the script receieves the user as second argument, you can deduce it's current quota size and restriction by reading the maildirsize file (if you have it). I think you can do the same if your quota is in the database (querying).
This a piece of script I wrote once that shows the value of quota used and quota max (both in megas and perecent) that might help you if you know your way through bash scripting :
I might be missing something but what's the advantage over doveadm?
doveadm quota get -A
-- Alex JOST
Good point Alex, there's no real advantage that script was there from courier's time and I still use it but doveadm quota command does the trick just as well.
Actual quota : root@messagerie[10.10.10.19] ~ # doveadm quota get -u sec-drh@domain.tld 2>/dev/null | sed -n 1p | awk '{print $4}' 559728 root@messagerie[10.10.10.19] ~ #
Max quota :
root@messagerie[10.10.10.19] ~ # doveadm quota get -u sec-drh@domain.tld 2>/dev/null | sed -n 1p | awk '{print $5}' 1048576 root@messagerie[10.10.10.19] ~ #
-- Yassine.
participants (4)
-
Alex JOST
-
chaouche yacine
-
dovecot@avv.solutions
-
Tom Sommer