[or-cvs] r20099: {torflow} Change the timestamp used at the top of the final result fil (torflow/trunk/NetworkScanners/BwAuthority)

mikeperry at seul.org mikeperry at seul.org
Tue Jul 21 09:46:19 UTC 2009

Author: mikeperry
Date: 2009-07-21 05:46:18 -0400 (Tue, 21 Jul 2009)
New Revision: 20099


Change the timestamp used at the top of the final result file
to be the oldest one of the newest timestamps from each
individual scanner. That way we will know if just one of the
scanners fails, because the authority will complain and stop
voting on bandwidths.

Modified: torflow/trunk/NetworkScanners/BwAuthority/aggregate.py
--- torflow/trunk/NetworkScanners/BwAuthority/aggregate.py	2009-07-21 04:00:11 UTC (rev 20098)
+++ torflow/trunk/NetworkScanners/BwAuthority/aggregate.py	2009-07-21 09:46:18 UTC (rev 20099)
@@ -162,12 +162,17 @@
     plog("ERROR", "Your Tor is not providing NS w bandwidths!")
+  # Take the most recent timestamp from each scanner 
+  # and use the oldest for the timestamp of the result.
+  # That way we can ensure all the scanners continue running.
+  scanner_timestamps = []
   for da in argv[1:-1]:
     # First, create a list of the most recent files in the
     # scan dirs that are recent enough
     for root, dirs, f in os.walk(da):
       for ds in dirs:
         if re.match("^scanner.[\d+]$", ds):
+          newest_timestamp = 0
           for sr, sd, files in os.walk(da+"/"+ds+"/scan-data"):
             for f in files:
               if re.search("^bws-[\S]+-done-", f):
@@ -183,11 +188,14 @@
                 if time.time() - timestamp > MAX_AGE:
                   plog("INFO", "Skipping old file "+f)
+                if timestamp > newest_timestamp:
+                  newest_timestamp = timestamp
                 bw_files.append((slicenum, timestamp, sr+"/"+f))
                 # FIXME: Can we kill this?
                 if slicenum not in timestamps or \
                      timestamps[slicenum] < timestamp:
                   timestamps[slicenum] = timestamp
+          scanner_timestamps.append(newest_timestamp)
   # Need to only use most recent slice-file for each node..
   for (s,t,f) in bw_files:
@@ -285,7 +293,7 @@
   n_print.sort(lambda x,y: int(y.change) - int(x.change))
   out = file(argv[-1], "w")
-  out.write(str(int(round(time.time(),0)))+"\n")
+  out.write(str(int(round(min(scanner_timestamps),0)))+"\n")
   for n in n_print:
     out.write("node_id="+n.idhex+" bw="+str(base10_round(n.new_bw))+" diff="+str(int(round(n.change/1000.0,0)))+ " nick="+n.nick+ " measured_at="+str(int(n.chosen_time))+"\n")

More information about the tor-commits mailing list