fix a few bugs with module_net
This commit is contained in:
parent
72093c16b6
commit
47bc71afd2
|
@ -4,21 +4,25 @@
|
||||||
# load config
|
# load config
|
||||||
module_config
|
module_config
|
||||||
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
|
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
|
||||||
|
[ -z "$URL" ] && URL="1.1.1.1"
|
||||||
[ "$ENABLE_ITEM6" = "true" ] || exit
|
[ "$ENABLE_ITEM6" = "true" ] || exit
|
||||||
|
|
||||||
# get stats
|
# get stats
|
||||||
GETNSTAT() {
|
GETNSTAT() {
|
||||||
R1="$(cat /sys/class/net/[ew]*/statistics/rx_bytes || exit)"
|
ip link | grep -q "UP mode" || exit
|
||||||
T1="$(cat /sys/class/net/[ew]*/statistics/tx_bytes || exit)"
|
R1="$(head -n 1 /sys/class/net/[ew]*/statistics/rx_bytes)"
|
||||||
|
T1="$(head -n 1 /sys/class/net/[ew]*/statistics/tx_bytes)"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
R2="$(cat /sys/class/net/[ew]*/statistics/rx_bytes || exit)"
|
R2="$(head -n 1 /sys/class/net/[ew]*/statistics/rx_bytes)"
|
||||||
T2="$(cat /sys/class/net/[ew]*/statistics/tx_bytes || exit)"
|
T2="$(head -n 1 /sys/class/net/[ew]*/statistics/tx_bytes)"
|
||||||
TXPMS="$(expr $T2 - $T1)"
|
TXPMS="$(("$T2" "-" "$T1"))"
|
||||||
RXPMS="$(expr $R2 - $R1)"
|
RXPMS="$(expr "$R2" "-" "$R1")"
|
||||||
TX="$(expr $TXPMS / 1024 "*" 10)"
|
TX="$(expr "$TXPMS" / "1024" "*" "10")"
|
||||||
RX="$(expr $RXPMS / 1024 "*" 10)"
|
RX="$(expr "$RXPMS" / "1024" "*" "10")"
|
||||||
[ ! -z "$TX" ] && printf "$TX\n" > /tmp/module_net_tx
|
[ ! -z "$TX" ] && printf "$TX\n" > /tmp/module_net_tx || exit
|
||||||
[ ! -z "$RX" ] && printf "$RX\n" > /tmp/module_net_rx
|
[ ! -z "$RX" ] && printf "$RX\n" > /tmp/module_net_rx || exit
|
||||||
|
[ -e "/tmp/module_net_tx" ] || exit
|
||||||
|
[ -e "/tmp/module_net_rx" ] || exit
|
||||||
}
|
}
|
||||||
|
|
||||||
[ ! -e "/tmp/module_net_tx" ] && GETNSTAT
|
[ ! -e "/tmp/module_net_tx" ] && GETNSTAT
|
||||||
|
|
Loading…
Reference in a new issue