Skip to main content

Posts

Showing posts from March, 2006

Bandwidth Monitoring Script (through ifconfig)

Some ppl might need sumthing to monitor their bwidth … i think this script would b enough for some of us … i wrote it by myself by manipulating the output of ifconfig …

#!/bin/bashIFCONFIG="/sbin/ifconfig”
IFACE=$1
if [ “${1}” != “” ]; then
IFOUTPUT=`${IFCONFIG} ${IFACE} |grep bytes`
DOWNOLD=`echo ${IFOUTPUT}|awk ‘{print $2}’|sed s/"bytes:"//`
UPOLD=`echo ${IFOUTPUT}|grep bytes|awk ‘{print $6}’|sed s/"bytes:"//`
sleep 0.8
IFOUTPUT=`${IFCONFIG} ${IFACE} |grep bytes`
DOWNNOW=`echo ${IFOUTPUT}|awk ‘{print $2}’|sed s/"bytes:"//`
UPNOW=`echo ${IFOUTPUT}|awk ‘{print $6}’|sed s/"bytes:"//` let “UP= $UPNOW - $UPOLD”
let “DOWN= $DOWNNOW - $DOWNOLD”
let “TOTAL = UP + DOWN”
echo “—-KBps Bandwitdh Monitor—-”
echo “”
echo ” by KageSenshi”
echo “”
echo “”
echo “——————————”
echo “Bandwidth for Interface ${IFACE}”
echo “——————————”
echo “”
echo ” KBps MBps”
echo “Upload Speed $(($UP / 1024)) $((…