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:<br>
<br>[code]<br>>>> import win32pdh<br>>>> intf = 'Intel[R] PRO_100 Network Connection'<br>>>> hq = win32pdh.OpenQuery()<br>>>> cp = win32pdh.MakeCounterPath( (None, 'Network Interface', intf, None, -1, 'Bytes Received/sec') )
<br>>>> hc = win32pdh.AddCounter( hq, cp )<br>>>> type,val = win32pdh.GetFormattedCounterValue( hc, win32pdh.PDH_FMT_LONG )<br><br>Traceback (most recent call last):<br> File "<pyshell#5>", line 1, in <module>
<br> type,val = win32pdh.GetFormattedCounterValue( hc, win32pdh.PDH_FMT_LONG )<br>error: (-2147481645, 'GetFormattedCounterValue', 'No error message is available'<br>[/code]<br>