diff --git a/README.rst b/README.rst index 6da05fe..3118f59 100644 --- a/README.rst +++ b/README.rst @@ -72,12 +72,12 @@ Usage $ speedtest-cli -h usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--list] [--server SERVER] [--mini MINI] [--source SOURCE] - [--version] - + [--version] [--rrdfile RRDFILE] + Command line interface for testing internet bandwidth using speedtest.net. -------------------------------------------------------------------------- https://github.com/sivel/speedtest-cli - + optional arguments: -h, --help show this help message and exit --bytes Display values in bytes instead of bits. Does not affect @@ -90,6 +90,7 @@ Usage --mini MINI URL of the Speedtest Mini server --source SOURCE Source IP address to bind to --version Show the version number and exit + --rrdfile Output results to an RRD file, three columns, ping (ms), download (bits per second), and upload (bits per second) Inconsistency ------------- diff --git a/speedtest_cli.py b/speedtest_cli.py index 105c390..10efa7c 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -486,6 +486,7 @@ def speedtest(): parser.add_argument('--source', help='Source IP address to bind to') parser.add_argument('--version', action='store_true', help='Show the version number and exit') + parser.add_argument('--rrdfile', help='Output results to an RRD file, three columns, ping (ms), download (bits per second), and upload (bits per second)') options = parser.parse_args() if isinstance(options, tuple): @@ -634,6 +635,13 @@ def speedtest(): print_() print_('Upload: %0.2f M%s/s' % ((ulspeed / 1000 / 1000) * args.units[1], args.units[0])) + + if args.rrdfile: + import rrdtool + rrdping = int(round(best['latency'], 0)) + rrdDLSpeedBits = int(round(dlspeed * 8, 0)) + rrdULSpeedBits = int(round(ulspeed * 8, 0)) + ret = rrdtool.update(args.rrdfile,'N:' + `rrdping` + ':' + `rrdDLSpeedBits` + ':' + `rrdULSpeedBits`); if args.share and args.mini: print_('Cannot generate a speedtest.net share results image while '