Last login time for mailusers?

Hey guys,

Long time lurker, first time poster. :slight_smile: I’ve got a Virtualmin GPL box up and running, serving up about 20 virtual domains at the moment. I’d really love to be able to see when last each user logged in to get their mail.

Is this even possible? :slight_smile:

Thanks!

Possible, sure. A common enough desire for us to add a button or menu item for it? No way. :wink:

Every IMAP and POP login is logged in /var/log/maillog. You can trivially grep out all such logins. It gets a little trickier to make some sort of easily read report out of this data…You could use Perl or Ruby or Python to build an associative array (aka hash) of the user logins it sees keyed to the username. At the end, it would naturally contain the last login of all users that it saw in the log file. About ten lines of Perl.

If you have no idea what I’m talking about, let me know, and I’ll see about taking out ten minutes and writing those ten lines for you. :wink:

if you use qmail+vpopmail you can use smth like this:

/home/vpopmail/bin/vuserinfo user@domain.net
name: user
passwd: $1$88iLzlEd$7ajP6YWuKXrbFzslF34561
clear passwd: gh35U$h3w
comment/gecos: user
uid: 1
gid: 0
flags: 0
gecos: user
limits: No user limits set.
dir: /home/vpopmail/domains/domain.net/user
quota: NOQUOTA
usage: NOQUOTA
account created: Fri Jun 15 17:18:50 2007
last auth: Never logged in

stress on the "last auth: Never logged in " line :slight_smile:

PS: forum has a bug, cant edit my messages

Thanks, but I’m using Postfix/Dovecot. I’m up to my eyeballs in other work at the moment, but I think a log parser is probably going to be pretty simple. I’ve been playing with Splunk as well to see if I can use that.

Hey Joe,

Looks like you are tracking a user’s last email login now. Quick question.

Are you grep’ing the log each time a user is brought up in the gui? Or are you tracking this to another flat file or database?

I’ll like to build a script to automate a report for a couple of my domains and dont mind grep’ing mail log to grab it, but if you are already tracking this elsewhere, I’ll pull from that.

Thanks!

John P.

I believe that information would be obtained using the collectinfo.pl cron job that runs every few minutes. That means it would be stored with all the other Webmin/Virtualmin data it gathers, though I don’t know the exact format or where specifically it’s stored… it may be in /etc/webmin/virtual-server/history.

You may be able to determine that by reviewing the collectinfo.pl code.

-Eric