Scripts

Script for extracting the maximum hourly transfer rate, latency and quality over a certain link.

#!/usr/bin/python
#
import sys,os.path
import string,time
import urllib,urllib2
import xml.dom.minidom
from xml.dom.minidom import Node


def GetTransferResults(fromsite,tosite,nfiles,starttime):
  now=int(time.time())
  url="https://cmsweb.cern.ch/phedex/datasvc/xml/debug/TransferHistory?from="+fromsite+"&to="+tosite+"&binwidth=300&starttime="+str(starttime)+"&endtime="+str(now)
  xmldata = urllib2.urlopen(url).read() 
  dom = xml.dom.minidom.parseString(xmldata) 

  done={}
  fail={}
  rate={}
  for node in dom.getElementsByTagName('transfer'): 
    time_bin=node.attributes["timebin"].value
    done[time_bin]=node.attributes["done_files"].value
    fail[time_bin]=node.attributes["fail_files"].value
    rate[time_bin]=node.attributes["rate"].value

  sumdone=0
  sumfail=0
  lastkey=0
  maxrate=0.
  moving_average=[0,0,0,0,0,0,0,0,0,0,0,0]
  for key in sorted(done.iterkeys()):
    rate_5m=float(str(rate[key]))
    moving_average.pop(0)
    moving_average.append(rate_5m)
    avg_1h=sum(moving_average)/12.
    if ( avg_1h > maxrate ) :
      maxrate=avg_1h

    sumdone+=int(str(done[key]))
    sumfail+=int(str(fail[key]))
    lastkey=int(str(key))
    if ( sumdone >= int(str(nfiles)) ) :
      break
    if ( int(str(key)) > now ) :
      break

  maxrate/=(1024.*1024)
  latency=float(int(lastkey)-int(starttime))/3600.
  try :
    quality=float(sumdone)/float(sumdone+sumfail)*100
  except ZeroDivisionError :
    quality=-1

  print "Testing",fromsite,"to",tosite
  print "Number of files transfered......",sumdone
  print "Maximum hourly transfer rate....",("%.1f" % maxrate),"MiB/s"
  print "Latency.........................",("%.1f" % latency),"h"
  print "Quality transfer success rate...",("%.1f" % quality),"%"

  return

fromsite=sys.argv[1]
tosite=sys.argv[2]
nfiles=sys.argv[3]
starttime=sys.argv[4]
GetTransferResults(fromsite,tosite,nfiles,starttime)

-- JamesLetts - 2011/05/31


This topic: UCSDTier2 > WebHome > CMSLoadTestLHCONE > CMSLoadTestLHCONEResults > CMSLoadTestLHCONEScripts
Topic revision: r9 - 2011/06/02 - 06:34:37 - JamesLetts
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback