def parse_cvla_memory_usage(query_response): response_lst = query_response.split('\r\n') res = {} res2 = {} cnt = 0 state = 0 name = '' number = 0.0 for line in response_lst: if state == 0: mtch = re.match("\W*Entity name:\W*(\w[^\r\n]+)", line) if mtch: name = misc_methods.mix_string(mtch.group(1)) state = 1 cnt += 1 elif state == 1: mtch = re.match("\W*Handle:\W*(\d+)", line) if mtch: state = state + 1 else: state = 0; elif state == 2: mtch = re.match("\W*Number of allocations:\W*(\d+)", line) if mtch: state = state + 1 number=float(mtch.group(1)) else: state = 0; elif state == 3: mtch = re.match("\W*Memory allocated:\W*(\d+)", line) if mtch: state = 0 res[name] = float(mtch.group(1)) res2[name] = number else: state = 0 if cnt == 0: raise PlatformResponseMissmatch('CVLA memory usage stats') return (res,res2)
def parse_cvla_memory_usage(query_response): response_lst = query_response.split('\r\n') res = {} res2 = {} cnt = 0 state = 0 name = '' number = 0.0 for line in response_lst: if state == 0: mtch = re.match("\W*Entity name:\W*(\w[^\r\n]+)", line) if mtch: name = misc_methods.mix_string(mtch.group(1)) state = 1 cnt += 1 elif state == 1: mtch = re.match("\W*Handle:\W*(\d+)", line) if mtch: state = state + 1 else: state = 0 elif state == 2: mtch = re.match("\W*Number of allocations:\W*(\d+)", line) if mtch: state = state + 1 number = float(mtch.group(1)) else: state = 0 elif state == 3: mtch = re.match("\W*Memory allocated:\W*(\d+)", line) if mtch: state = 0 res[name] = float(mtch.group(1)) res2[name] = number else: state = 0 if cnt == 0: raise PlatformResponseMissmatch('CVLA memory usage stats') return (res, res2)
def parse (self): """ parse(self) -> None Parse the content of the result file from the TRex test and upload the data into """ stop_read = False d = { 'total-tx' : 0, 'total-rx' : 0, 'total-pps' : 0, 'total-cps' : 0, 'expected-pps' : 0, 'expected-cps' : 0, 'expected-bps' : 0, 'active-flows' : 0, 'open-flows' : 0 } self.error = "" # Parse the output of the test, line by line (each line matches another RegEx and as such # different rules apply for line in self.lines: match = re.match(".*/var/run/.rte_config.*", line) if match: stop_read = True continue #Total-Tx : 462.42 Mbps Nat_time_out : 0 ==> we try to parse the next decimal in this case Nat_time_out # match = re.match("\W*(\w(\w|[-])+)\W*([:]|[=])\W*(\d+[.]\d+)\W*\w+\W+(\w+)\W*([:]|[=])\W*(\d+)(.*)", line); # if match: # key = misc_methods.mix_string(match.group(5)) # val = float(match.group(7)) # # continue to parse !! we try the second # self.result[key] = val #update latest # check if we need to stop reading match = re.match(".*latency daemon has stopped.*", line) if match: stop_read = True continue match = re.match("\W*(\w(\w|[-])+)\W*([:]|[=])\W*(\d+[.]\d+)(.*ps)\s+(\w+)\W*([:]|[=])\W*(\d+)", line) if match: key = misc_methods.mix_string(match.group(1)) val = float(match.group(4)) if d.has_key(key): if stop_read == False: self.update (key, val, match.group(5)) else: self.result[key] = val # update latest key2 = misc_methods.mix_string(match.group(6)) val2 = int(match.group(8)) self.result[key2] = val2 # always take latest match = re.match("\W*(\w(\w|[-])+)\W*([:]|[=])\W*(\d+[.]\d+)(.*)", line) if match: key = misc_methods.mix_string(match.group(1)) val = float(match.group(4)) if d.has_key(key): if stop_read == False: self.update (key, val, match.group(5)) else: self.result[key] = val # update latest continue match = re.match("\W*(\w(\w|[-])+)\W*([:]|[=])\W*(\d+)(.*)", line) if match: key = misc_methods.mix_string(match.group(1)) val = float(match.group(4)) self.result[key] = val #update latest continue match = re.match("\W*(\w(\w|[-])+)\W*([:]|[=])\W*(OK)(.*)", line) if match: key = misc_methods.mix_string(match.group(1)) val = 0 # valid self.result[key] = val #update latest continue match = re.match("\W*(Cpu Utilization)\W*([:]|[=])\W*(\d+[.]\d+) %(.*)", line) if match: key = misc_methods.mix_string(match.group(1)) val = float(match.group(3)) if self.result.has_key(key): if (self.result[key] < val): # update only if larger than previous value self.result[key] = val else: self.result[key] = val continue match = re.match(".*(rx_check\s.*)\s+:\s+(\w+)", line) if match: key = misc_methods.mix_string(match.group(1)) try: val = int(match.group(2)) except ValueError: # corresponds with rx_check validation case val = match.group(2) finally: self.result[key] = val continue
def parse(self): """ parse(self) -> None Parse the content of the result file from the TRex test and upload the data into """ stop_read = False d = { 'total-tx': 0, 'total-rx': 0, 'total-pps': 0, 'total-cps': 0, 'expected-pps': 0, 'expected-cps': 0, 'expected-bps': 0, 'active-flows': 0, 'open-flows': 0 } self.error = "" # Parse the output of the test, line by line (each line matches another RegEx and as such # different rules apply for line in self.lines: match = re.match(".*/var/run/.rte_config.*", line) if match: stop_read = True continue #Total-Tx : 462.42 Mbps Nat_time_out : 0 ==> we try to parse the next decimal in this case Nat_time_out # match = re.match("\W*(\w(\w|[-])+)\W*([:]|[=])\W*(\d+[.]\d+)\W*\w+\W+(\w+)\W*([:]|[=])\W*(\d+)(.*)", line); # if match: # key = misc_methods.mix_string(match.group(5)) # val = float(match.group(7)) # # continue to parse !! we try the second # self.result[key] = val #update latest # check if we need to stop reading match = re.match(".*latency daemon has stopped.*", line) if match: stop_read = True continue match = re.match( "\W*(\w(\w|[-])+)\W*([:]|[=])\W*(\d+[.]\d+)(.*ps)\s+(\w+)\W*([:]|[=])\W*(\d+)", line) if match: key = misc_methods.mix_string(match.group(1)) val = float(match.group(4)) if key in d: if stop_read == False: self.update(key, val, match.group(5)) else: self.result[key] = val # update latest key2 = misc_methods.mix_string(match.group(6)) val2 = int(match.group(8)) self.result[key2] = val2 # always take latest match = re.match("\W*(\w(\w|[-])+)\W*([:]|[=])\W*(\d+[.]\d+)(.*)", line) if match: key = misc_methods.mix_string(match.group(1)) val = float(match.group(4)) if key in d: if stop_read == False: self.update(key, val, match.group(5)) else: self.result[key] = val # update latest continue match = re.match("\W*(\w(\w|[-])+)\W*([:]|[=])\W*(\d+)(.*)", line) if match: key = misc_methods.mix_string(match.group(1)) val = float(match.group(4)) self.result[key] = val #update latest continue match = re.match("\W*(\w(\w|[-])+)\W*([:]|[=])\W*(OK)(.*)", line) if match: key = misc_methods.mix_string(match.group(1)) val = 0 # valid self.result[key] = val #update latest continue match = re.match( "\W*(Cpu Utilization)\W*([:]|[=])\W*(\d+[.]\d+) %(.*)", line) if match: key = misc_methods.mix_string(match.group(1)) val = float(match.group(3)) if key in self.result: if (self.result[key] < val): # update only if larger than previous value self.result[key] = val else: self.result[key] = val continue match = re.match(".*(rx_check\s.*)\s+:\s+(\w+)", line) if match: key = misc_methods.mix_string(match.group(1)) try: val = int(match.group(2)) except ValueError: # corresponds with rx_check validation case val = match.group(2) finally: self.result[key] = val continue