]> git.ipfire.org Git - thirdparty/squid.git/blame - scripts/trace-job.pl
Added debugging scripts that work with detailed cache.log
[thirdparty/squid.git] / scripts / trace-job.pl
CommitLineData
e83fd259
AR
1#!/usr/bin/perl -w
2
3# Reads cache.log and displays lines that correspond to a given async job.
4#
5# If job entering/exiting line format changes, the script must be updated.
6# Keep the old RE around for a while because they may be handy for working
7# with folks running older Squids.
8
9use strict;
10use warnings;
11
12my $XactId = shift or die("usage: $0 <xaction id> [log file]\n");
13
14# Squid uses asyncNNN, jobNNN, icapxNNN for the same job/transaction
15# TODO: use jobNNN everywhere
16$XactId =~ s/^(?:async|job|icapx)(\d+)$/(async|job|icapx)$1/ and
17 warn("Replacing xaction ID with $XactId\n");
18
19my $inside = 0;
20
21my $entering;
22
23while (<>) {
24 $entering = $_ if !$inside && /\| entering\b/;
25 undef $entering if /\| leaving\b/;
26
27 # if (!$inside && /\bcalled\b.*\b$XactId\b/o) {
28 if (!$inside && /\bstatus in\b.*\b$XactId\b/o) {
29 print $entering if defined $entering;
30 $inside = 1;
31 }
32
33 my $external = !$inside && /\b$XactId\b/o;
34
35 print $_ if $inside || $external;
36 print "\n" if $external;
37
38 next unless $inside;
39
40 # if (/\bended\b.*\b$XactId\b/o || /\bswan\s+sang\b.*\b$XactId\b/o) {
41 # if (/\bstatus out\b.*\b$XactId\b/o || /\bswan\s+sang\b.*\b$XactId\b/o ||
42 if (/\| leaving\b/) {
43 print "\n";
44 $inside = 0;
45 }
46}
47
48exit(0);