[python-win32] Fetching network interface instance names

Chris Miles miles.chris at gmail.com
Wed Jul 27 01:05:43 CEST 2005


On 26 Jul 2005, at 00:04, Chris Miles wrote:
> Thanks Mark.  The "List Network Adapter Properties" script did the  
> trick.  And it didn't need ActiveState Python to work, thankfully.

I spoke too soon.  Unfortunately the answers I get from COM are not  
compatible with win32pdh.  Example:

win32com tells me my network interface is called:
   "Intel(R) PRO/100 Network Connection"
But win32pdh calls it:
   "Intel[R] PRO_100 Network Connection - Packet Scheduler Miniport"

Notice the almost subtle "(R)" and "[R]" differences and "PRO/100" vs  
"PRO_100".  Nice and inconsistent!  Who knows why ... crazy Microsoft.

Anyway, further digging showed me that win32pdh can indeed tell me  
all the available instance names for the "Network Interface" object,  
exactly what I was looking for.

 >>> items, instances = win32pdh.EnumObjectItems(None, None, 'Network  
Interface', win32pdh.PERF_DETAIL_WIZARD)
 >>> items
['Bytes Total/sec', 'Packets/sec', 'Packets Received/sec', 'Packets  
Sent/sec', 'Current Bandwidth', 'Bytes Received/sec', 'Packets  
Received Unicast/sec', 'Packets Received Non-Unicast/sec', 'Packets  
Received Discarded', 'Packets Received Errors', 'Packets Received  
Unknown', 'Bytes Sent/sec', 'Packets Sent Unicast/sec', 'Packets Sent  
Non-Unicast/sec', 'Packets Outbound Discarded', 'Packets Outbound  
Errors', 'Output Queue Length']
 >>> instances
['ORiNOCO Wireless LAN Mini PCI Card - Packet Scheduler Miniport',  
'Intel[R] PRO_100 Network Connection - Packet Scheduler Miniport',  
'MS TCP Loopback interface']

instances is a list of network interface names that win32pdh can  
provide counters for, and items is a list of all the counters that  
can be provided.

Hope this helps others.

Cheers,
Chris

-- 
Chris Miles
http://chrismiles.info/

> On 24 Jul 2005, at 23:45, Mark Hammond wrote:
>> http://www.microsoft.com/technet/scriptcenter/scripts/python/ 
>> pyindex.mspx



More information about the Python-win32 mailing list