This script will output bytes received and transmitted for a local Windows machine since the last reboot:
import re from subprocess import Popen, PIPE p = Popen('net statistics workstation', stdout=PIPE) for line in p.stdout: m = re.search('Bytes received\W+(.*)', line) if m: print 'Bytes received: %s' % (m.group(1)) m = re.search('Bytes transmitted\W+(.*)', line) if m: print 'Bytes transmitted: %s' % (m.group(1))
Copyright © 2006-2008 Corey Goldberg
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.