[or-cvs] r13693: Fixing bug 71 (torstatus/trunk)

kasimir at seul.org kasimir at seul.org
Sun Feb 24 15:19:03 UTC 2008


Author: kasimir
Date: 2008-02-24 10:19:02 -0500 (Sun, 24 Feb 2008)
New Revision: 13693

Modified:
   torstatus/trunk/tns_update.pl
Log:
Fixing bug 71

Modified: torstatus/trunk/tns_update.pl
===================================================================
--- torstatus/trunk/tns_update.pl	2008-02-24 10:41:09 UTC (rev 13692)
+++ torstatus/trunk/tns_update.pl	2008-02-24 15:19:02 UTC (rev 13693)
@@ -249,7 +249,7 @@
 	{
 		$currentRouter{'BandwidthMAX'} = $1;
 		$currentRouter{'BandwidthBURST'} = $2;
-		$currentRouter{'BandwidthOBSERVED'} = $3;
+		#$currentRouter{'BandwidthOBSERVED'} = $3;  # Bandwidth calculated now
 	}
 
 	# Format for the platform line
@@ -380,6 +380,11 @@
 		# Serialize the last part of the data
 		@readhistory = split(/,/,$4);
 		$currentRouter{'ReadHistorySERDATA'} = serialize(\@readhistory);
+		# Add to the observed bandwidth counter
+		foreach my $num (@readhistory)
+		{
+			$currentRouter{'bandwidthcounter'} += $num;
+		}
 
 	}
 
@@ -410,6 +415,11 @@
 		# Serialize the last part of the data
 		@writehistory = split(/,/,$4);
 		$currentRouter{'WriteHistorySERDATA'} = serialize(\@writehistory);
+		# Add to the observed bandwidth counter
+		foreach my $num (@writehistory)
+		{
+			$currentRouter{'bandwidthcounter'} += $num;
+		}
 	}
 
 	# Format for the router-signature line
@@ -498,6 +508,11 @@
 				# Serialize the last part of the data
 				@readhistory = split(/,/,$4);
 				$currentRouter{'ReadHistorySERDATA'} = serialize(\@readhistory);
+				# Add to the observed bandwidth counter
+				foreach my $num (@readhistory)
+				{
+					$currentRouter{'bandwidthcounter'} += $num;
+				}
 			}
 		
 			# Format for the write-history line
@@ -527,11 +542,19 @@
 				# Serialize the last part of the data
 				@writehistory = split(/,/,$4);
 				$currentRouter{'WriteHistorySERDATA'} = serialize(\@writehistory);
+				# Add to the observed bandwidth counter
+				foreach my $num (@writehistory)
+				{
+					$currentRouter{'bandwidthcounter'} += $num;
+				}
 			}
 		}
 		# Close the new Tor connection
 		close ($digestSocket);
 		}
+
+		# Calculate the bandwidth
+		$currentRouter{'BandwidthOBSERVED'} = $currentRouter{'bandwidthcounter'}/172800;
 		
 		# Save the data to the MySQL database
 		$dbresponse->execute( $currentRouter{'nickname'},



More information about the tor-commits mailing list