[or-cvs] r22550: {arm} added: logging for GETINFO and GETCONF requests fix: no long (in arm/trunk: . init interface/graphing util)

Damian Johnson atagar1 at gmail.com
Fri Jun 25 15:04:30 UTC 2010


Author: atagar
Date: 2010-06-25 15:04:30 +0000 (Fri, 25 Jun 2010)
New Revision: 22550

Modified:
   arm/trunk/armrc.sample
   arm/trunk/init/starter.py
   arm/trunk/interface/graphing/bandwidthStats.py
   arm/trunk/interface/graphing/graphPanel.py
   arm/trunk/util/torTools.py
Log:
added: logging for GETINFO and GETCONF requests
fix: no longer querying accounting data when disabled



Modified: arm/trunk/armrc.sample
===================================================================
--- arm/trunk/armrc.sample	2010-06-24 16:26:16 UTC (rev 22549)
+++ arm/trunk/armrc.sample	2010-06-25 15:04:30 UTC (rev 22550)
@@ -58,6 +58,8 @@
 log.configEntryNotFound NONE
 log.configEntryUndefined NOTICE
 log.configEntryTypeError NOTICE
+log.torGetInfo DEBUG
+log.torGetConf DEBUG
 log.sysCallMade DEBUG
 log.sysCallCached NONE
 log.sysCallFailed INFO

Modified: arm/trunk/init/starter.py
===================================================================
--- arm/trunk/init/starter.py	2010-06-24 16:26:16 UTC (rev 22549)
+++ arm/trunk/init/starter.py	2010-06-25 15:04:30 UTC (rev 22550)
@@ -130,7 +130,7 @@
       config.update(DEFAULTS)
       
       # loads user preferences for utilities
-      for utilModule in (util.conf, util.connections, util.hostnames, util.log, util.panel, util.sysTools, util.uiTools):
+      for utilModule in (util.conf, util.connections, util.hostnames, util.log, util.panel, util.sysTools, util.torTools, util.uiTools):
         utilModule.loadConfig(config)
     except IOError, exc:
       msg = "Failed to load configuration (using defaults): \"%s\"" % str(exc)

Modified: arm/trunk/interface/graphing/bandwidthStats.py
===================================================================
--- arm/trunk/interface/graphing/bandwidthStats.py	2010-06-24 16:26:16 UTC (rev 22549)
+++ arm/trunk/interface/graphing/bandwidthStats.py	2010-06-25 15:04:30 UTC (rev 22550)
@@ -73,7 +73,8 @@
         self.bwBurst = self.bwBurst.replace(".0", "")
   
   def bandwidth_event(self, event):
-    if self.isNextTickRedraw(): self._updateAccountingInfo()
+    if self.isAccounting and self.isNextTickRedraw():
+      self._updateAccountingInfo()
     
     # scales units from B to KB for graphing
     self._processEvent(event.read / 1024.0, event.written / 1024.0)

Modified: arm/trunk/interface/graphing/graphPanel.py
===================================================================
--- arm/trunk/interface/graphing/graphPanel.py	2010-06-24 16:26:16 UTC (rev 22549)
+++ arm/trunk/interface/graphing/graphPanel.py	2010-06-25 15:04:30 UTC (rev 22550)
@@ -103,7 +103,7 @@
     being redrawn.
     """
     
-    if self._graphPanel and not self.isPaused:
+    if self._graphPanel and not self.isPauseBuffer and not self.isPaused:
       updateRate = UPDATE_INTERVALS[self._graphPanel.updateInterval][1]
       if (self.tick + 1) % updateRate == 0: return True
     

Modified: arm/trunk/util/torTools.py
===================================================================
--- arm/trunk/util/torTools.py	2010-06-24 16:26:16 UTC (rev 22549)
+++ arm/trunk/util/torTools.py	2010-06-25 15:04:30 UTC (rev 22550)
@@ -41,6 +41,11 @@
 CONTROLLER = None # singleton Controller instance
 INCORRECT_PASSWORD_MSG = "Provided passphrase was incorrect"
 
+CONFIG = {"log.torGetInfo": log.DEBUG, "log.torGetConf": log.DEBUG}
+
+def loadConfig(config):
+  config.update(CONFIG)
+
 def makeCtlConn(controlAddr="127.0.0.1", controlPort=9051):
   """
   Opens a socket to the tor controller and queries its authentication type,
@@ -358,6 +363,7 @@
     
     self.connLock.acquire()
     
+    startTime = time.time()
     result, raisedExc = default, None
     if self.isAlive():
       try:
@@ -366,6 +372,9 @@
         if type(exc) == TorCtl.TorCtlClosed: self.close()
         raisedExc = exc
     
+    msg = "tor control call: GETINFO %s (runtime: %0.4f)" % (param, time.time() - startTime)
+    log.log(CONFIG["log.torGetInfo"], msg)
+    
     self.connLock.release()
     
     if not suppressExc and raisedExc: raise raisedExc
@@ -388,6 +397,7 @@
     
     self.connLock.acquire()
     
+    startTime = time.time()
     result, raisedExc = [], None
     if self.isAlive():
       try:
@@ -399,6 +409,9 @@
         if type(exc) == TorCtl.TorCtlClosed: self.close()
         result, raisedExc = default, exc
     
+    msg = "tor control call: GETCONF %s (runtime: %0.4f)" % (param, time.time() - startTime)
+    log.log(CONFIG["log.torGetConf"], msg)
+    
     self.connLock.release()
     
     if not suppressExc and raisedExc: raise raisedExc



More information about the tor-commits mailing list