Skip to content

Instantly share code, notes, and snippets.

@lanrat
Created December 21, 2015 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lanrat/7d22c7c07a9b0da4e68a to your computer and use it in GitHub Desktop.
Save lanrat/7d22c7c07a9b0da4e68a to your computer and use it in GitHub Desktop.
DD-WRT SNMP bandwidth
#!/usr/bin/env bash
HOST=192.168.1.1
IFACE_ID=3
SAMPLE=5
## iface
NAME=$(snmpget -v 2c -c public -O q $HOST iso.3.6.1.2.1.2.2.1.2.$IFACE_ID | cut -d ' ' -f2)
echo "Bandwidth for $NAME"
## bytes
D1=$(snmpget -v 2c -c public -O q $HOST iso.3.6.1.2.1.2.2.1.10.$IFACE_ID | cut -d ' ' -f2)
U1=$(snmpget -v 2c -c public -O q $HOST iso.3.6.1.2.1.2.2.1.16.$IFACE_ID | cut -d ' ' -f2)
sleep $SAMPLE
D2=$(snmpget -v 2c -c public -O q $HOST iso.3.6.1.2.1.2.2.1.10.$IFACE_ID | cut -d ' ' -f2)
U2=$(snmpget -v 2c -c public -O q $HOST iso.3.6.1.2.1.2.2.1.16.$IFACE_ID | cut -d ' ' -f2)
D=$((($D2-$D1)/$SAMPLE))
U=$((($U2-$U1)/$SAMPLE))
echo "Down ${D} bytes/seccond"
echo "Up ${U} bytes/seccond"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment