#!/usr/bin/perl -w $SERVER=shift; %HOSTS = (); %CHANN = ( "#0" => "none" ); %EVENTS = ( "#0" => {"+hs"=>0} ); %SENT = (); %RCVD = (); %DSENT = (); %DRCVD = (); %CWNDLOG = (); %RTTLOG = (); %OWDLOG = (); %TDATALOG = (); %RDATALOG = (); $SENTB = 0; $RCVDB = 0; open(SRV,$ENV{"HOME"}."/.ssh/config") or die; while () { $srvname=$1 if /Host (\S+)/; $HOSTS{$1}=$srvname if /HostName (\S+)/; } close SRV; while (<>) { /(\d+_\d+_\d+_\d+_\d+) (#\d+) (\S+) (.*)/ or next; my $time = $1; my $channel = $2; my $event = $3; my $rest = $4; my $host = $CHANN{"$channel"}; $host = "unknown" if not $host; $time =~ /^(\d+)_(\d+)_(\d+)_(\d+)/; my $ms=$1*60; $ms=($ms+$2)*60; $ms=($ms+$3)*1000; $ms+=$4; if ($event eq "sent") { $rest =~ /(\d+)b ([\d\.]+):/; $ip = $2; $host = $HOSTS{$ip}; #$SENT{$h} = 0 if not exists $SENT{$h}; $SENT{$host} += $1; $SENTB += $1; $DSENT{$host}++; $CHANN{"$channel"} = $host; } elsif ($event eq "recvd") { $rest =~ /(\d+)/; #$RCVD{$h} = 0 if not exists $RCVD{$h}; $DRCVD{$host}++; $RCVD{$host} += $1; $RCVDB += $1; } elsif ($event eq "sendctrl") { if ($rest =~ /cwnd (\d+\.\d+).*data_out (\d+)/) { if (not exists $CWNDLOG{$host}) { open(my $handle, '>', "harvest/$SERVER-$host-cwnd.log") or die; $CWNDLOG{$host} = $handle; } print {$CWNDLOG{$host}} "$ms\t$1\t$2\n"; } elsif ($rest =~ /ledbat (\-?\d+)\-(\-?\d+)/) { if (not exists $OWDLOG{$host}) { open(my $handle, '>', "harvest/$SERVER-$host-owd.log") or die; $OWDLOG{$host} = $handle; } print {$OWDLOG{$host}} "$ms\t$1\t$2\n"; } elsif ($rest =~ /rtt (\d+) dev (\d+)/) { if (not exists $RTTLOG{$host}) { open(my $handle, '>', "harvest/$SERVER-$host-rtt.log") or die; $RTTLOG{$host} = $handle; } print {$RTTLOG{$host}} "$ms\t$1\t$2\n"; } } elsif ($event eq "Tdata") { if (not exists $TDATALOG{$host}) { open(my $handle, '>', "harvest/$SERVER-$host-tdata.log") or die; $TDATALOG{$host} = $handle; } print {$TDATALOG{$host}} "$ms\n"; } elsif ($event eq "Rdata") { if (not exists $RDATALOG{$host}) { open(my $handle, '>', "harvest/$SERVER-$host-rdata.log") or die; $RDATALOG{$host} = $handle; } print {$RDATALOG{$host}} "$ms\n"; } $EVENTS{"$host"} = { "+hs"=>0 } if not exists $EVENTS{"$host"}; print "$time $SERVER $host$channel $event $rest\n"; # DO STATS $EVENTS{"$host"}{"$event"} = 0 if not exists $EVENTS{"$host"}{"$event"}; $EVENTS{"$host"}{"$event"}++; } for $host (keys %CWNDLOG) { close($CWNDLOG{$host}); } for $host (keys %OWDLOG) { close ($OWDLOG{$host}); } for $host (keys %RTTLOG) { close ($RTTLOG{$host}); } for $host (keys %TDATALOG) { close ($TDATALOG{$host}); } for $host (keys %RDATALOG) { close ($RDATALOG{$host}); } open(LEGEND,"> harvest/$SERVER-legend.txt") or die; for $channel (keys %CHANN) { my $host = $CHANN{"$channel"}; print LEGEND "$channel\t$host\n"; open(STATS,"> harvest/$SERVER-$host.stat") or die; my %events = %{ $EVENTS{"$host"} }; for $event ( keys %events ) { print STATS "$event\t".($events{"$event"})."\n"; } close STATS; open(HTML,"> harvest/$SERVER-$host.html") or die; print HTML "\n"; my $rcvd = $RCVD{$host}; my $sent = $SENT{$host}; $rcvd=0.001 if not $rcvd; $sent=0.001 if not $sent; printf HTML "". "\n", $sent, $SENTB?$sent/$SENTB*100:0, $rcvd, $RCVDB?$rcvd/$RCVDB*100:0; print HTML "\n"; printf HTML "\n", $events{"+data"}, ($events{"+data"}*1029)/$sent*100, $events{"-data"}, ($events{"-data"}*1029)/$rcvd*100; printf HTML "\n", $events{"+hash"}, ($events{"+hash"}*25)/$sent*100, $events{"-hash"}, ($events{"-hash"}*25)/$rcvd*100; printf HTML "\n", $events{"+ack"}, ($events{"+ack"}*5)/$sent*100, $events{"-ack"}, ($events{"-ack"}*5)/$rcvd*100; printf HTML "\n", $events{"+hint"}, ($events{"+hint"}*5)/$sent*100, $events{"-hint"}, ($events{"-hint"}*5)/$rcvd*100; printf HTML "\n", $events{"+hs"}, $events{"-hs"}; my $losses = $events{"+data"}>0 ? ($events{"Rdata"}+$events{"Tdata"})/$events{"+data"}*100 : 0; printf HTML "\n", $events{"Rdata"}, $events{"Tdata"}, $events{"Rdata"}+$events{"Tdata"}, $losses; print HTML "
sentrcvd
bytes%i/%.1f%%%i/%.1f%%
dgrams".$DSENT{$host}."".$DRCVD{$host}."
data%i/%.1f%%%i/%.1f%%
hash%i/%.1f%%%i/%.1f%%
ack%i/%.1f%%%i/%.1f%%
hint%i/%.1f%%%i/%.1f%%
hs%i%i
lossesR:%i+T:%i=%i/%.1f%%
\n"; close HTML; } close LEGEND;