|
| 1 | +#!/usr/bin/perl |
| 2 | +# Parse Java Proxy logs and look for mem2mm shennanigans |
| 3 | + |
| 4 | +use strict; |
| 5 | + |
| 6 | +my ($pid, $tid, $time, $timestr, $ver, $table); |
| 7 | +my %threads = (); |
| 8 | +my %servers = (); |
| 9 | +my %dates = (); |
| 10 | +my @chrono; |
| 11 | +my $ln; |
| 12 | +my $file = $ARGV[0]; |
| 13 | + |
| 14 | +sub readpidtid() { |
| 15 | + if (m/\[.*?(\d+:\d+:\d+:\d+).*?\] (\w+)/) { |
| 16 | + $timestr = $1; |
| 17 | + $tid = $2; |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +sub sed_split { |
| 22 | + my ($data) = @_; |
| 23 | + return sprintf "sed -e '%s,%s!d' '%s' | grep '%s'\n", $data->{'line'}, $data->{'line_end'}, $file , $data->{'tid'}; |
| 24 | +} |
| 25 | + |
| 26 | +while(<>) { |
| 27 | + $ln++; |
| 28 | + if (/\[null\]/) { |
| 29 | + next; |
| 30 | + } |
| 31 | + # These cases are in the order the messages appear |
| 32 | + if (/Finishing request to target asynch.*target=(\S*)/) { |
| 33 | + readpidtid(); |
| 34 | + $threads{$tid} = { tid=>$tid, name=>$1, line=>$ln}; |
| 35 | + } |
| 36 | + if (/Adding header \[Date\] with value \[(.*)\]$/) { |
| 37 | + readpidtid(); |
| 38 | + my $server = $threads{$tid}->{'name'}; |
| 39 | + my $date = $1; |
| 40 | + if ($date =~ m/(\d+:\d+:\d+)/) { |
| 41 | + $dates{$tid} = $1; |
| 42 | + } |
| 43 | + } |
| 44 | + if (/getHeaderAsString.*WSPT \[(.*)\]$/) { |
| 45 | + readpidtid(); |
| 46 | + my $server = $threads{$tid}->{'name'}; |
| 47 | + $threads{$tid}->{'table'} = $1; |
| 48 | + } |
| 49 | + if (/getHeaderAsString.*_WS_HAPRT_WLMVERSION \[(.*)\]$/) { |
| 50 | + readpidtid(); |
| 51 | + my $server = $threads{$tid}->{'name'}; |
| 52 | + my $line1 = $threads{$tid}->{'line'}; |
| 53 | + my $table = $threads{$tid}->{'table'}; |
| 54 | + push @{$servers{$server}->{'data'}}, { tid=>$tid, time=>$timestr , table=>$table, version=>$1, line=>$line1, line_end=>$ln, http_date=>$dates{$tid} }; |
| 55 | + push @chrono, "$timestr\n\t$server\n\tWSPT=$table\n\tVER=$1"; |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +print "By Server\n\n"; |
| 60 | +my ($k, $v); |
| 61 | +while (($k, $v) = each(%servers)) { |
| 62 | + print "$k\n\n"; |
| 63 | + my $prevtable; |
| 64 | + foreach (@{$v->{'data'}}) { |
| 65 | + my @trace_time = split, /:/, $_->{'time'}; |
| 66 | + my @http_time = split, /:/, $_->{'http_date'}; |
| 67 | + my $delay_seconds = $trace_time[2] - $http_time[2]; |
| 68 | + $delay_seconds = 60*($trace_time[1] - $http_time[1]); |
| 69 | + print "\t $_->{'line'}: $_->{'time'} delay=$delay_seconds VER=$_->{'version'} WSPT=$_->{'table'} \n"; |
| 70 | + print "\t\t" . sed_split($_) . "\n"; |
| 71 | + if (defined($prevtable) && length($prevtable) > length($_->{'table'})) { |
| 72 | + print "\t ^^^ WHY DID THIS SHRINK " . sed_split($_) . "\n"; |
| 73 | + } |
| 74 | + $prevtable = $_->{'table'}; |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +print "By time\n\n"; |
| 79 | +foreach(@chrono) { |
| 80 | + print "$_\n"; |
| 81 | +} |
0 commit comments