0

I am building a small Raspberry Pi based device which will have multiple 3G dongles, each with a different provider's sim card inside. I want to run the cli version of speedtest (speedtest-cli) through each interface, at timed intervals so that I can measure the signal and connection quality for each provider in certain locations. The device runs unattended and each speedtest result is then pushed to a Google doc.
I am trying to find a way how to do this in either bash or Python, where I can switch the system to use one network interface (One of the 3g Dongles or Wifi for example), run the app, log the result and then switch to the next interface in line. What is the best way to deal with this?

1 Answer 1

1

I would be looking at a for in do script like:

Ifconfig * down

for IFACE in (usb1 usb2 usb3 wlan0); do ifconfig $IFACE up && speedtest-google.script && ifconfig $IFACE down; done

Please note this is concept only, syntax oe&e, and will need tweaking to your environ.

-edit for clarity- (at a computer now)

#!/bin/bash

for IFACE in (usb1 usb2 usb3 wlan0)
 do
  ifconfig $IFACE up &&
  ./path/to/speedtest-google.script && 
  ifconfig $IFACE down
 done
3
  • Thanks, its so simple I wonder why I didn't consider it. instead i got tangled in various routing paths, custom programs to bind an interface etc.
    – Harel
    Nov 11, 2016 at 14:05
  • I must add that in some cases, strategically placed sleep calls can be used to wait for an interface going up or down
    – Harel
    Nov 14, 2016 at 9:09
  • You don't need the parentheses in for IFACE in (usb1 usb2 usb3 wlan0)
    – janos
    Dec 17, 2017 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .