Created
August 15, 2018 16:04
-
-
Save athoik/7972bbc8868a6cb8142d5b4ffc4d2745 to your computer and use it in GitHub Desktop.
Measure traffic per second using /proc/net/dev
This file contains 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 characters
import time | |
last = 0L | |
while True: | |
current = 0L | |
lines = open("/proc/net/dev").readlines()[3:] | |
for l in lines: | |
ll = l.split() | |
current += long(ll[1])+long(ll[9]) | |
delta = current - last | |
last = current | |
print "%s bytes per second" % delta | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment