Created
March 25, 2020 14:11
-
-
Save simonrw/c5e89fd99fe131192ee6e3d9a9aab955 to your computer and use it in GitHub Desktop.
Script to run benchmark using iperf3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
import subprocess as sp | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
"-o", "--output", required=True, help="JSON file name to output" | |
) | |
parser.add_argument("-H", "--host", required=True) | |
parser.add_argument( | |
"-i", | |
"--interval", | |
required=False, | |
type=int, | |
default=1, | |
help="How often to perform a test", | |
) | |
parser.add_argument( | |
"-t", | |
"--time", | |
required=False, | |
default=3600, | |
type=int, | |
help="How long to run the test for", | |
) | |
parser.add_argument( | |
"-b", | |
"--bind", | |
required=False, | |
help="IP address to bind to, to e.g. specify a network interface", | |
) | |
args = parser.parse_args() | |
cmd = [ | |
"iperf3", | |
"--time", | |
str(args.time), | |
"--json", | |
"--logfile", | |
args.output, | |
"--interval", | |
str(args.interval), | |
"-c", | |
args.host, | |
] | |
if args.bind is not None: | |
cmd.extend(["--bind", args.bind]) | |
sp.run(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment