]>
Commit | Line | Data |
---|---|---|
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 | 16 | use strict; |
db6ebab8 AJ |
17 | use Squid::ParseLog; |
18 | ||
19 | my %u; | |
20 | my $wh; | |
21 | ||
22 | $wh = "username"; | |
23 | if (scalar @ARGV >= 1) { | |
24 | $wh = $ARGV[0]; | |
25 | shift @ARGV; | |
26 | } | |
27 | ||
28 | while (<>) { | |
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 | ||
37 | foreach (keys %u) { | |
38 | printf "%s\t\t%lu\n", $_, $u{$_}->{"traffic"}; | |
39 | } |