Archives for : SOGo

sogo-last, a quick utility for SOGo

The small script is used to parse an nginx (or any other webserver) access log and output the list of the last connected SOGo users, sorted by date of connexion.


use strict;
use warnings;

my $logfile = shift;
$logfile ||= "/var/log/nginx/access.log";

my %seen = ();
open LOG, "<$logfile" or die "Can't open '$logfile': $!\n";
while ()
        if (m#\[([^\]]+)\].*POST /SOGo/so/([^/]+)/Mail//#)
                $seen{$2} = $1;
close LOG;

sub bydate { $seen{$a} cmp $seen{$b}; }

foreach (sort bydate keys %seen)
        printf "%-12s %s\n", $_, $seen{$_};