public
Created

Simple(ish) hacked up bandwidth logger

  • Download Gist
bandwidth.sh
Shell
1 2 3 4 5 6 7 8 9 10 11
#!/bin/bash
#Makes a CSV of UNIX Time, wget speed, and link speed from an SNMP router
TEMPFILE="/tmp/10m"
STARTBYTES=`snmpwalk -OvQ -v2c -c SNMPRO ROUTERIP 1.3.6.1.2.1.2.2.1.10.7`
STARTTIME=`date +%s`
WGETOUTPUT=`/usr/bin/wget -O$TEMPFILE "http://mirror.internode.on.net/pub/test/10meg.test" 2>&1`
FINISHBYTES=`snmpwalk -OvQ -v2c -c SNMPRO ROUTERIP 1.3.6.1.2.1.2.2.1.10.7`
FINISHTIME=`date +%s`
BPS=`echo \(\($FINISHBYTES-$STARTBYTES\)/\($FINISHTIME-$STARTTIME\)\)/1024|/usr/bin/bc`
DATALINE=`echo $WGETOUTPUT | /usr/bin/perl -ne 'print "$1 $2" if /.*(?:\()([0-9]+) (KB|MB)\/s(?:\)).*/' `
echo $STARTTIME,$DATALINE,$BPS KB >> bandwidth.csv

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.