def calcTR(numberOfTraceroutes,numberOfProbes,outageDuration): if numberOfTraceroutes==0: return 0 elif numberOfProbes==0: return 0 else: rate=round(float(numberOfTraceroutes/(numberOfProbes*(outageDuration/60))),2) return rate if __name__ == "__main__": logging.basicConfig(filename='logs/{0}.log'.format(os.path.basename(sys.argv[0]).split('.')[0]), level=logging.INFO,\ format='[%(asctime)s] [%(levelname)s] %(message)s',datefmt='%m-%d-%Y %I:%M:%S') pp=PrettyPrinter() plotter=plotter() plotter.suffix='Both' fname=sys.argv[2] ot=outputWriter(resultfilename='outageEval/'+fname)#outageEvalForTMA.txt') #Master trRate List trRateB4List=[] trRateAfList=[] trRateOtList=[] trRateList=[] trrRefList=[] trrCalcList=[] #MongoDB mongodb=mongoClient()
try: int(agg) except: onlyASNs=False if onlyASNs: filterOutageByAgg.add(int(outageID)) eventsMasterDict[int(outageID)]=[outageStartStr,outageEndStr,eval(probeSet),aggregation,burstID] #Load MSMID to Dst map msmIDToDstMap={} with closing(open('data/msmIDToDst.txt')) as fp: for line in fp: mid,dstAddr=line.split(' ') msmIDToDstMap[int(mid)]=dstAddr.rstrip('\n') plotter=plotter() toPlotRatioFaultyIPsPerProbe = [] trResultsDir='tracerouteAnalysisResults/' if os.path.isdir(trResultsDir): picFiles = [join(trResultsDir, f) for f in listdir(trResultsDir) if isfile(join(trResultsDir, f))] for fname in picFiles: numberOfTraceroutes=0 numberOfFailedTraceroutes=0 numberOfSuccessfulTraceroutes=0 numberOfTraceroutesWithValidNextIP=0 problemProbes=set() problemIPs=set() problemPrefixes=set()