I often use rsync
on a OSX-based laptop to synchronise some files from it to a Linux server. The laptop can be connected to different networks with greatly varying bandwidths (office ethernet, wifi, 3G, etc.) The --bwlimit=Kbps
option allows one to control the bandwidth used in userspace by specifying a hard (well, approximately hard) limit to rsync itself. However, it's expressed in Kbps, which makes it difficult for use in automated scripts that get used on varying networks, such as the ones the laptop connects to.
Is there a way to tell rsync to use a percentage of the bandwidth rather than a limit expressed in K? Alternatively, can I easily calculate this value dynamically or wrap rsync with a script to do it?
I'd like a solution that works on OS X, or failing that Linux - ideally both.
Note: I'd like to avoid solutions that involve hardcore traffic shaping with a firewall or such. Approximate or estimated values for the limit are OK.
Assuming you have Python, you could modify speedtest-cli to change its printed results, or import it as a module into your own program and use the return values of its
downloadSpeed()
function. As is, you can get: