Fedora17 terminal view real-time network speed rate :#! /Bin/sh # rate-t # real-time display # rate # display once # Nic name needs to be customized # ora17 # HL_START = "\ 033 [37; 40; 1 m "HL_START =" \ 033 [31; 42; 1 m "HL_END =" \ 033 [0 m "DEV_NAME =" wlan0 "# DEV_NAME =" p5p1 "functi
Fedora 17 terminal view real-time network speed rate:
#! /Bin/sh
# Rate-t # real-time display
# Rate # display once
# The NIC name must be customized.
# Ora 17
# HL_START = "\ 033 [37; 40; 1 m"
HL_START="\ 033 [31; 42; 1 m"
HL_END="\ 033 [0 m"
DEV_NAME="Wlan0"
# DEV_NAME = "p5p1"
FunctionDisp_usage()
{
Printf"Usage: $1 [DEV_NAME] [TIMES |-t] \ n"
Printf"DEV_NAME the name of the network device, default: eth0 \ n"
Printf"TIMES the times of counts, default: 1 \ n"
Printf"-T counting until break \ n"
}
If [$#-Eq 0]
Then
TOTAL_TIME=1
Elif [$1= "-H" ]
Then
Disp_usage $0
Exit 0
Elif [$1= "-- Help" ]
Then
Disp_usage $0
Exit 0
Elif [$1= "-T" ]
Then
TOTAL_TIME=65535
Elif [$#-Eq 1]
Then
DEV_NAME=$1
TOTAL_TIME=1
Elif [$2= "-T" ]
Then
DEV_NAME=$1
TOTAL_TIME=65535
Else
DEV_NAME=$1
TOTAL_TIME=$2
Fi
Echo"The Rate of Network, by dorainm, dora...@gmail.com"
Echo"-----------------------------------------------------"
Echo"DEV_NAME is $ DEV_NAME"
Count=0
While [$ Count-Lt $ TOTAL_TIME]
Do
#
# RX_FIRST = $ (/sbin/ifconfig $ DEV_NAME | awk '/RX bytes/{print $2}' | awk-F: '{print $2 }')
# TX_FIRST = $ (/sbin/ifconfig $ DEV_NAME | awk '/RX bytes/{print $6}' | awk-F: '{print $2 }')
# Echo "FIRST = $ FIRST"
# Sleep 1
# RX_SECOND = $ (/sbin/ifconfig $ DEV_NAME | awk '/RX bytes/{print $2}' | awk-F: '{print $2 }')
# TX_SECOND = $ (/sbin/ifconfig $ DEV_NAME | awk '/RX bytes/{print $6}' | awk-F: '{print $2 }')
# Echo "SECOND = $ SECOND"
# Net-tools 1.60
# Ifconfig 1.42)
RX_FIRST=$(/Sbin/Ifconfig $ DEV_NAME|Awk'/RX packets/{print $5 }')
TX_FIRST=$(/Sbin/Ifconfig $ DEV_NAME|Awk'/TX packets/{print $5 }')
# Echo "FIRST = $ FIRST"
Sleep1
RX_SECOND=$(/Sbin/Ifconfig $ DEV_NAME|Awk'/RX packets/{print $5 }')
TX_SECOND=$(/Sbin/Ifconfig $ DEV_NAME|Awk'/TX packets/{print $5 }')
# Echo "SECOND = $ SECOND"
Printf"RX_FIRST = $ RX_FIRST \ n"
Printf"RX_SECOND = $ RX_SECOND \ n"
Printf"TX_FIRST = $ TX_FIRST \ n"
Printf"TX_SECOND = $ TX_SECOND \ n"
((RX_FIRST=$ RX_SECOND-$ RX_FIRST))
((TX_FIRST=$ TX_SECOND-$ TX_FIRST))
If [$ RX_FIRST-Gt1048576 ]
Then
RX_FIRST=$(Echo"Scale = 3; $ RX_FIRST/1048576" |Bc-L)
Printf"RX Rate = $ HL_START %. 3F $ HL_END MB/S \ t"$ RX_FIRST
Elif [$ RX_FIRST-Gt1024 ]
Then
RX_FIRST=$(Echo"Scale = 3; $ RX_FIRST/1024" |Bc-L)
# (RX_FIRST = ($ RX_FIRST/1024 )))
Printf"RX Rate = $ HL_START %. 3F $ HL_END KB/S \ t"$ RX_FIRST
Else
Printf"RX Rate = $ HL_START $ RX_FIRST $ HL_END B/S \ t"
Fi
If [$ RX_SECOND-Gt1048576 ]
Then
RX_SECOND=$(Echo"Scale = 3; $ rx_secondd/1048576" |Bc-L)
Printf"Totle Bytes: $ HL_START $ RX_SECOND $ HL_END MB \ n"
Elif [$ RX_SECOND-Gt1024 ]
Then
RX_SECOND=$(Echo"Scale = 3; $ rx_secondd/1024" |Bc-L)
Printf"Totle Bytes: $ HL_START $ RX_SECOND $ HL_END KB \ n"
Else
Printf"Totle Bytes: $ HL_START $ RX_SECOND $ HL_END B \ n"
Fi
If [$ TX_FIRST-Gt1048576 ]
Then
TX_FIRST=$(Echo"Scale = 3; $ TX_FIRST/1048576" |Bc-L)
Printf"TX Rate = $ HL_START %. 3F $ HL_END MB/S \ t"$ TX_FIRST
Elif [$ TX_FIRST-Gt1024 ]
Then
TX_FIRST=$(Echo"Scale = 3; $ TX_FIRST/1024" |Bc-L)
Printf"TX Rate = $ HL_START %. 3F $ HL_END KB/S \ t"$ TX_FIRST
Else
Printf"TX Rate = $ HL_START $ TX_FIRST $ HL_END B/S \ t"
Fi
If [$ TX_SECOND-Gt1048576 ]
Then
TX_SECOND=$(Echo"Scale = 3; $ tx_secondd/1048576" |Bc-L)
Printf"Totle Bytes: $ HL_START $ TX_SECOND $ HL_END MB \ n"
Elif [$ TX_SECOND-Gt1024 ]
Then
TX_SECOND=$(Echo"Scale = 3; $ tx_secondd/1024" |Bc-L)
Printf"Totle Bytes: $ HL_START $ TX_SECOND $ HL_END KB \ n"
Else
Printf"Totle Bytes: $ HL_START $ TX_SECOND $ HL_END B \ n"
Fi
((Count=$ Count+1))
Echo"-----------------------------------------------------"
Done
Echo"All Done"
For more information about Fedora, see Fedora topics page http://www.linuxidc.com/topicnews.aspx? Tid = 5