From f2b38a3de49bd73ac1c29103c9c3305b18222c6a Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 9 May 2016 17:00:24 +0300 Subject: small fix for TUI (shows CPU util. in round up float) --- .../trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'scripts/automation/trex_control_plane') diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py index c7513144..61122e79 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py @@ -28,6 +28,9 @@ SS_COMPAT = [GLOBAL_STATS, STREAMS_STATS] ExportableStats = namedtuple('ExportableStats', ['raw_data', 'text_table']) +def round_float (f): + return float("%.2f" % f) + # deep mrege of dicts dst = src + dst def deep_merge_dicts (dst, src): for k, v in src.items(): @@ -633,10 +636,10 @@ class CGlobalStats(CTRexStats): ("version", "{ver}, UUID: {uuid}".format(ver=self.server_version.get("version", "N/A"), uuid="N/A")), - ("cpu_util", "{0}% {1}".format( format_threshold(self.get("m_cpu_util"), [85, 100], [0, 85]), + ("cpu_util", "{0}% {1}".format( format_threshold(round_float(self.get("m_cpu_util")), [85, 100], [0, 85]), self.get_trend_gui("m_cpu_util", use_raw = True))), - ("rx_cpu_util", "{0}% {1}".format( format_threshold(self.get("m_rx_cpu_util"), [85, 100], [0, 85]), + ("rx_cpu_util", "{0}% {1}".format( format_threshold(round_float(self.get("m_rx_cpu_util")), [85, 100], [0, 85]), self.get_trend_gui("m_rx_cpu_util", use_raw = True))), (" ", ""), -- cgit 1.2.3-korg