Skip to content

Instantly share code, notes, and snippets.

@rewida17
Created February 28, 2020 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rewida17/28411df201d5aa2343f3c231abea593d to your computer and use it in GitHub Desktop.
Save rewida17/28411df201d5aa2343f3c231abea593d to your computer and use it in GitHub Desktop.
interface stats based on /sys/class/net/eth0/statistics/
#!/bin/bash
a="$(cat /sys/class/net/eth0/statistics/rx_bytes)"
b="$(cat /sys/class/net/eth0/statistics/tx_bytes)"
rx="$(echo "scale=3;$a/1024^3"|bc)"
tx="$(echo "scale=3;$b/1024^3"|bc)"
sum=$(echo "scale=3;$rx+$tx"|bc)
printf "\n\e[41mETH0_STATS:\e[0m \e[42m RX: $rx GB TX: $tx GB Su: $sum GB\e[0m\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment