Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix indention

  • Loading branch information...
commit 730f4d94558ffb70e3184875076b7deceb35888e 1 parent 08bab89
@housemaister authored
Showing with 43 additions and 43 deletions.
  1. +43 −43 net/netspeed
View
86 net/netspeed
@@ -30,13 +30,13 @@ while getopts ":rkbi:" opt; do
done
if [ -z "$IF" ]; then
- echo "$0: prints the tx/rx speed/bytes at given network interface in b/s"
- echo " usage: $0 [-rkb] -i network-interface"
- echo " e.g. $0 -i eth0"
- echo " -k sets the unit to kbyte(/s)"
- echo " -b outputs the total (k)byte; without the output is (k)byte/s"
- echo " -r outputs in raw format: TIMESTAMP tx rx"
- exit 1
+ echo "$0: prints the tx/rx speed/bytes at given network interface in b/s"
+ echo " usage: $0 [-rkb] -i network-interface"
+ echo " e.g. $0 -i eth0"
+ echo " -k sets the unit to kbyte(/s)"
+ echo " -b outputs the total (k)byte; without the output is (k)byte/s"
+ echo " -r outputs in raw format: TIMESTAMP tx rx"
+ exit 1
fi
R2=`cat /sys/class/net/$IF/statistics/rx_bytes`
@@ -45,41 +45,41 @@ TIMESTAMP=`date +%s.%N`
while true
do
- R1=$R2
- T1=$T2
- OLDTIMESTAMP=$TIMESTAMP
- sleep 1
- R2=`cat /sys/class/net/$IF/statistics/rx_bytes`
- T2=`cat /sys/class/net/$IF/statistics/tx_bytes`
- TIMESTAMP=`date +%s.%N`
- DELTAT=`expr $T2 - $T1`
- DELTAR=`expr $R2 - $R1`
- DELTATIME=`echo "scale=8; $TIMESTAMP - $OLDTIMESTAMP" | bc`
- if [ "$byte" -eq 1 ]; then
- if [ "$kb" -eq 1 ]; then
- TSPEED=`expr $DELTAT / 1024`
- RSPEED=`expr $DELTAR / 1024`
- UNIT='kbyte'
- else
- TSPEED=$DELTAT
- RSPEED=$DELTAR
- UNIT='byte'
- fi
- else
- if [ "$kb" -eq 1 ]; then
- TSPEED=`echo "scale=0; $DELTAT / 1024 / $DELTATIME" | bc`
- RSPEED=`echo "scale=0; $DELTAR / 1024 / $DELTATIME" | bc`
- UNIT='kb/s'
- else
- TSPEED=`echo "scale=0; $DELTAT / $DELTATIME" | bc`
- RSPEED=`echo "scale=0; $DELTAR / $DELTATIME" | bc`
- UNIT='b/s'
- fi
- fi
- if [ "$raw" -eq 1 ]; then
- echo -e "$TIMESTAMP $TSPEED $RSPEED"
- else
- echo -e "[$TIMESTAMP]\ttx $IF: $TSPEED $UNIT \trx $IF: $RSPEED $UNIT"
- fi
+ R1=$R2
+ T1=$T2
+ OLDTIMESTAMP=$TIMESTAMP
+ sleep 1
+ R2=`cat /sys/class/net/$IF/statistics/rx_bytes`
+ T2=`cat /sys/class/net/$IF/statistics/tx_bytes`
+ TIMESTAMP=`date +%s.%N`
+ DELTAT=`expr $T2 - $T1`
+ DELTAR=`expr $R2 - $R1`
+ DELTATIME=`echo "scale=8; $TIMESTAMP - $OLDTIMESTAMP" | bc`
+ if [ "$byte" -eq 1 ]; then
+ if [ "$kb" -eq 1 ]; then
+ TSPEED=`expr $DELTAT / 1024`
+ RSPEED=`expr $DELTAR / 1024`
+ UNIT='kbyte'
+ else
+ TSPEED=$DELTAT
+ RSPEED=$DELTAR
+ UNIT='byte'
+ fi
+ else
+ if [ "$kb" -eq 1 ]; then
+ TSPEED=`echo "scale=0; $DELTAT / 1024 / $DELTATIME" | bc`
+ RSPEED=`echo "scale=0; $DELTAR / 1024 / $DELTATIME" | bc`
+ UNIT='kb/s'
+ else
+ TSPEED=`echo "scale=0; $DELTAT / $DELTATIME" | bc`
+ RSPEED=`echo "scale=0; $DELTAR / $DELTATIME" | bc`
+ UNIT='b/s'
+ fi
+ fi
+ if [ "$raw" -eq 1 ]; then
+ echo -e "$TIMESTAMP $TSPEED $RSPEED"
+ else
+ echo -e "[$TIMESTAMP]\ttx $IF: $TSPEED $UNIT \trx $IF: $RSPEED $UNIT"
+ fi
done
Please sign in to comment.
Something went wrong with that request. Please try again.