[or-cvs] r19086: {torctl torflow} Print out interesting ratios with a higher precision to sepa (torctl/trunk/python/TorCtl torflow/trunk torflow/trunk/NetworkScanners)
mikeperry at seul.org
mikeperry at seul.org
Thu Mar 19 08:13:15 UTC 2009
Author: mikeperry
Date: 2009-03-19 04:13:15 -0400 (Thu, 19 Mar 2009)
New Revision: 19086
Modified:
torctl/trunk/python/TorCtl/StatsSupport.py
torflow/trunk/NetworkScanners/speedracer.py
torflow/trunk/metatroller.py
Log:
Print out interesting ratios with a higher precision to
separate file.
Modified: torctl/trunk/python/TorCtl/StatsSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/StatsSupport.py 2009-03-19 04:05:41 UTC (rev 19085)
+++ torctl/trunk/python/TorCtl/StatsSupport.py 2009-03-19 08:13:15 UTC (rev 19086)
@@ -243,13 +243,29 @@
if bw == 0.0: return 0
else: return self.bw/(1024.*bw)
- def strm_ratio(self):
+ def strm_bw_ratio(self):
"""Return the ratio of the Router's stream capacity to the average
stream capacity passed in as 'mean'"""
bw = self.bwstats.mean
if StatsRouter.global_mean == 0.0: return 0
else: return (1.0*bw)/StatsRouter.global_mean
+ def circ_fail_ratio(self):
+ if self.circ_chosen == 0: return 0
+ return (1.0*self.circ_failed)/self.circ_chosen
+
+ def strm_fail_ratio(self):
+ if self.strm_chosen == 0: return 0
+ return (1.0*self.strm_failed)/self.strm_chosen
+
+ def circ_succeed_ratio(self):
+ if self.circ_chosen == 0: return 1
+ return (1.0*(self.circ_succeeded))/self.circ_chosen
+
+ def strm_succeed_ratio(self):
+ if self.strm_chosen == 0: return 1
+ return (1.0*(self.strm_succeeded))/self.strm_chosen
+
def current_uptime(self):
if self.became_active_at:
ret = (self.total_active_uptime+(time.time()-self.became_active_at))
@@ -311,7 +327,7 @@
+" BR="+str(round(self.bw_ratio(),1))
+" ZR="+str(round(self.z_ratio,1))
+" PR="+(str(round(self.prob_zr,3))[1:])
- +" SR="+(str(round(self.strm_ratio(),1)))
+ +" SR="+(str(round(self.strm_bw_ratio(),1)))
+" U="+str(round(self.current_uptime()/3600, 1))+"\n")
def sanity_check(self):
@@ -411,23 +427,41 @@
for r in rlist:
# only print it if we've used it.
if r.circ_chosen+r.strm_chosen > 0: f.write(str(r))
-
+
+ def write_ratios(self, filename):
+ "Write out bandwith ratio stats StatsHandler has gathered"
+ plog("DEBUG", "Writing ratios to "+filename)
+ f = file(filename, "w")
+ (avg, dev) = self.run_zbtest()
+ StatsRouter.global_mean = avg
+ strm_bw_ratio = copy.copy(self.sorted_r)
+ strm_bw_ratio.sort(lambda x, y: cmp(x.strm_bw_ratio(), y.strm_bw_ratio()))
+ for r in strm_bw_ratio:
+ if r.circ_chosen == 0: continue
+ f.write(r.idhex+"="+r.nickname+"\n ")
+ f.write("SR="+str(round(r.strm_bw_ratio(),4))+" BR="+str(round(r.bw_ratio(),4))+" CSR="+str(round(r.circ_succeed_ratio(),4))+" SSR="+str(round(r.strm_succeed_ratio(),4))+" CFR="+str(round(1-r.circ_fail_ratio(),4))+" SFR="+str(round(1-r.strm_fail_ratio(),4))+"\n")
+ f.close()
+
def write_stats(self, filename):
"Write out all the statistics the StatsHandler has gathered"
# TODO: all this shit should be configurable. Some of it only makes
# sense when scanning in certain modes.
- plog("DEBUG", "Writing stats")
+ plog("DEBUG", "Writing stats to "+filename)
# Sanity check routers
for r in self.sorted_r: r.sanity_check()
# Sanity check the router reason lists.
for r in self.sorted_r:
for rsn in r.reason_failed:
- if r not in self.failed_reasons[rsn].rlist:
- plog("ERROR", "Router missing from reason table")
+ if rsn not in self.failed_reasons:
+ plog("ERROR", "Router "+r.idhex+" w/o reason "+rsn+" in fail table")
+ elif r not in self.failed_reasons[rsn].rlist:
+ plog("ERROR", "Router "+r.idhex+" missing from fail table")
for rsn in r.reason_suspected:
- if r not in self.suspect_reasons[rsn].rlist:
- plog("ERROR", "Router missing from reason table")
+ if rsn not in self.suspect_reasons:
+ plog("ERROR", "Router "+r.idhex+" w/o reason "+rsn+" in fail table")
+ elif r not in self.suspect_reasons[rsn].rlist:
+ plog("ERROR", "Router "+r.idhex+" missing from suspect table")
# Sanity check the lists the other way
for rsn in self.failed_reasons.itervalues(): rsn._verify_failed()
@@ -437,11 +471,11 @@
f.write(StatsRouter.key)
(avg, dev) = self.run_zbtest()
f.write("\n\nBW stats: u="+str(round(avg,1))+" s="+str(round(dev,1))+"\n")
+ StatsRouter.global_mean = avg
(avg, dev) = self.run_zrtest()
f.write("BW ratio stats: u="+str(round(avg,1))+" s="+str(round(dev,1))+"\n")
- StatsRouter.global_mean = avg
# Circ, strm infoz
f.write("Circ failure ratio: "+str(self.circ_failed)
@@ -466,9 +500,9 @@
self.write_routers(f, bw_rate, "Bandwidth Ratios")
# sort+print by bandwidth
- strm_ratio = copy.copy(self.sorted_r)
- strm_ratio.sort(lambda x, y: cmp(x.strm_ratio(), y.strm_ratio()))
- self.write_routers(f, strm_ratio, "Stream Ratios")
+ strm_bw_ratio = copy.copy(self.sorted_r)
+ strm_bw_ratio.sort(lambda x, y: cmp(x.strm_bw_ratio(), y.strm_bw_ratio()))
+ self.write_routers(f, strm_bw_ratio, "Stream Ratios")
failed = copy.copy(self.sorted_r)
failed.sort(lambda x, y:
Modified: torflow/trunk/NetworkScanners/speedracer.py
===================================================================
--- torflow/trunk/NetworkScanners/speedracer.py 2009-03-19 04:05:41 UTC (rev 19085)
+++ torflow/trunk/NetworkScanners/speedracer.py 2009-03-19 08:13:15 UTC (rev 19086)
@@ -128,6 +128,7 @@
if (successful % save_every) == 0:
meta.send_command_and_check('CLOSEALLCIRCS')
meta.send_command_and_check('SAVESTATS '+os.getcwd()+'/data/speedraces/stats-'+str(skip)+':'+str(pct)+"-"+str(successful)+"-"+race_time)
+ meta.send_command_and_check('SAVERATIOS '+os.getcwd()+'/data/speedraces/ratios-'+str(skip)+':'+str(pct)+"-"+str(successful)+"-"+race_time)
meta.send_command_and_check('COMMIT')
plog('INFO', str(skip) + '-' + str(pct) + '% ' + str(count) + ' fetches took ' + str(attempt) + ' tries.')
@@ -173,6 +174,7 @@
plog('DEBUG', 'speedroced')
meta.send_command_and_check('CLOSEALLCIRCS')
meta.send_command_and_check('SAVESTATS '+os.getcwd()+'/data/speedraces/stats-'+str(pct) + ':' + str(pct + pct_step)+"-"+str(count)+"-"+strftime("20%y-%m-%d-%H:%M:%S"))
+ meta.send_command_and_check('SAVERATIOS '+os.getcwd()+'/data/speedraces/ratios-'+str(pct) + ':' + str(pct + pct_step)+"-"+str(count)+"-"+strftime("20%y-%m-%d-%H:%M:%S"))
plog('DEBUG', 'Wrote stats')
pct += pct_step
meta.send_command_and_check('COMMIT')
Modified: torflow/trunk/metatroller.py
===================================================================
--- torflow/trunk/metatroller.py 2009-03-19 04:05:41 UTC (rev 19085)
+++ torflow/trunk/metatroller.py 2009-03-19 08:13:15 UTC (rev 19086)
@@ -204,7 +204,17 @@
else:
s.write("510 Argument expected\r\n")
elif command == "GUARDNODES":
- s.write("250 OK\r\n")
+ try:
+ if arg:
+ use_guards = bool(int(arg))
+ plog("DEBUG", "Got Setexit: "+str(use_guards))
+ def notlambda(sm):
+ plog("DEBUG", "Job for setexit: "+str(use_guards))
+ sm.use_guards = use_guards
+ h.schedule_selmgr(notlambda)
+ s.write("250 OK\r\n")
+ except ValueError:
+ s.write("510 Integer expected\r\n")
elif command == "CLOSEALLCIRCS":
def notlambda(this): this.close_all_circuits()
h.schedule_immediate(notlambda)
@@ -215,6 +225,12 @@
def notlambda(this): this.write_stats(filename)
h.schedule_low_prio(notlambda)
s.write("250 OK\r\n")
+ elif command == "SAVERATIOS":
+ if arg: rfilename = arg
+ else: rfilename="./data/stats/ratios-"+time.strftime("20%y-%m-%d-%H:%M:%S")
+ def notlambda(this): this.write_ratios(rfilename)
+ h.schedule_low_prio(notlambda)
+ s.write("250 OK\r\n")
elif command == "RESETSTATS":
plog("DEBUG", "Got resetstats")
def notlambda(this): this.reset_stats()
More information about the tor-commits
mailing list