[or-cvs] r22993: {arm} fix: shifting bandwidth prepopulation by a sampling interval (arm/trunk/interface/graphing)

Damian Johnson atagar1 at gmail.com
Thu Aug 19 16:31:33 UTC 2010


Author: atagar
Date: 2010-08-19 16:31:33 +0000 (Thu, 19 Aug 2010)
New Revision: 22993

Modified:
   arm/trunk/interface/graphing/bandwidthStats.py
Log:
fix: shifting bandwidth prepopulation by a sampling interval to account for tor's internal behavior (thanks to voidzero, nickm, arma, and Sebastian)



Modified: arm/trunk/interface/graphing/bandwidthStats.py
===================================================================
--- arm/trunk/interface/graphing/bandwidthStats.py	2010-08-19 16:12:13 UTC (rev 22992)
+++ arm/trunk/interface/graphing/bandwidthStats.py	2010-08-19 16:31:33 UTC (rev 22993)
@@ -113,17 +113,27 @@
     for line in stateFile:
       line = line.strip()
       
+      # According to the rep_hist_update_state() function the BWHistory*Ends
+      # correspond to the start of the following sampling period. Also, the
+      # most recent values of BWHistory*Values appear to be an incremental
+      # counter for the current sampling period. Hence, offsets are added to
+      # account for both.
+      
       if line.startswith("BWHistoryReadValues"):
         bwReadEntries = line[20:].split(",")
         bwReadEntries = [int(entry) / 1024.0 / 900 for entry in bwReadEntries]
+        bwReadEntries.pop()
       elif line.startswith("BWHistoryWriteValues"):
         bwWriteEntries = line[21:].split(",")
         bwWriteEntries = [int(entry) / 1024.0 / 900 for entry in bwWriteEntries]
+        bwWriteEntries.pop()
       elif line.startswith("BWHistoryReadEnds"):
         lastReadTime = time.mktime(time.strptime(line[18:], "%Y-%m-%d %H:%M:%S")) - tz_offset
+        lastReadTime -= 900
         missingReadEntries = int((time.time() - lastReadTime) / 900)
       elif line.startswith("BWHistoryWriteEnds"):
         lastWriteTime = time.mktime(time.strptime(line[19:], "%Y-%m-%d %H:%M:%S")) - tz_offset
+        lastWriteTime -= 900
         missingWriteEntries = int((time.time() - lastWriteTime) / 900)
     
     if not bwReadEntries or not bwWriteEntries or not lastReadTime or not lastWriteTime:



More information about the tor-commits mailing list