Traffic accounting
Hello,
Could you please tell me whether is it possible to do traffic accounting using Dovecot 2.3.4?
What I'd like to do is to collect network traffic (both in & out) for each user (both POP and IMAP traffic).
Regards,
On 20-07-2021 8:13, Jesús Ángel del Pozo Domínguez wrote:
Hello,
Could you please tell me whether is it possible to do traffic accounting using Dovecot 2.3.4?
What I'd like to do is to collect network traffic (both in & out) for each user (both POP and IMAP traffic).
Regards,
It's possible, you need to adjust the IMAP & POP3 logging configuration, then parse the mail log and collect in/out values. E.g.:
doveconf -a | egrep '(imap|pop3).*logout_format' imap_logout_format = rcvd=%i, sent=%o imap_urlauth_logout_format = in=%i out=%o pop3_logout_format = rcvd=%i, sent=%o, top=%t/%p, retr=%r/%b, del=%d/%m, size=%s
egrep 'dovecot: service=imap, user=user@domain.com.au.*Logged out' /var/log/maillog | tail -n 1 Jul 20 15:59:38 server dovecot: service=imap, user=user@domain.com.au, ip=[127.0.0.1]. Logged out rcvd=38, sent=593
YMMV
-- Adi Pircalabu
On 20/07/2021 09:03 Adi Pircalabu adi@ddns.com.au wrote:
On 20-07-2021 8:13, Jesús Ángel del Pozo Domínguez wrote:
Hello,
Could you please tell me whether is it possible to do traffic accounting using Dovecot 2.3.4?
What I'd like to do is to collect network traffic (both in & out) for each user (both POP and IMAP traffic).
Regards,
It's possible, you need to adjust the IMAP & POP3 logging configuration, then parse the mail log and collect in/out values. E.g.:
doveconf -a | egrep '(imap|pop3).*logout_format' imap_logout_format = rcvd=%i, sent=%o imap_urlauth_logout_format = in=%i out=%o pop3_logout_format = rcvd=%i, sent=%o, top=%t/%p, retr=%r/%b, del=%d/%m, size=%s
egrep 'dovecot: service=imap, user=user@domain.com.au.*Logged out' /var/log/maillog | tail -n 1 Jul 20 15:59:38 server dovecot: service=imap, user=user@domain.com.au, ip=[127.0.0.1]. Logged out rcvd=38, sent=593
YMMV
-- Adi Pircalabu
With 2.3.12+ you can use
metric imapc_traffic { filter=event=imap_command_finished fields=bytes_in bytes_out group_by=user }
or if you have 2.3.11 (or older)
metric imap_traffic { event_name=imap_command_finished fields=bytes_in bytes_out # group_by needs 2.3.10+ group_by=user }
Then you can use doveadm stats dump
to see these.
Aki
On July 20, 2021 5:29:31 PM UTC, Benny Pedersen me@junc.eu wrote:
On 2021-07-20 08:16, Aki Tuomi wrote:
With 2.3.12+ you can use
metric imapc_traffic { filter=event=imap_command_finished fields=bytes_in bytes_out group_by=user }
typo with = twice in same line ?
Nope. You can write it
filter = event=imap_command_finished
for clarity.
Aki
participants (4)
-
Adi Pircalabu
-
Aki Tuomi
-
Benny Pedersen
-
Jesús Ángel del Pozo Domínguez