优化:改用脚本显示网速

This commit is contained in:
2025-08-18 11:25:09 +08:00
parent 9c54afd2f3
commit 3e292e87e2
2 changed files with 33 additions and 0 deletions

16
mux_net_speed.sh Normal file
View File

@ -0,0 +1,16 @@
#!/bin/bash
IF=wlp3s0
TMPFILE=/tmp/tmux_net_speed.txt
# 初始化上一秒流量
read RX_PREV TX_PREV <<< $(awk -v iface=$IF '$1 ~ iface {print $2, $10}' /proc/net/dev)
while true; do
sleep 1
read RX_CUR TX_CUR <<< $(awk -v iface=$IF '$1 ~ iface {print $2, $10}' /proc/net/dev)
RX_RATE=$(( (RX_CUR - RX_PREV)/1024 ))
TX_RATE=$(( (TX_CUR - TX_PREV)/1024 ))
printf "↑%dKB/s ↓%dKB/s" $TX_RATE $RX_RATE > $TMPFILE
RX_PREV=$RX_CUR
TX_PREV=$TX_CUR
done