various changes

This commit is contained in:
2020-07-17 15:05:59 +02:00
parent f60abea7c7
commit 0c574196f3
16 changed files with 63 additions and 37 deletions

View File

@ -27,8 +27,14 @@ lasttime=${XDG_CACHE_HOME:-$HOME/.cache}/nettraf_time
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
timedifference=$(( "$(date +'%s')" - "$previoustime" ))
rx_avg=$(( "$rx" / "$timedifference" ))
tx_avg=$(( "$tx" / "$timedifference" ))
if [ -n "$timedifference" ]; then
rx_avg=$(( "$rx" / "$timedifference" ))
tx_avg=$(( "$rx" / "$timedifference" ))
else
rx_avg=rx_bytes
tx_avg=tx_bytes
fi
#only print if any traffic at all
if [ "$rx_avg" -gt 0 ] || [ "$tx_avg" -gt 0 ]