6 %CHANN = ( "#0" => "none" );
7 %EVENTS = ( "#0" => {"+hs"=>0} );
21 open(SRVP,$ENV{"HOME"}."/swift/mfold/servers.txt") or die;
23 /(\S+):(\d+)/ or next;
28 open(SRV,$ENV{"HOME"}."/.ssh/config") or die;
32 $port = $PORTS{$srvname};
34 $HOSTS{$1}{$port}=$srvname if /HostName (\S+)/ && $port;
39 /(\d+_\d+_\d+_\d+_\d+) (#\d+) (\S+) (.*)/ or next;
44 my $host = $CHANN{"$channel"};
45 $host = "unknown" if not $host;
46 $time =~ /^(\d+)_(\d+)_(\d+)_(\d+)/;
47 my $ms=$1*60; $ms=($ms+$2)*60; $ms=($ms+$3)*1000; $ms+=$4;
48 if ($event eq "sent") {
49 $rest =~ /(\d+)b ([\d\.]+):(\d+):/;
52 $host = $HOSTS{$ip}{$port};
53 #$SENT{$h} = 0 if not exists $SENT{$h};
57 $CHANN{"$channel"} = $host;
58 } elsif ($event eq "recvd") {
60 #$RCVD{$h} = 0 if not exists $RCVD{$h};
64 } elsif ($event eq "sendctrl") {
65 if ($rest =~ /cwnd (\d+\.\d+).*data_out (\d+)/) {
66 if (not exists $CWNDLOG{$host}) {
67 open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-cwnd.log") or die;
68 $CWNDLOG{$host} = $handle;
70 print {$CWNDLOG{$host}} "$ms\t$1\t$2\n";
71 } elsif ($rest =~ /ledbat (\-?\d+)\-(\-?\d+)/) {
72 if (not exists $OWDLOG{$host}) {
73 open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-owd.log") or die;
74 $OWDLOG{$host} = $handle;
76 print {$OWDLOG{$host}} "$ms\t$1\t$2\n";
77 } elsif ($rest =~ /rtt (\d+) dev (\d+)/) {
78 if (not exists $RTTLOG{$host}) {
79 open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-rtt.log") or die;
80 $RTTLOG{$host} = $handle;
82 print {$RTTLOG{$host}} "$ms\t$1\t$2\n";
84 } elsif ($event eq "Tdata") {
85 if (not exists $TDATALOG{$host}) {
86 open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-tdata.log") or die;
87 $TDATALOG{$host} = $handle;
89 print {$TDATALOG{$host}} "$ms\n";
90 } elsif ($event eq "Rdata") {
91 if (not exists $RDATALOG{$host}) {
92 open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-rdata.log") or die;
93 $RDATALOG{$host} = $handle;
95 print {$RDATALOG{$host}} "$ms\n";
96 } elsif ($event eq "-data" && $rest =~ /\(0,(\d+)\)/) {
98 if (not exists $INDATALOG{$host}) {
99 open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-indata.log") or die;
100 $INDATALOG{$host} = $handle;
102 print {$INDATALOG{$host}} "$bin\t$ms\n";
104 $EVENTS{"$host"} = { "+hs"=>0 } if not exists $EVENTS{"$host"};
106 print "$time $SERVER $host$channel $event $rest\n";
109 $EVENTS{"$host"}{"$event"} = 0 if not exists $EVENTS{"$host"}{"$event"};
110 $EVENTS{"$host"}{"$event"}++;
114 for $host (keys %CWNDLOG) {
115 close($CWNDLOG{$host});
117 for $host (keys %OWDLOG) {
118 close ($OWDLOG{$host});
120 for $host (keys %RTTLOG) {
121 close ($RTTLOG{$host});
123 for $host (keys %TDATALOG) {
124 close ($TDATALOG{$host});
126 for $host (keys %RDATALOG) {
127 close ($RDATALOG{$host});
129 for $host (keys %INDATALOG) {
130 close ($INDATALOG{$host});
133 open(LEGEND,"> $SERVER-harvest/$SERVER-legend.txt") or die;
135 for $channel (keys %CHANN) {
136 my $host = $CHANN{"$channel"};
137 print LEGEND "$channel\t$host\n";
138 open(STATS,"> $SERVER-harvest/$SERVER-$host.stat") or die;
139 my %events = %{ $EVENTS{"$host"} };
140 for $event ( keys %events ) {
141 print STATS "$event\t".($events{"$event"})."\n";
144 open(HTML,"> $SERVER-harvest/$SERVER-$host.html") or die;
145 print HTML "<table class='channel'><th><td>sent</td><td>rcvd</td></th>\n";
146 my $rcvd = $RCVD{$host};
147 my $sent = $SENT{$host};
148 $rcvd=0.001 if not $rcvd;
149 $sent=0.001 if not $sent;
151 "<tr class='bytes'><td>bytes</td><td>%i/<pp>%.1f%%</pp></td>".
152 "<td>%i/<pp>%.1f%%</pp></td></tr>\n",
153 $sent, $SENTB?$sent/$SENTB*100:0, $rcvd, $RCVDB?$rcvd/$RCVDB*100:0;
155 "<tr><td>dgrams</td><td>".$DSENT{$host}."</td><td>".$DRCVD{$host}."</td></tr>\n";
157 "<tr><td>data</td><td>%i/<pp><b>%.1f%%</b></pp></td><td>%i/<pp><b>%.1f%%</b></pp></td></tr>\n",
158 $events{"+data"}, ($events{"+data"}*1029)/$sent*100,
159 $events{"-data"}, ($events{"-data"}*1029)/$rcvd*100;
161 "<tr><td>hash</td><td>%i/<pp>%.1f%%</pp></td><td>%i/<pp>%.1f%%</pp></td></tr>\n",
162 $events{"+hash"}, ($events{"+hash"}*25)/$sent*100,
163 $events{"-hash"}, ($events{"-hash"}*25)/$rcvd*100;
165 "<tr><td>ack</td><td>%i/<pp>%.1f%%</pp></td><td>%i/<pp>%.1f%%</pp></td></tr>\n",
166 $events{"+ack"}, ($events{"+ack"}*5)/$sent*100,
167 $events{"-ack"}, ($events{"-ack"}*5)/$rcvd*100;
169 "<tr><td>hint</td><td>%i/<pp>%.1f%%</pp></td><td>%i/<pp>%.1f%%</pp></td></tr>\n",
170 $events{"+hint"}, ($events{"+hint"}*5)/$sent*100,
171 $events{"-hint"}, ($events{"-hint"}*5)/$rcvd*100;
173 "<tr><td>hs</td><td>%i</td><td>%i</td></tr>\n",
174 $events{"+hs"}, $events{"-hs"};
175 my $losses = $events{"+data"}>0 ?
176 ($events{"Rdata"}+$events{"Tdata"})/$events{"+data"}*100 : 0;
178 "<tr><td>losses</td><td colspan='2'>R:%i+T:%i=%i/<pp>%.1f%%</pp></td></tr>\n",
179 $events{"Rdata"}, $events{"Tdata"},
180 $events{"Rdata"}+$events{"Tdata"}, $losses;
182 print HTML "</table>\n";