]>
git.ipfire.org Git - thirdparty/squid.git/blob - scripts/access-log-matrix.pl
3 ## Copyright (C) 1996-2021 The Squid Software Foundation and contributors
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.
10 # access-log-matrix.pl
12 # Duane Wessels, Dec 1995
14 # Stdin is a Harvest access log (in the old, non-common logfile format!).
15 # The output is a matrix of hostnames and log entry types, plus totals.
21 $first = $when unless ($first);
31 if ($what eq 'TCP_DONE') {
34 } elsif ($what eq 'TCP_HIT') {
37 } elsif ($what eq 'TCP_MISS') {
40 } elsif ($what eq 'TCP_MISS_TTL') {
41 $TCP_MISS_TTL{$host}++;
42 $TCP_MISS_TTL{'TOTAL'}++;
43 } elsif ($what eq 'UDP_HIT') {
46 } elsif ($what eq 'UDP_MISS') {
55 print ' HOSTNAME: '. `hostname`;
56 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdat) = localtime($first);
57 printf "FIRST LOG ENTRY: %04d/%02d/%02d %.2d:%.2d:%.2d\n", $year+1900,$mon+1,$mday, $hour,$min,$sec;
58 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdat) = localtime($last);
59 printf " LAST LOG ENTRY: %04d/%02d/%02d %.2d:%.2d:%.2d\n", $year+1900,$mon+1,$mday, $hour,$min,$sec;
62 printf ("%25.25s %5s %5s %5s %5s %5s %5s %5s %5s\n",
64 'TCP', 'TCP', 'TCP', 'TCP',
67 printf ("%25.25s %5s %5s %5s %5s %5s %5s %5s %5s\n",
69 'HIT', 'MISS', 'TTL', 'DONE',
70 'HIT', 'MISS', 'OTHER',
73 printf ("%25.25s %5s %5s %5s %5s %5s %5s %5s %5s\n",
75 '-'x5
, '-'x5
, '-'x5
, '-'x5
, '-'x5
, '-'x5
, '-'x5
, '-'x5
);
77 foreach $h (sort totalcmp
keys %HOSTS) {
78 next if ($h eq 'TOTAL');
79 ($a1,$a2,$a3,$a4) = split('\.', $h);
80 ($fqdn, @F) = gethostbyaddr(pack('C4',$a1,$a2,$a3,$a4),2);
81 $fqdn = $h unless ($fqdn ne '');
83 printf "%25.25s %5d %5d %5d %5d %5d %5d %5d %5d\n",
97 printf ("%25.25s %5s %5s %5s %5s %5s %5s %5s %5s\n",
99 '-'x5
, '-'x5
, '-'x5
, '-'x5
, '-'x5
, '-'x5
, '-'x5
, '-'x5
);
100 printf "%25.25s %5d %5d %5d %5d %5d %5d %5d %5d\n",
104 $TCP_MISS_TTL{'TOTAL'},
118 $HOSTS{$b} <=> $HOSTS{$a}