From cc910193563475c0d2695a1c5635f9ce8a9eedf5 Mon Sep 17 00:00:00 2001 From: Christopher Canel Date: Tue, 2 Apr 2024 23:34:46 +0000 Subject: [PATCH] Add sender/receiver CPU --- ratemon/scripts/iperf_metrics.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/ratemon/scripts/iperf_metrics.py b/ratemon/scripts/iperf_metrics.py index 155b6e3..a8871c6 100755 --- a/ratemon/scripts/iperf_metrics.py +++ b/ratemon/scripts/iperf_metrics.py @@ -33,18 +33,26 @@ def main(args): print(f"Error: 'end' key not found in JSON file: {args.in_file}") return 1 - bps = res["end"]["sum_sent"]["bits_per_second"] - rxmits = res["end"]["sum_sent"]["retransmits"] - cpu_total = res["end"]["cpu_utilization_percent"]["host_total"] - cpu_user = res["end"]["cpu_utilization_percent"]["host_user"] - cpu_system = res["end"]["cpu_utilization_percent"]["host_system"] + bps = res["end"]["sum_received"]["bits_per_second"] + rxmits_per_sec = res["end"]["sum_sent"]["retransmits"] / ( + res["end"]["sum_sent"]["end"] - res["end"]["sum_sent"]["start"] + ) + sender_cpu_total = res["end"]["cpu_utilization_percent"]["host_total"] + sender_cpu_user = res["end"]["cpu_utilization_percent"]["host_user"] + sender_cpu_system = res["end"]["cpu_utilization_percent"]["host_system"] + receiver_cpu_total = res["end"]["cpu_utilization_percent"]["remote_total"] + receiver_cpu_user = res["end"]["cpu_utilization_percent"]["remote_user"] + receiver_cpu_system = res["end"]["cpu_utilization_percent"]["remote_system"] msg = ( f"throughput (Gbps):{bps / 1e9:.2f}\n" - f"retransmits (total):{rxmits}\n" - f"cpu total (%):{cpu_total:.2f}\n" - f"cpu user (%):{cpu_user:.2f}\n" - f"cpu system (%):{cpu_system:.2f}" + f"retransmits (per second):{rxmits_per_sec:.2f}\n" + f"sender cpu total (%):{sender_cpu_total:.2f}\n" + f"sender cpu user (%):{sender_cpu_user:.2f}\n" + f"sender cpu system (%):{sender_cpu_system:.2f}\n" + f"receiver cpu total (%):{receiver_cpu_total:.2f}\n" + f"receiver cpu user (%):{receiver_cpu_user:.2f}\n" + f"receiver cpu system (%):{receiver_cpu_system:.2f}" ) print(msg) with open(args.out_file, "w", encoding="utf-8") as fil: