Skip to content

Commit

Permalink
Add CPU util to iperf metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ccanel committed Apr 2, 2024
1 parent 5e6b4a9 commit 34383fc
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
Expand Down

0 comments on commit 34383fc

Please sign in to comment.