[python-win32] Fetching network interface instance names

Mark Hammond mhammond at skippinet.com.au
Mon Jul 25 00:45:37 CEST 2005


http://www.microsoft.com/technet/scriptcenter/scripts/python/pyindex.mspx
has some scripts that appear to do what you need.

(Quite cool that we can now post a microsoft.com address for help with
Python scripts ;)

Mark.

> -----Original Message-----
> From: python-win32-bounces at python.org
> [mailto:python-win32-bounces at python.org]On Behalf Of Chris Miles
> Sent: Monday, 25 July 2005 7:45 AM
> To: python-win32 at python.org
> Subject: [python-win32] Fetching network interface instance names
>
>
> Hi, I am querying win32pdh to fetch statistics from each network
> interface on the machine.  I am able to fetch the stats I need, using
> the code below, from each network interface, provided I already know
> the network interface instance name (eg: intf below).
>
> My Q is: how can I programmatically find out what the network
> interface instance names are?
>
> I can see the instance names manually from the GUI using
> win32pdhutil.browse() but that doesn't help my program do it.
>
>  >>> intf = 'Intel[R] PRO_100 Network Connection - Packet Scheduler
> Miniport'
>  >>> import win32pdh
>  >>> hq = win32pdh.OpenQuery()
>  >>> cp = win32pdh.MakeCounterPath( (None, 'Network Interface', intf,
> None, -1, 'Bytes Sent/sec') )
>  >>> hc = win32pdh.AddCounter( hq, cp )
>  >>> type,val = win32pdh.GetFormattedCounterValue( hc,
> win32pdh.PDH_FMT_LONG )
>  >>> type
> 272696320
>  >>> val
> 0
>
> Cheers,
> Chris
>
> --
> Chris Miles
> http://chrismiles.info/
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32



More information about the Python-win32 mailing list