5 %CHANN = ( "#0" => "none" );
6 %EVENTS = ( "#0" => {"+hs"=>0} );
17 open(SRV,$ENV{"HOME"}."/.ssh/config") or die;
19 $srvname=$1 if /Host (\S+)/;
20 $HOSTS{$1}=$srvname if /HostName (\S+)/;
25 /(\d+_\d+_\d+_\d+_\d+) (#\d+) (\S+) (.*)/ or next;
30 my $host = $CHANN{"$channel"};
31 $host = "unknown" if not $host;
32 $time =~ /^(\d+)_(\d+)_(\d+)_(\d+)/;
33 my $ms=$1*60; $ms=($ms+$2)*60; $ms=($ms+$3)*1000; $ms+=$4;
34 if ($event eq "sent") {
35 $rest =~ /(\d+)b ([\d\.]+):/;
38 #$SENT{$h} = 0 if not exists $SENT{$h};
42 $CHANN{"$channel"} = $host;
43 } elsif ($event eq "recvd") {
45 #$RCVD{$h} = 0 if not exists $RCVD{$h};
49 } elsif ($event eq "sendctrl") {
50 if ($rest =~ /cwnd (\d+\.\d+).*data_out (\d+)/) {
51 if (not exists $CWNDLOG{$host}) {
52 open(my $handle, '>', "harvest/$SERVER-$host-cwnd.log") or die;
53 $CWNDLOG{$host} = $handle;
55 print {$CWNDLOG{$host}} "$ms\t$1\t$2\n";
56 } elsif ($rest =~ /ledbat (\-?\d+)\-(\-?\d+)/) {
57 if (not exists $OWDLOG{$host}) {
58 open(my $handle, '>', "harvest/$SERVER-$host-owd.log") or die;
59 $OWDLOG{$host} = $handle;
61 print {$OWDLOG{$host}} "$ms\t$1\t$2\n";
62 } elsif ($rest =~ /rtt (\d+) dev (\d+)/) {
63 if (not exists $RTTLOG{$host}) {
64 open(my $handle, '>', "harvest/$SERVER-$host-rtt.log") or die;
65 $RTTLOG{$host} = $handle;
67 print {$RTTLOG{$host}} "$ms\t$1\t$2\n";
70 $EVENTS{"$host"} = { "+hs"=>0 } if not exists $EVENTS{"$host"};
72 print "$time $SERVER $host$channel $event $rest\n";
75 $EVENTS{"$host"}{"$event"} = 0 if not exists $EVENTS{"$host"}{"$event"};
76 $EVENTS{"$host"}{"$event"}++;
80 for $host (keys %CWNDLOG) {
81 close($CWNDLOG{$host});
83 for $host (keys %OWDLOG) {
84 close ($OWDLOG{$host});
86 for $host (keys %RTTLOG) {
87 close ($RTTLOG{$host});
89 open(LEGEND,"> harvest/$SERVER-legend.txt") or die;
91 for $channel (keys %CHANN) {
92 my $host = $CHANN{"$channel"};
93 print LEGEND "$channel\t$host\n";
94 open(STATS,"> harvest/$SERVER-$host.stat") or die;
95 my %events = %{ $EVENTS{"$host"} };
96 for $event ( keys %events ) {
97 print STATS "$event\t".($events{"$event"})."\n";
100 open(HTML,"> harvest/$SERVER-$host.html") or die;
101 print HTML "<table class='channel'><th><td>sent</td><td>rcvd</td></th>\n";
102 my $rcvd = $RCVD{$host};
103 my $sent = $SENT{$host};
104 $rcvd=0.001 if not $rcvd;
105 $sent=0.001 if not $sent;
107 "<tr class='bytes'><td>bytes</td><td>%i/<pp>%.1f%%</pp></td>".
108 "<td>%i/<pp>%.1f%%</pp></td></tr>\n",
109 $sent, $SENTB?$sent/$SENTB*100:0, $rcvd, $RCVDB?$rcvd/$RCVDB*100:0;
111 "<tr><td>dgrams</td><td>".$DSENT{$host}."</td><td>".$DRCVD{$host}."</td></tr>\n";
113 "<tr><td>data</td><td>%i/<pp><b>%.1f%%</b></pp></td><td>%i/<pp><b>%.1f%%</b></pp></td></tr>\n",
114 $events{"+data"}, ($events{"+data"}*1029)/$sent*100,
115 $events{"-data"}, ($events{"-data"}*1029)/$rcvd*100;
117 "<tr><td>hash</td><td>%i/<pp>%.1f%%</pp></td><td>%i/<pp>%.1f%%</pp></td></tr>\n",
118 $events{"+hash"}, ($events{"+hash"}*25)/$sent*100,
119 $events{"-hash"}, ($events{"-hash"}*25)/$rcvd*100;
121 "<tr><td>ack</td><td>%i/<pp>%.1f%%</pp></td><td>%i/<pp>%.1f%%</pp></td></tr>\n",
122 $events{"+ack"}, ($events{"+ack"}*5)/$sent*100,
123 $events{"-ack"}, ($events{"-ack"}*5)/$rcvd*100;
125 "<tr><td>hint</td><td>%i/<pp>%.1f%%</pp></td><td>%i/<pp>%.1f%%</pp></td></tr>\n",
126 $events{"+hint"}, ($events{"+hint"}*5)/$sent*100,
127 $events{"-hint"}, ($events{"-hint"}*5)/$rcvd*100;
129 "<tr><td>hs</td><td>%i</td><td>%i</td></tr>\n",
130 $events{"+hs"}, $events{"-hs"};
131 my $losses = $events{"+data"}>0 ?
132 ($events{"Rdata"}+$events{"Tdata"})/$events{"+data"}*100 : 0;
134 "<tr><td>losses</td><td colspan='2'>R:%i+T:%i=%i/<pp>%.1f%%</pp></td></tr>\n",
135 $events{"Rdata"}, $events{"Tdata"},
136 $events{"Rdata"}+$events{"Tdata"}, $losses;
139 "<tr><td colspan='3'><a href='harvest/%s-%s.png'>".
140 "cwnd/data_out/rtt/owd graph</a></td></tr>\n",
143 print HTML "</table>\n";