Get link speed - Win32_PerfRawData_Tcpip_NetworkInterface

I found a definition of network connection speed and now I'm trying to map data from Win32_PerfRawData_Tcpip_NetworkInterface to Win32_NetworkAdapter (or Win32_NetworkAdapterConfiguration ).

In the Win32_PerfRawData_Tcpip_NetworkInterface class Win32_PerfRawData_Tcpip_NetworkInterface I do not see any index or unique key that I can use to refer to Win32_NetworkAdapterConfiguration or Win32_NetworkAdapter. I tried to use the Win32_NetworkAdapter. I tried to use the Name in Win32_PerfRawData_Tcpip_NetworkInterface and Win32_NetworkAdapter`, but still they look different.

eg.

Name: Intel (R) PRO / 1000 PL Network Connection

against

Name: Intel [R] PRO_1000 PL Network Connection

Any clues?

Thanks in advance,

Milde

===

Perhaps this piece of code will help you help me :)

 # I got the DeviceID of a NIC and use it to get the "NetConnection ID": $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\CIMV2") or die "Exit: WMI connection failed. \n"; $colNicSetts = $objWMIService->ExecQuery( "SELECT * FROM Win32_NetworkAdapter Where DeviceID = '$ID'", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); foreach my $objItem (in $colNicSetts){ $NetConnID = $objItem->{NetConnectionID}; } # => $NetConnID stores "Intel(R) PRO/1000 PL Network Connection". # Now I tried to get the Link Speed with sth. like that: $collItems = $objWMIService->ExecQuery( "SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface Where Name = '$NetConnID'", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); foreach my $objItem (in $collItems){ $LinkSpeed = $objItem->{CurrentBandwidth}; } # "Win32_PerfRawData_Tcpip_NetworkInterface" contains "Intel[R] PRO_1000 PL Network" Connection # "Intel(R) PRO/1000 PL Network Connection" != Intel[R] PRO_1000 PL Network Connection # => $LinkSpeed empty 
+6
windows perl wmi wmi-query
source share
3 answers

OK Thanks for posting a short script. While you were working on this, I was following another track using DBD :: WMI and looking through documents to see if you missed something.

I could not find a better way (it should be one) than canonicalization of names:

 #!/usr/bin/perl use strict; use warnings; use DBI; use Data::Dumper; my $computer = '.'; ($computer) = @ARGV if @ARGV; my $dbh = DBI->connect("dbi:WMI:$computer", undef, undef, { RaiseError => 1}, ); print "=== From Win32_NetworkAdapter ===\n"; my $name = $dbh->selectall_arrayref( 'SELECT * FROM Win32_NetworkAdapter WHERE DeviceID = 11' )->[0]->[0]->{Name}; (my $canonname = $name) =~ s/[^A-Za-z0-9]/_/g; print "Name: $name\nCanonical name: $canonname\n\n"; my $sth = $dbh->prepare( 'SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface' ); $sth->execute; print "=== From Win32_PerfRawData_Tcpip_NetworkInterface ===\n"; while (defined (my $adapter = $sth->fetchrow_arrayref )) { my $conf = $adapter->[0]; my $perfname = $conf->{Name}; (my $canonperfname = $perfname) =~ s/[^A-Za-z0-9]/_/g; if ( $canonperfname =~ /^$canonname/ ) { print "Name: $perfname\nCanonical name: $canonperfname\n"; print $conf->{CurrentBandwidth}, "\n\n"; last; } } 

Output:

  === From Win32_NetworkAdapter ===
 Name: Intel (R) PRO / Wireless 3945ABG Network Connection
 Canonical name: Intel_R__PRO_Wireless_3945ABG_Network_Connection

 === From Win32_PerfRawData_Tcpip_NetworkInterface ===
 Name: Intel [R] PRO_Wireless 3945ABG Network Connection - Packet Scheduler Miniport
 Canonical name: Intel_R__PRO_Wireless_3945ABG_Network_Connection___Packet_Scheduler_Miniport
 54000000
+4
source share

I just looked at my machine using WMI-Tools, because I thought it should be easy ... ;-)
But it is not...

But what I found on my machine is the union "Win32_NetworkAdapter.Name" + "__" + "Win32_NetworkAdapter.InterfaceIndex" leads to "Win32_PerfFormattedData_Tcpip_NetworkInterface.Name =" NVIDIA nForce Networking Controller _2 "[Pay attention to space too!]] .

Example from my car:

  Win32_NetworkAdapter.DeviceID = "13"
 Win32_NetworkAdapter.NetConnectionID = "Local Area Connection 2"
 Win32_NetworkAdapter.InterfaceIndex = "2"
 Win32_NetworkAdapter.Name = "NVIDIA nForce Networking Controller"
 Win32_PerfFormattedData_Tcpip_NetworkInterface = "NVIDIA nForce Networking Controller _2"

I hope I understood your question correctly, and this can help ?!

w - mabra

+3
source share

The only approach I could find was to use the Win32_PnPEntity class to get the DeviceName for the network adapter and then convert it to InstanceName . This allows you to find the key value that you can use in other WMI tables (I used InterfaceIndex, but there are other options in the Win32_NetworkAdapter class.

So, at a high level:

  • Get an instance of Win32_NetworkAdapter
  • Use one of the two WQL WQL queries below to get PnpEntity
  • Convert the name Win32_PNPEntity.Name to InstanceName by replacing:
    • (from [
    • ) from]
    • # \ / all with _
  • Use this instance name to request the Win32_PerfFormattedData_Tcpip_NetworkInterface class

It's rather confusing, but since InstanceName breaks out of the PnPEntity name, this is the only way to find exact mappings.

Here are two ways I was able to get an instance of PnPEntity for the NetworkAdapter:

 ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID='12'} WHERE ResultClass=Win32_PnPEntity SELECT * FROM Win32_PNPEntity where DeviceID='PCI\\VEN_14E4&DEV_1684&SUBSYS_1309103C&REV_10\\4&11050A08&0&00E5' 
+1
source share

All Articles