[Dovecot] Track when user last checked mail
First off I've just got to say thanks. We just upgraded from UW to Dovecot migrating from mbox to maildir. Wow, what a difference! Load average used to hang around 5.0 during business hours and could get up to 20+ on a bad day. Now we rarely break 1.0!
I'm wondering if there's a way to keep track of the last time a user checked their email and whether they checked it using POP or IMAP. We're trying to gather statistics on what protocols our users use and find accounts that haven't been checked for a long time. We used to be able to do some of this with the finger command and the user's mbox. I found a script called "mfinger" that works better with Maildir, but it's designed for Courier.
Any ideas?
Thanks!
Del Stoliker wrote:
First off I've just got to say thanks. We just upgraded from UW to Dovecot migrating from mbox to maildir. Wow, what a difference! Load average used to hang around 5.0 during business hours and could get up to 20+ on a bad day. Now we rarely break 1.0!
That's encouraging for those of us planning this change :)
I'm wondering if there's a way to keep track of the last time a user checked their email and whether they checked it using POP or IMAP. We're trying to gather statistics on what protocols our users use and find accounts that haven't been checked for a long time. We used to be able to do some of this with the finger command and the user's mbox. I found a script called "mfinger" that works better with Maildir, but it's designed for Courier.
Can't you just grep through the logs? It's not too hard to add extra logging if needed; I've currently got SELECTs (i.e. IMAP folder opens) logged, for example.
Best Wishes, Chris
-- --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+- Christopher Wakelin, c.d.wakelin@reading.ac.uk IT Services Centre, The University of Reading, Tel: +44 (0)118 378 8439 Whiteknights, Reading, RG6 2AF, UK Fax: +44 (0)118 975 3094
On Monday 25 April 2005 22:25, Del Stoliker wrote:
First off I've just got to say thanks. We just upgraded from UW to Dovecot migrating from mbox to maildir. Wow, what a difference! Load average used to hang around 5.0 during business hours and could get up to 20+ on a bad day. Now we rarely break 1.0!
I'm wondering if there's a way to keep track of the last time a user checked their email and whether they checked it using POP or IMAP. We're trying to gather statistics on what protocols our users use and find accounts that haven't been checked for a long time. We used to be able to do some of this with the finger command and the user's mbox. I found a script called "mfinger" that works better with Maildir, but it's designed for Courier.
You don't say how you wish to access this information, but this works:
egrep "(pop|imap)-login: Login:" /var/log/mail.log | grep USERNAME| tail -1
Assuming you run it before you rotate your logs, or you could miss out.
Another way is to modify Dovecot a little and have it record whatever activity details you want directly into a Database, ie: SQLite / MySQL. This should be simple to do for some inclined developer (if this is a commercial project).
Any ideas?
Thanks!
HTH,
Dominic GoodforBusiness.co.uk I.T. Services for SMEs in the UK.
First off I've just got to say thanks. We just upgraded from UW to Dovecot migrating from mbox to maildir. Wow, what a difference! Load average used to hang around 5.0 during business hours and could get up to 20+ on a bad day. Now we rarely break 1.0!
I'm wondering if there's a way to keep track of the last time a user checked their email and whether they checked it using POP or IMAP. We're trying to gather statistics on what protocols our users use and find accounts that haven't been checked for a long time. We used to be able to do some of this with the finger command and the user's mbox. I found a script called "mfinger" that works better with Maildir, but it's designed for Courier.
You don't say how you wish to access this information, but this works:
egrep "(pop|imap)-login: Login:" /var/log/mail.log | grep USERNAME| tail -1
Assuming you run it before you rotate your logs, or you could miss out.
Another way is to modify Dovecot a little and have it record whatever activity details you want directly into a Database, ie: SQLite / MySQL. This should be simple to do for some inclined developer (if this is a commercial project).
Thanks for the suggestions. I guess I could have articulated my question a little better.
Ideally, I'd like to have the user's protocol and timestamp recorded when they check mail into a database. I'd rather not modify dovecot itself - seems like that would be a project itself just to maintain.
The only idea I'm coming up with so far is to grep the logfile for each user in the manner you suggest on cron job (late at night while the server is bored), parse the results, and record them into a database. The downfall is that it's not real time.
I can't help but wonder if I'm reinventing the wheel here. Is someone else doing something like this?
I am not sure if this is what you are looking for, but currently LogWatch does something quite similar, but the results are sent via an email, and, granted, they could be a bit more verbose but it is only going by what dovecot logs to syslog..
-Rich
[IMAPd] Connections:
Host | Connections | SSL | Total
-------------------------------------- | ----------- | -------- | --------- [192.168.6.10] | 7 | 0 | 7 [192.168.6.2] | 8 | 0 | 8 [192.168.6.3] | 5 | 0 | 5 [68.44.18.33] | 14 | 0 | 14 [68.6.116.208] | 2 | 0 | 2 [69.11.57.131] | 1 | 0 | 1 [70.104.7.3] | 5 | 0 | 5
42 | 0 | 42
[POP3] Connections:
Host | Connections
------------------------------------------------------------- | ----------- [24.25.30.219] | 250 [8.46.16.208] | 5 [70.1.11.86] | 8
263
Thanks for the suggestions. I guess I could have articulated my question a little better.
Ideally, I'd like to have the user's protocol and timestamp recorded when they check mail into a database. I'd rather not modify dovecot itself - seems like that would be a project itself just to maintain.
The only idea I'm coming up with so far is to grep the logfile for each user in the manner you suggest on cron job (late at night while the server is bored), parse the results, and record them into a database. The downfall is that it's not real time.
I can't help but wonder if I'm reinventing the wheel here. Is someone else doing something like this?
Hi, I've been lurking on this list for a while. We are still using UW-IMAP and Qualcomm popper, but I'm thinking of changing to dovecot this summer after the students disappear.
In UW-IMAP, I needed this feature so I modified the code to basically touch a dot file in the user's homedir. This way I can go look for this file and check the date to see the last time they used IMAP. Here is my hack lifted straight out of my patchfile for UW-IMAP; the same idea could be hacked into dovecot:
touchfile = (char *) fs_get (strlen (home) + 15);
sprintf(touchfile,"%s/.imapd.last",home);
fd = open(touchfile,O_WRONLY|O_CREAT|O_TRUNC,0600);
if(fd < 0)
r(errno));syslog (LOG_NOTICE|LOG_AUTH,"touchfile failed for %s:%s",user,strerro
else
close(fd);
fs_give((void **) &touchfile);
Note that fs_get and fs_give are UW's wrapper around malloc() and free(). Build the path to the file, open the file, close the file, complain to syslog if the open failed.
Jeff Earickson Colby College (back to lurking)
On Mon, 25 Apr 2005, Del Stoliker wrote:
Date: Mon, 25 Apr 2005 17:07:13 -0600 From: Del Stoliker dstoliker@alphagraphics.com To: dovecot@dovecot.org Subject: RE: [Dovecot] Track when user last checked mail
First off I've just got to say thanks. We just upgraded from UW to Dovecot migrating from mbox to maildir. Wow, what a difference! Load average used to hang around 5.0 during business hours and could get up to 20+ on a bad day. Now we rarely break 1.0!
I'm wondering if there's a way to keep track of the last time a user checked their email and whether they checked it using POP or IMAP. We're trying to gather statistics on what protocols our users use and find accounts that haven't been checked for a long time. We used to be able to do some of this with the finger command and the user's mbox. I found a script called "mfinger" that works better with Maildir, but it's designed for Courier.
You don't say how you wish to access this information, but this works:
egrep "(pop|imap)-login: Login:" /var/log/mail.log | grep USERNAME| tail -1
Assuming you run it before you rotate your logs, or you could miss out.
Another way is to modify Dovecot a little and have it record whatever activity details you want directly into a Database, ie: SQLite / MySQL. This should be simple to do for some inclined developer (if this is a commercial project).
Thanks for the suggestions. I guess I could have articulated my question a little better.
Ideally, I'd like to have the user's protocol and timestamp recorded when they check mail into a database. I'd rather not modify dovecot itself - seems like that would be a project itself just to maintain.
The only idea I'm coming up with so far is to grep the logfile for each user in the manner you suggest on cron job (late at night while the server is bored), parse the results, and record them into a database. The downfall is that it's not real time.
I can't help but wonder if I'm reinventing the wheel here. Is someone else doing something like this?
--On Monday, April 25, 2005 3:25 PM -0600 Del Stoliker dstoliker@alphagraphics.com wrote:
I'm wondering if there's a way to keep track of the last time a user checked their email and whether they checked it using POP or IMAP.
This won't tell you whether IMAP or POP was used, but you can look at the atime on the inbox to see when it was last read.
The problem I ran into with this approach was that my verify pass on my backup job would read every file on the system, touching the atime's. To get around this, my verify script would remount the filesystem with noatime for the duration of the verify. So there was a window of an hour or two during which I might miss a user's access.
participants (6)
-
Chris Wakelin
-
Del Stoliker
-
Dominic Marks
-
Jeff A. Earickson
-
Kenneth Porter
-
Rich West