]>
Commit | Line | Data |
---|---|---|
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 | ||
9 | use strict; | |
10 | use warnings; | |
11 | ||
12 | my $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 | ||
19 | my $inside = 0; | |
20 | ||
21 | my $entering; | |
22 | ||
23 | while (<>) { | |
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 | ||
48 | exit(0); |