summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/common/trex_stats.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/common/trex_stats.py')
-rwxr-xr-xscripts/automation/trex_control_plane/common/trex_stats.py48
1 files changed, 46 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/common/trex_stats.py b/scripts/automation/trex_control_plane/common/trex_stats.py
index a6add4ac..3f64310f 100755
--- a/scripts/automation/trex_control_plane/common/trex_stats.py
+++ b/scripts/automation/trex_control_plane/common/trex_stats.py
@@ -59,7 +59,7 @@ def calculate_diff_raw (samples):
class CTRexInfoGenerator(object):
"""
This object is responsible of generating stats and information from objects maintained at
- CTRexStatelessClient and the ports.
+ STLClient and the ports.
"""
def __init__(self, global_stats_ref, ports_dict_ref):
@@ -260,7 +260,7 @@ class CTRexStats(object):
def __init__(self):
self.reference_stats = None
- self.latest_stats = {}
+ self.latest_stats = None
self.last_update_ts = time.time()
self.history = deque(maxlen = 10)
@@ -314,9 +314,11 @@ class CTRexStats(object):
self.last_update_ts = time.time()
+
def clear_stats(self):
self.reference_stats = self.latest_stats
+
def invalidate (self):
self.latest_stats = {}
@@ -333,6 +335,10 @@ class CTRexStats(object):
return "N/A"
if not format:
+ if not field in self.reference_stats:
+ print "REF: " + str(self.reference_stats)
+ print "BASE: " + str(self.latest_stats)
+
return (self.latest_stats[field] - self.reference_stats[field])
else:
return format_num(self.latest_stats[field] - self.reference_stats[field], suffix)
@@ -399,6 +405,24 @@ class CGlobalStats(CTRexStats):
self.server_version = server_version
self._ports_dict = ports_dict_ref
+ def get_stats (self):
+ stats = {}
+
+ # absolute
+ stats['cpu_util'] = self.get("m_cpu_util")
+ stats['tx_bps'] = self.get("m_tx_bps")
+ stats['tx_pps'] = self.get("m_tx_pps")
+
+ stats['rx_bps'] = self.get("m_rx_bps")
+ stats['rx_pps'] = self.get("m_rx_pps")
+ stats['rx_drop_bps'] = self.get("m_rx_drop_bps")
+
+ # relatives
+ stats['queue_full'] = self.get_rel("m_total_queue_full")
+
+ return stats
+
+
def generate_stats(self):
return OrderedDict([("connection", "{host}, Port {port}".format(host=self.connection_info.get("server"),
port=self.connection_info.get("sync_port"))),
@@ -453,6 +477,9 @@ class CPortStats(CTRexStats):
raise TypeError("cannot add non stats object to stats")
# main stats
+ if not self.latest_stats:
+ self.latest_stats = {}
+
self.__merge_dicts(self.latest_stats, x.latest_stats)
# reference stats
@@ -471,6 +498,23 @@ class CPortStats(CTRexStats):
return self
+ # for port we need to do something smarter
+ def get_stats (self):
+ stats = {}
+
+ stats['opackets'] = self.get_rel("opackets")
+ stats['ipackets'] = self.get_rel("ipackets")
+ stats['obytes'] = self.get_rel("obytes")
+ stats['ibytes'] = self.get_rel("ibytes")
+ stats['oerrors'] = self.get_rel("oerrors")
+ stats['ierrors'] = self.get_rel("ierrors")
+ stats['tx_bps'] = self.get("m_total_tx_bps")
+ stats['tx_pps'] = self.get("m_total_tx_pps")
+ stats['rx_bps'] = self.get("m_total_rx_bps")
+ stats['rx_pps'] = self.get("m_total_rx_pps")
+
+ return stats
+
def generate_stats(self):