[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Parsing cell-stats-end lines



commit 00e7ce52acc2ddb8f45ccae29469d3463ba39010
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun May 13 14:13:57 2012 -0700

    Parsing cell-stats-end lines
    
    Not much to this attribute. The next few are slightly different, though.
---
 stem/descriptor/extrainfo_descriptor.py      |   18 ++++++++++++++----
 test/unit/descriptor/extrainfo_descriptor.py |    2 +-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index 7008272..64a33b0 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -180,7 +180,7 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
     geoip_db_digest (str) - sha1 of geoIP database file
     signature (str)       - signature for this extrainfo descriptor (*)
     
-    Bytes read/written for relayed traffic
+    Bytes read/written for relayed traffic:
       read_history_end (datetime) - end of the sampling interval
       read_history_interval (int) - seconds per interval
       read_history_values (list)  - bytes read during each interval
@@ -189,6 +189,10 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
       write_history_interval (int) - seconds per interval
       write_history_values (list)  - bytes written during each interval
     
+    Cell relaying statistics:
+      cell_stats_end (datetime) - end of the period when stats were gathered
+      cell_stats_interval (int) - length in seconds of the interval
+    
     Directory Mirror Attributes:
       dir_stats_end (datetime) - end of the period when stats were gathered
       dir_stats_interval (int) - length in seconds of the interval
@@ -214,7 +218,7 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
       dir_v2_tunneled_dl_unknown (dict) - mapping of unrecognized stats to their measurement
       dir_v3_tunneled_dl_unknown (dict) - mapping of unrecognized stats to their measurement
       
-      Bytes read/written for directory mirroring
+      Bytes read/written for directory mirroring:
         dir_read_history_end (datetime) - end of the sampling interval
         dir_read_history_interval (int) - seconds per interval
         dir_read_history_values (list)  - bytes read during each interval
@@ -274,6 +278,9 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
     self.write_history_interval = None
     self.write_history_values = None
     
+    self.cell_stats_end = None
+    self.cell_stats_interval = None
+    
     self.dir_stats_end = None
     self.dir_stats_interval = None
     self.dir_v2_ips = None
@@ -455,13 +462,16 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
         except ValueError:
           if validate:
             raise ValueError("Timestamp on %s line wasn't parseable: %s" % (keyword, line))
-      elif keyword in ("entry-stats-end", "bridge-stats-end", "dirreq-stats-end"):
+      elif keyword in ("cell-stats-end", "entry-stats-end", "bridge-stats-end", "dirreq-stats-end"):
         # "<keyword>" YYYY-MM-DD HH:MM:SS (NSEC s)
         
         try:
           timestamp, interval, _ = _parse_timestamp_and_interval(keyword, value)
           
-          if keyword == "entry-stats-end":
+          if keyword == "cell-stats-end":
+            self.cell_stats_end = timestamp
+            self.cell_stats_interval = interval
+          elif keyword == "entry-stats-end":
             self.entry_stats_end = timestamp
             self.entry_stats_interval = interval
           elif keyword == "bridge-stats-end":
diff --git a/test/unit/descriptor/extrainfo_descriptor.py b/test/unit/descriptor/extrainfo_descriptor.py
index 1ea19da..92f37bc 100644
--- a/test/unit/descriptor/extrainfo_descriptor.py
+++ b/test/unit/descriptor/extrainfo_descriptor.py
@@ -268,7 +268,7 @@ class TestExtraInfoDescriptor(unittest.TestCase):
     "<keyword>" YYYY-MM-DD HH:MM:SS (NSEC s)
     """
     
-    for keyword in ('entry-stats-end', 'bridge-stats-end', 'dirreq-stats-end'):
+    for keyword in ('cell-stats-end', 'entry-stats-end', 'bridge-stats-end', 'dirreq-stats-end'):
       end_attr = keyword.replace('-', '_').replace('dirreq', 'dir')
       interval_attr = end_attr[:-4] + "_interval"
       



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits