Beispiel #1
0
    def get_eff_bw_stats(self, input_file):
        data = read_list(input_file, " ")
        eff_bw = []
        for row in data:
            if row[0] != "host_stat:":
                continue

            ebw = 0

            try:
                ebw = float(row[-1])
            except:
                continue

            eff_bw.append(ebw)

        return eff_bw
Beispiel #2
0
    def get_bw_stats(self, input_file, pat_iface):
        pat_iface = re.compile(pat_iface)
        data = read_list(input_file)

        rate = {}
        column = 3
        for row in data:
            try:
                ifname = row[1]
            except Exception as e:
                break
            if pat_iface.match(ifname):
                if ifname not in rate:
                    rate[ifname] = []
                try:
                    rate[ifname].append(float(row[column]) * 8.0 / (1 << 20))
                except Exception as e:
                    break
        vals = {}
        avg_bw = []
        match = 0
        avg_bw_iface = {}
        filtered_bw = {}
        for iface, bws in rate.items():
            rate[iface] = self.moving_average(bws[10:-10], 100)
            avg_bw.append(avg(bws[10:-10]))
            avg_bw_iface[iface] = avg(bws[10:-10])
            match += 1
        # Update the num of interfaces to reflect true matches
        # TODO: This is a hack. Remove.
        self.num_ifaces = match
        total_bw = list(itertools.chain.from_iterable(rate.values()))
        vals["avg_bw_iface"] = avg_bw_iface
        vals["avg_bw"] = fsum(avg_bw)
        vals["median_bw"] = np.median(total_bw)
        vals["max_bw"] = max(total_bw)
        vals["stdev_bw"] = stdev(total_bw)
        return vals, rate
Beispiel #3
0
    def get_qlen_stats(self, input_file, pat_iface):
        data = read_list(input_file)
        pat_iface = re.compile(pat_iface)
        qlen = {}
        for row in data:
            try:
                ifname = row[0]
            except Exception as e:
                break
            if pat_iface.match(ifname):
                if ifname not in qlen:
                    qlen[ifname] = []
                try:
                    qlen[ifname].append(int(row[2]))
                except Exception as e:
                    break
        vals = {}
        qlens = []
        avg_qlen_iface = {}
        full_qlen_iface = {}
        for iface, queues in qlen.items():
            qlens.append(queues)
            avg_qlen_iface[iface] = avg(queues)
            full_qlen_iface[iface] = queues

        # qlens = map(float, col(2, data))[10:-10]

        qlens = list(itertools.chain.from_iterable(qlens))
        vals["full_qlen_iface"] = full_qlen_iface
        vals["avg_qlen_iface"] = avg_qlen_iface
        vals["avg_qlen"] = avg(qlens)
        vals["median_qlen"] = np.median(qlens)
        vals["max_qlen"] = max(qlens)
        vals["stdev_qlen"] = stdev(qlens)
        vals["xcdf_qlen"], vals["ycdf_qlen"] = cdf(qlens)
        return vals