Author: atagar
Date: 2011-03-22 02:48:17 +0000 (Tue, 22 Mar 2011)
New Revision: 24406
Modified:
arm/trunk/armrc.sample
arm/trunk/src/interface/graphing/bandwidthStats.py
Log:
Always starting the bandwidth field from zero rather than using the state file total, which only contains the last day's worth of data (thanks to guilhem)
Modified: arm/trunk/armrc.sample
===================================================================
--- arm/trunk/armrc.sample 2011-03-22 02:25:04 UTC (rev 24405)
+++ arm/trunk/armrc.sample 2011-03-22 02:48:17 UTC (rev 24406)
@@ -136,6 +136,9 @@
# prepopulate
# attempts to use tor's state file to prepopulate the bandwidth graph at the
# 15-minute interval (this requires the minimum of a day's worth of uptime)
+# prepopulateTotal
+# populates the total stat from the state file if true (this only contains
+# the last day's worth of information, so this metric isn't the true total)
# transferInBystes
# shows rate measurments in bytes if true, bits otherwise
# accounting.show
@@ -146,6 +149,7 @@
# provides verbose measurements of time if true
features.graph.bw.prepopulate true
+features.graph.bw.prepopulateTotal false
features.graph.bw.transferInBytes false
features.graph.bw.accounting.show true
features.graph.bw.accounting.rate 10
Modified: arm/trunk/src/interface/graphing/bandwidthStats.py
===================================================================
--- arm/trunk/src/interface/graphing/bandwidthStats.py 2011-03-22 02:25:04 UTC (rev 24405)
+++ arm/trunk/src/interface/graphing/bandwidthStats.py 2011-03-22 02:48:17 UTC (rev 24406)
@@ -20,7 +20,8 @@
PREPOPULATE_SUCCESS_MSG = "Read the last day of bandwidth history from the state file"
PREPOPULATE_FAILURE_MSG = "Unable to prepopulate bandwidth information (%s)"
-DEFAULT_CONFIG = {"features.graph.bw.transferInBytes": False,
+DEFAULT_CONFIG = {"features.graph.bw.prepopulateTotal": False,
+ "features.graph.bw.transferInBytes": False,
"features.graph.bw.accounting.show": True,
"features.graph.bw.accounting.rate": 10,
"features.graph.bw.accounting.isTimeLong": False,
@@ -39,6 +40,11 @@
if config:
config.update(self._config, {"features.graph.bw.accounting.rate": 1})
+ # stats prepopulated from tor's state file
+ self.prepopulatePrimaryTotal = 0
+ self.prepopulateSecondaryTotal = 0
+ self.prepopulateTicks = 0
+
# accounting data (set by _updateAccountingInfo method)
self.accountingLastUpdated = 0
self.accountingInfo = dict([(arg, "") for arg in ACCOUNTING_ARGS])
@@ -164,10 +170,11 @@
readVal, writeVal = bwReadEntries[i], bwWriteEntries[i]
self.lastPrimary, self.lastSecondary = readVal, writeVal
- self.primaryTotal += readVal * 900
- self.secondaryTotal += writeVal * 900
- self.tick += 900
+ self.prepopulatePrimaryTotal += readVal * 900
+ self.prepopulateSecondaryTotal += writeVal * 900
+ self.prepopulateTicks += 900
+
self.primaryCounts[intervalIndex].insert(0, readVal)
self.secondaryCounts[intervalIndex].insert(0, writeVal)
@@ -316,10 +323,15 @@
def _getAvgLabel(self, isPrimary):
total = self.primaryTotal if isPrimary else self.secondaryTotal
- return "avg: %s/sec" % uiTools.getSizeLabel((total / max(1, self.tick)) * 1024, 1, False, self._config["features.graph.bw.transferInBytes"])
+ total += self.prepopulatePrimaryTotal if isPrimary else self.prepopulateSecondaryTotal
+ return "avg: %s/sec" % uiTools.getSizeLabel((total / max(1, self.tick + self.prepopulateTicks)) * 1024, 1, False, self._config["features.graph.bw.transferInBytes"])
def _getTotalLabel(self, isPrimary):
total = self.primaryTotal if isPrimary else self.secondaryTotal
+
+ if self._config["features.graph.bw.prepopulateTotal"]:
+ total += self.prepopulatePrimaryTotal if isPrimary else self.prepopulateSecondaryTotal
+
return "total: %s" % uiTools.getSizeLabel(total * 1024, 1)
def _updateAccountingInfo(self):