You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
603 B
Bash

#!/bin/bash
icon=""
iface="enp4s0"
up=""
down=""
R1="$(cat /sys/class/net/$iface/statistics/rx_bytes)"
T1="$(cat /sys/class/net/$iface/statistics/tx_bytes)"
sleep 1
R2="$(cat /sys/class/net/$iface/statistics/rx_bytes)"
T2="$(cat /sys/class/net/$iface/statistics/tx_bytes)"
TBPS="$(expr $T2 - $T1)"
RBPS="$(expr $R2 - $R1)"
TKBPS="$(expr $TBPS / 1024)"
RKBPS="$(expr $RBPS / 1024)"
IPADDR="$(ip a show dev $iface | awk '/inet / { print $2 } ')"
printf " %s [%s] %s %skB/s %s %skB/s \\n" "$icon" "$IPADDR" "$up" "$TKBPS" "$down" "$RKBPS"
#echo "tx $iface: $TKBPS kB/s rx $iface: $RKBPS kB/s"