From 34383fc18142a1e0993e0eb686a6cc93cab0521c Mon Sep 17 00:00:00 2001 From: Christopher Canel Date: Tue, 2 Apr 2024 14:55:54 +0000 Subject: [PATCH] Add CPU util to iperf metrics --- .../{tput_rxmits.py => iperf_metrics.py} | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) rename ratemon/scripts/{tput_rxmits.py => iperf_metrics.py} (61%) diff --git a/ratemon/scripts/tput_rxmits.py b/ratemon/scripts/iperf_metrics.py similarity index 61% rename from ratemon/scripts/tput_rxmits.py rename to ratemon/scripts/iperf_metrics.py index 0e2ba86..155b6e3 100755 --- a/ratemon/scripts/tput_rxmits.py +++ b/ratemon/scripts/iperf_metrics.py @@ -10,7 +10,10 @@ def parse_args(): parser = argparse.ArgumentParser( - description="Calculate average throughput and retransmission count" + description=( + "Parse iperf3 sender JSON log file to determine " + "average throughput, retransmission count, and CPU utilization." + ) ) parser.add_argument( "--in-file", @@ -32,7 +35,17 @@ def main(args): bps = res["end"]["sum_sent"]["bits_per_second"] rxmits = res["end"]["sum_sent"]["retransmits"] - msg = f"Throughput: {bps / 1e9:.2f} Gbps\nRetransmits: {rxmits}" + 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"] + + 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}" + ) print(msg) with open(args.out_file, "w", encoding="utf-8") as fil: fil.write(msg)