improve speed format (#738)
* improve speed format Convert network speed into human-readable format using numfmt, this will handle low and high values properly. * Update nettraf fix jitter
This commit is contained in:
parent
be9490155f
commit
f11008c619
1 changed files with 2 additions and 2 deletions
|
@ -19,10 +19,10 @@ update() {
|
||||||
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
|
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
|
||||||
[ -f "$cache" ] && read -r old < "$cache" || old=0
|
[ -f "$cache" ] && read -r old < "$cache" || old=0
|
||||||
printf %d\\n "$sum" > "$cache"
|
printf %d\\n "$sum" > "$cache"
|
||||||
printf %d\\n $(( (sum - old) / 1024 ))
|
printf %d\\n $(( sum - old ))
|
||||||
}
|
}
|
||||||
|
|
||||||
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
|
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
|
||||||
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
|
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
|
||||||
|
|
||||||
printf "🔻%dKiB 🔺%dKiB\\n" "$rx" "$tx"
|
printf "🔻%4sB 🔺%4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec-i $tx)
|
||||||
|
|
Loading…
Reference in a new issue