[tor-commits] [arm/release] Initializing bandwidth totals from Tor when able

atagar at torproject.org atagar at torproject.org
Sun Jul 17 06:08:16 UTC 2011


commit 301085e92801173d884e8a1282539282331244d8
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Apr 23 20:24:55 2011 -0700

    Initializing bandwidth totals from Tor when able
    
    Ticket 2345 (https://trac.torproject.org/projects/tor/ticket/2345) introduced
    GETINFO options for the total read and written bandwidth values. If these are
    available then they're used to populate the total values in arm.
---
 src/interface/graphing/bandwidthStats.py |   19 +++++++++++++++++++
 src/settings.cfg                         |    4 ++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/interface/graphing/bandwidthStats.py b/src/interface/graphing/bandwidthStats.py
index 1955465..3f34e3c 100644
--- a/src/interface/graphing/bandwidthStats.py
+++ b/src/interface/graphing/bandwidthStats.py
@@ -55,6 +55,25 @@ class BandwidthStats(graphPanel.GraphStats):
     self._titleStats, self.isAccounting = [], False
     self.resetListener(conn, torTools.State.INIT) # initializes values
     conn.addStatusListener(self.resetListener)
+    
+    # Initialized the bandwidth totals to the values reported by Tor. This
+    # uses a controller options introduced in ticket 2345:
+    # https://trac.torproject.org/projects/tor/ticket/2345
+    # 
+    # further updates are still handled via BW events to avoid unnecessary
+    # GETINFO requests. This needs to update the pause buffer too because
+    # instances start paused, causing the primary value to be clobbered once
+    # just after initalization.
+    
+    readTotal = conn.getInfo("traffic/read")
+    if readTotal and readTotal.isdigit():
+      self.primaryTotal = int(readTotal) / 1024 # Bytes -> KB
+      self._pauseBuffer.primaryTotal = int(readTotal) / 1024
+    
+    writeTotal = conn.getInfo("traffic/written")
+    if writeTotal and writeTotal.isdigit():
+      self.secondaryTotal = int(writeTotal) / 1024 # Bytes -> KB
+      self._pauseBuffer.secondaryTotal = int(writeTotal) / 1024
   
   def resetListener(self, conn, eventType):
     # updates title parameters and accounting status if they changed
diff --git a/src/settings.cfg b/src/settings.cfg
index 0e0e395..1ee63a1 100644
--- a/src/settings.cfg
+++ b/src/settings.cfg
@@ -273,6 +273,8 @@ config.summary.TestingEstimatedDescriptorPropagationTime delay before clients at
 # [ARM_DEBUG] recreating panel 'graph' with the dimensions of 14/124
 # [ARM_DEBUG] redrawing the log panel with the corrected content height (estimat was off by 4)
 # [ARM_DEBUG] GETINFO accounting/bytes-left (runtime: 0.0006)
+# [ARM_DEBUG] GETINFO traffic/read (runtime: 0.0004)
+# [ARM_DEBUG] GETINFO traffic/written (runtime: 0.0002)
 # [ARM_DEBUG] GETCONF MyFamily (runtime: 0.0007)
 # [ARM_DEBUG] Unable to query process resource usage from ps, waiting 6.25 seconds (unrecognized output from ps: ...)
 
@@ -311,6 +313,8 @@ msg.ARM_DEBUG GETINFO accounting/bytes
 msg.ARM_DEBUG GETINFO accounting/bytes-left
 msg.ARM_DEBUG GETINFO accounting/interval-end
 msg.ARM_DEBUG GETINFO accounting/hibernating
+msg.ARM_DEBUG GETINFO traffic/read
+msg.ARM_DEBUG GETINFO traffic/written
 msg.ARM_DEBUG GETCONF
 msg.ARM_DEBUG Unable to query process resource usage from ps
 





More information about the tor-commits mailing list