Example #1
0
    def __init__(self, nopull=False, keep=False, date=None, xstats=False):

        PXPaths.normalPaths()
        self.manager = PXManager()
        #self.logger = logger.getLogger()

        # Date for which we want to obtain stats
        if date == None:
            self.date = dateLib.getYesterdayFormatted()  # ISO Date
        else:
            self.date = date

        self.dateDashed = dateLib.getISODateDashed(self.date)

        self.machines = []  # Machines were the logs can be found
        self.sources = [
        ]  # Sources for which we will check arrival time of the products
        self.client = [
        ]  # Client for which we will check delivery time of the products (ONLY ONE ENTRY in the list)
        self.messages = []  # FIXME: Special messages coming from weird results

        self.nopull = nopull  # Do not pull the necessary files (we suppose they are already downloaded)
        self.keep = keep  # Erase all the files present before downloading new files
        self.xstats = xstats  # Boolean that determine if we will use xferlog in making stats

        self.goodRx = []  # Lines matching initial values
        self.goodTx = []  # Lines matching initial values
        self.goodXferlog = []  # Lines matching initial values

        self.receivingInfos = {
        }  # Dict. addressed by filename and containing a tuple of (formatted date, date in seconds, machine)
        self.sendingInfos = {
        }  # Dict. addressed by filename and containing a tuple of (formatted date, date in seconds, machine)
        self.xferlogInfos = {
        }  # Dict. addressed by filename and containing a tuple of (formatted date, date in seconds, machine)

        self.stats = {}  # Final stats
        self.sortedStats = []  # Final sorted stats
        self.max = 0  # Maximum latency time in seconds
        self.min = sys.maxint  # Minimum latency time in seconds
        self.mean = 0  # Mean latency time in seconds
        self.latencyThreshold = 15  # We don't want to go over this threshold (in seconds)
        self.overThreshold = 0  # Number of files with latency over threshold
        self.underThresholdP = 0  # Percentage of files for which the latency is equal or under threshold
        self.meanWaiting = 0  # Mean waiting time before being noticed by the PDS

        self.random = str(
            random.random()
        )[2:]  # Unique identificator permitting the program to be run in parallel
        self.system = None  # 'PDS' or 'PX'
        self.rejected = 0  # Count of rejected files
        self.maxInfos = ['NO FILE', ('00:00:00', 'No machine', 0)
                         ]  # Informations about the max.
Example #2
0
    def __init__(self, nopull=False, keep=False, date=None, xstats=False):

        PXPaths.normalPaths()
        self.manager = PXManager()
        #self.logger = logger.getLogger()

        # Date for which we want to obtain stats
        if date == None:
            self.date = dateLib.getYesterdayFormatted() # ISO Date
        else:
            self.date = date

        self.dateDashed = dateLib.getISODateDashed(self.date)

        self.machines = []         # Machines were the logs can be found
        self.sources = []          # Sources for which we will check arrival time of the products
        self.client = []           # Client for which we will check delivery time of the products (ONLY ONE ENTRY in the list)
        self.messages = []         # FIXME: Special messages coming from weird results

        self.nopull = nopull       # Do not pull the necessary files (we suppose they are already downloaded)
        self.keep =  keep          # Erase all the files present before downloading new files
        self.xstats = xstats       # Boolean that determine if we will use xferlog in making stats

        self.goodRx = []           # Lines matching initial values
        self.goodTx = []           # Lines matching initial values
        self.goodXferlog = []      # Lines matching initial values

        self.receivingInfos = {}   # Dict. addressed by filename and containing a tuple of (formatted date, date in seconds, machine) 
        self.sendingInfos = {}     # Dict. addressed by filename and containing a tuple of (formatted date, date in seconds, machine) 
        self.xferlogInfos = {}     # Dict. addressed by filename and containing a tuple of (formatted date, date in seconds, machine) 

        self.stats = {}            # Final stats
        self.sortedStats = []      # Final sorted stats
        self.max = 0               # Maximum latency time in seconds
        self.min = sys.maxint      # Minimum latency time in seconds
        self.mean = 0              # Mean latency time in seconds
        self.latencyThreshold = 15 # We don't want to go over this threshold (in seconds)
        self.overThreshold = 0     # Number of files with latency over threshold
        self.underThresholdP = 0   # Percentage of files for which the latency is equal or under threshold
        self.meanWaiting = 0       # Mean waiting time before being noticed by the PDS

        self.random = str(random.random())[2:]   # Unique identificator permitting the program to be run in parallel
        self.system = None                       # 'PDS' or 'PX'
        self.rejected = 0                        # Count of rejected files
        self.maxInfos = ['NO FILE', ('00:00:00', 'No machine', 0)]   # Informations about the max.
Example #3
0
    def plot(self):

        self.graph('set size 1.5, %2.1f' % (0.5 * len(self.latenciers)))
        self.graph('set origin 0, 0') 

        i = 0
        nbLatenciers = len (self.latenciers)
        for latencier in self.latenciers:
            machines = []
            for machine in latencier.machines:
                machines.append(machine.split('.')[0])


            systemString = 'System: %s' % latencier.system
            machinesString = 'Machines: %s' % str(machines)
            clientString = 'Client: %s' % latencier.client
            if latencier.sources[0] == '__ALL__':
                sourcesString = 'Sources: **ALL**'
            else:
                sourcesString = 'Sources: %s' % str(latencier.sources)
            rejectedString = '# Files rejected: %i' % latencier.rejected
            overThresholdString = '# Files with lat. over %i seconds: %i' % (latencier.latencyThreshold, latencier.overThreshold)
            underThresholdPString = '%% of files with lat. under %i seconds: %4.2f' % (latencier.latencyThreshold, latencier.underThresholdP)
            (filename, (time, host, lat)) = latencier.maxInfos
            maxInfos1 = 'Maximum occurs at: %s' % (time)
            maxInfos2 = '%s (%s)' % (filename.split(':')[0], host)
            xferlogString = 'Xferlog used: %s' % ['No', 'Yes'][latencier.xstats]


            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (systemString, 0.40 + ((nbLatenciers -1) - i) * 0.5))
            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (machinesString, 0.38 + ((nbLatenciers -1) - i) * 0.5))
            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (clientString, 0.36 + ((nbLatenciers -1) -i) * 0.5))
            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (sourcesString, 0.34  + ((nbLatenciers -1) -i) * 0.5))
            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (xferlogString, 0.32  + ((nbLatenciers -1) -i) * 0.5))
            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (maxInfos1, 0.30 + ((nbLatenciers -1) - i) * 0.5))
            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (maxInfos2, 0.28 + ((nbLatenciers -1) - i) * 0.5))
            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (underThresholdPString, 0.26 + ((nbLatenciers -1) - i) * 0.5))
            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (overThresholdString, 0.24 + ((nbLatenciers -1) - i) * 0.5))
            self.graph('set label "%s" at screen 1.00, screen %3.2f' % (rejectedString, 0.22 + ((nbLatenciers -1) - i) * 0.5))
            i += 1

        self.graph('set linestyle 1 lt 4 lw 5')
        self.graph('set linestyle 2 lt 3 lw 3')

        #self.graph('set key left top Left title "%s" box 1' % machinesString)
        #self.graph('set key left samplen 3 top Left title "%s" box 1' % sourcesString)
        #self.graph('set key left bottom')
        #self.graph('set key box linestyle 1')

        self.graph('set lmargin 8')
        
        self.graph.xlabel('time (hours)')
        self.graph.ylabel('latency (seconds)')

        self.graph('set grid')
        #self.graph('set grid linestyle 1')
        #self.graph('set xtics ("low" 0, "medium" 30, "high" 100)')
        self.graph('set xtics (%s)' % self.xtics)

        if self.type == 'lines':
            self.graph('set data style lines')  
        elif self.type == 'impulses':
            self.graph('set data style impulses')  
        elif self.type == 'boxes':
            self.graph('set data style boxes')  
        elif self.type == 'linespoints':
            self.graph('set data style linespoints')  

        self.graph('set terminal png small color')

        #self.graph.plot([[0, 1.1], [1, 5.8], [2, 3.3], [3, 100]])

        self.imageName = "%s_latencies.%s_%s.png" % (self.latenciers[0].pattern, self.latenciers[0].date, self.latenciers[0].random)

        self.graph('set output "%s%s"' % (PXPaths.LAT_RESULTS, self.imageName))

        self.graph('set multiplot')
        
        const = len(self.latenciers) -1
        for i in range(len(self.latenciers)):
            if i == 0:
                color = 1
            elif i == 1:
                color = 3 
            else:
                color = i + 2

            self.graph('set size 1, 0.5')
            self.graph('set origin 0, %3.2f' % ((const - i) * 0.5))
            try:
                if self.latenciers[i].xstats:
                    self.graph("set key title 'MAX: %i,  MEAN: %4.2f (mean wait: %4.2f),  MIN: %i  (#files: %i)' box lt 2" % (
                                               self.latenciers[i].max, self.latenciers[i].mean,
                                               self.latenciers[i].meanWaiting, self.latenciers[i].min, len(self.latenciers[i].sortedStats)))
                else:
                    self.graph("set key title 'MAX: %i,  MEAN: %4.2f,  MIN: %i  (#files: %i)' box lt 2" % (
                                               self.latenciers[i].max, self.latenciers[i].mean,
                                               self.latenciers[i].min, len(self.latenciers[i].sortedStats)))
            except AttributeError:
                self.graph("set key title 'MAX: %i,  MEAN: %4.2f,  MIN: %i  (#files: %i)' box lt 2" % (
                                           self.latenciers[i].max, self.latenciers[i].mean,
                                           self.latenciers[i].min, len(self.latenciers[i].sortedStats)))
            
            if self.latenciers[i].pattern == '__ALL__':
                pattern = 'ALL'
            else:
                pattern = self.latenciers[i].pattern

            self.graph.title('%s Latencies for %s (%s)' % (pattern, str(self.latenciers[i].client), dateLib.getISODateDashed(latencier.date)))
            self.graph.plot(Gnuplot.Data(self.getPairs(self.latenciers[i].sortedStats), with="%s %s 2" % (self.type, color)))
    
            #plotItem = Gnuplot.PlotItems.PlotItem(Gnuplot.Data(self.getPairs(self.latenciers[0].sortedStats), title="MPCN")
            #self.graph.plot(self.getPairs(self.latenciers[0].sortedStats), title="MPCN")
            #self.graph.plot(Gnuplot.Data(self.getPairs(self.latenciers[0].sortedStats), title="MPCN", with="lines 3 2"))
            #self.graph.plot('x')
    
        # FIXME: I start the saving of the file with this (garbage collector). Better command must exist.
        self.graph = None