Created
November 28, 2017 15:26
-
-
Save jamexhuang/d76ae261b2c9948dba4c3c5ae626f95c to your computer and use it in GitHub Desktop.
net mon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ethn=$1 | |
while true | |
do | |
RX_pre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}') | |
TX_pre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}') | |
sleep 1 | |
RX_next=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}') | |
TX_next=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}') | |
clear | |
echo -e "\t RX `date +%k:%M:%S` TX" | |
RX=$((${RX_next}-${RX_pre})) | |
TX=$((${TX_next}-${TX_pre})) | |
if [[ $RX -lt 1024 ]];then | |
RX="${RX}B/s" | |
elif [[ $RX -gt 1048576 ]];then | |
RX=$(echo $RX | awk '{print $1/1048576 "MB/s"}') | |
else | |
RX=$(echo $RX | awk '{print $1/1024 "KB/s"}') | |
fi | |
if [[ $TX -lt 1024 ]];then | |
TX="${TX}B/s" | |
elif [[ $TX -gt 1048576 ]];then | |
TX=$(echo $TX | awk '{print $1/1048576 "MB/s"}') | |
else | |
TX=$(echo $TX | awk '{print $1/1024 "KB/s"}') | |
fi | |
echo -e "$ethn \t $RX $TX " | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment