]> git.ipfire.org Git - thirdparty/squid.git/blame - scripts/PerUser.pl
SourceFormat Enforcement
[thirdparty/squid.git] / scripts / PerUser.pl
CommitLineData
db6ebab8 1#!/usr/bin/perl -w
a151895d 2#
ef57eb7b 3## Copyright (C) 1996-2016 The Squid Software Foundation and contributors
a151895d
AJ
4##
5## Squid software is distributed under GPLv2+ license and includes
6## contributions from numerous individuals and organizations.
7## Please see the COPYING and CONTRIBUTORS files for details.
8##
db6ebab8
AJ
9
10# This is a simple script that will summarise per-user traffic
11# statistics.
12#
13# Adrian Chadd <adrian@squid-cache.org>
a151895d 14# CVS-Id: PerUser.pl,v 1.2 2007/01/24 08:03:52 adrian Exp
db6ebab8 15
a151895d 16use strict;
db6ebab8
AJ
17use Squid::ParseLog;
18
19my %u;
20my $wh;
21
22$wh = "username";
23if (scalar @ARGV >= 1) {
24 $wh = $ARGV[0];
25 shift @ARGV;
26}
27
28while (<>) {
29 chomp;
30 my $l = Squid::ParseLog::parse($_);
31 if (! defined $u{$l->{$wh}}) {
32 $u{$l->{$wh}}->{"traffic"} = 0;
33 }
34 $u{$l->{$wh}}->{"traffic"} += $l->{"size"};
35}
36
37foreach (keys %u) {
38 printf "%s\t\t%lu\n", $_, $u{$_}->{"traffic"};
39}