[python-win32] Getting Network Information/Statistics

sai rabbit twopill at gmail.com
Tue Jan 22 16:06:30 CET 2008


I want to get bytes sent and received in total and by each application if
possible. I tried winpdh and winpdhutil but it reports the wrong number for
Received in XP and doesn't seem to work for network stats in Vista:

[code]
>>> import win32pdh
>>> intf = 'Intel[R] PRO_100 Network Connection'
>>> hq = win32pdh.OpenQuery()
>>> cp = win32pdh.MakeCounterPath( (None, 'Network Interface', intf, None,
-1, 'Bytes Received/sec') )
>>> hc = win32pdh.AddCounter( hq, cp )
>>> type,val = win32pdh.GetFormattedCounterValue( hc, win32pdh.PDH_FMT_LONG)

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    type,val = win32pdh.GetFormattedCounterValue( hc, win32pdh.PDH_FMT_LONG)
error: (-2147481645, 'GetFormattedCounterValue', 'No error message is
available'
[/code]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20080122/9b0a6d8b/attachment.htm 


More information about the python-win32 mailing list