bin directory and vimrc comment

This commit is contained in:
wt committed 2024-07-05 13:25:21 +07:00
1 parent 04f05aad1b
commit 2307c4225c
12 files changed
+2515 -15

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env sh
# ---- colors ----
RESET='\033[0m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
# ----------------
interface=$1
bytes=$2
while true; do
clear
tx_traffic=$(cat /sys/class/net/${interface}/statistics/tx_bytes)
rx_traffic=$(cat /sys/class/net/${interface}/statistics/rx_bytes)
traffic_color=$GREEN
if [[ $(echo $(($rx_traffic/1024/1024/1024))) > 5 ]]; then
traffic_color=$YELLOW
elif [[ $(echo $(($rx_traffic/1024/1024/1024))) > 10 ]]; then
traffic_color=$RED
fi
if [[ $bytes == 'k' ]] || [[ $bytes == 'K' ]]; then
printf "$BLUE tx traffic$RESET = $(($tx_traffic/1024)) Kb\n"
printf "$traffic_color rx traffic$RESET = $(($rx_traffic/1024)) Kb\n"
fi
if [[ $bytes == 'm' ]] || [[ $bytes == 'M' ]]; then
printf "$BLUE tx traffic$RESET = $(($tx_traffic/1024/1024)) Mb\n"
printf "$traffic_color rx traffic$RESET = $(($rx_traffic/1024/1024)) Mb\n"
fi
if [[ $bytes == 'g' ]] || [[ $bytes == 'G' ]]; then
if [[ $(echo $(($tx_traffic/1024/1024/1024))) == 0 ]]; then
printf "$BLUE tx traffic$RESET = $(($tx_traffic/1024/1024)) Mb\n"
else
printf "$BLUE tx traffic$RESET = $(($tx_traffic/1024/1024/1024)) Gb\n"
fi
if [[ $(echo $(($rx_traffic/1024/1024/1024))) == 0 ]]; then
printf "$traffic_color rx traffic$RESET = $(($rx_traffic/1024/1024)) Mb\n"
else
printf "$traffic_color rx traffic$RESET = $(($rx_traffic/1024/1024/1024)) Gb\n"
fi
fi
if [[ $bytes == 'b' ]] || [[ $bytes == '' ]]; then
printf "$BLUE tx traffic$RESET = $(($tx_traffic)) b\n"
printf "$traffic_color rx traffic$RESET = $(($rx_traffic)) b\n"
fi
sleep 1
done