Skip to content

Instantly share code, notes, and snippets.

@athoik
Created August 15, 2018 16:04
Show Gist options
  • Save athoik/7972bbc8868a6cb8142d5b4ffc4d2745 to your computer and use it in GitHub Desktop.
Save athoik/7972bbc8868a6cb8142d5b4ffc4d2745 to your computer and use it in GitHub Desktop.
Measure traffic per second using /proc/net/dev
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