Created
May 23, 2013 19:37
-
-
Save csfrancis/5638827 to your computer and use it in GitHub Desktop.
Revisions
-
csfrancis created this gist
May 23, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #!/bin/bash # # Show if stats by sampling /sys/. # Originally stolen from http://unix.stackexchange.com/questions/41346/upload-download-speed-in-tmux-status-line run_segment() { sleeptime="0.5" iface="eth0" RXB=$(</sys/class/net/"$iface"/statistics/rx_bytes) TXB=$(</sys/class/net/"$iface"/statistics/tx_bytes) sleep "$sleeptime" RXBN=$(</sys/class/net/"$iface"/statistics/rx_bytes) TXBN=$(</sys/class/net/"$iface"/statistics/tx_bytes) RXDIF=$(echo $((RXBN - RXB)) ) TXDIF=$(echo $((TXBN - TXB)) ) rx=$(echo "${RXDIF} / 1024 / ${sleeptime}" | bc) tx=$(echo "${TXDIF} / 1024 / ${sleeptime}" | bc) echo "⇊ ${rx}K/s ⇈ ${tx}K/s" return 0 } run_segment