]>
git.ipfire.org Git - thirdparty/squid.git/blob - scripts/trace-kid.pl
f965541b69f82c09404d682601aead0954171105
3 ## Copyright (C) 1996-2016 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 # Reads cache.log and displays lines that correspond to a given kid.
12 # Cache log format and logging bugs make accurate kid attribution impossible,
13 # but this script is much better than running "grep kidN cache.log" and missing
14 # all "kidless" lines that do not contain kidN ID, such as HTTP header dumps.
20 my $IncludePrefix = 0; # include initial kidless lines
21 my $IncludeMentions = 0; # include other kid references to the targeted kid
23 "prefix!" => \
$IncludePrefix,
24 "mentions!" => \
$IncludeMentions,
27 my $Kid = shift or die(usage
());
28 die("$0: error: expecting an integer kid ID but got $Kid\n")
29 unless $Kid =~ /^\d+$/;
33 my ($currentKid) = (/^\d[^a-z]+? kid(\d+)[|]/);
34 $lastKid = $currentKid if defined $currentKid;
36 if (!defined($currentKid) && !defined($lastKid)) { # kidless prefix
37 print $_ if $IncludePrefix;
41 # targeted kid output or kidless output by, hopefully, the targeted kid
42 if (defined $lastKid && $lastKid == $Kid) {
47 if (defined $currentKid) { # wrong kid output
48 # print lines mentioning our kid if requested, isolating each such line
49 print "\n$_\n" if $IncludeMentions && /\bkid(:\s*)?$Kid\b/o;
53 # ignore kidless output produced by, hopefully, wrong kids
60 usage: $0 [option...] <kid ID> [log file...]
62 --prefix include initial kidless lines
63 --mentions include other kid references to the targeted kid