Thursday, 15 August 2013

windows - Get Link Speed - Win32_PerfRawData_Tcpip_NetworkInterface -


I found and now I'm trying to Win32_PerfRawData_Tcpip_NetworkInterface data Win32_NetworkAdapter (or Win32_NetworkAdapterConfiguration ).

Win32_PerfRawData_Tcpip_NetworkInterface I have any index or unique key that I do not see that you can use for reference Win32_NetworkAdapterAdapterConfiguration or Win32_NetworkAdapter I tried to use name Win32_PerfRawData_Tcpip_NetworkInterface and Win32_NetworkAdapter`, but still they look different.

Name: Intel (R) PRO / 1000 PL network connection

versus

< P> Name: Intel [R] PRO_1000 PL network connection

Any hint?

Thanks in advance,

milde

===

Perhaps the piece of code will help you to help people: )

  # I have got DeviceID of a NIC and use it to get "Netconnection ID": $ objWMIService = Win32 :: OLE- & Gt; 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); $ $ In $ objItem ($ colNicSetts) NetConnID = $ objItem-> {NetConnectionID}; } # = & Gt; $ Netconad Store "Intel (R) Pro / 1000 PL Network Connection" # I now try to get link speed with STH. Like this: $ collItems = $ objWMIService- & gt; ExecQuery ( "Select * Win32_PerfRawData_Tcpip_NetworkInterface name where = '$ NetConnID", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); $ {LinkSpeed ​​= $ objItem-> in my $ objItem ($ collItems) {CurrentBandwidth}; } #include "Intel® (R) PRO_1000 PL Network" Connection # "Intel (R) Pro / 1000 PL Network Connection" in "Win32_PerfRawData_Tcpip_NetworkInterface"! = Intel [R] PRO_1000 PL network connection # = & gt; $ LinkSpeed ​​Empty  

OK. Thanks for posting a short script while you were working on it, I was following a different track and digging through the docs to see if you missed anything.

I could not find a better method (should be one) Name:

  #! Use / usr / bin / perl strict; Use warnings; Use DBI; Use data: Dumper; My $ computer = '.'; ($ Computer) = @ARGV if @RAGV; My $ dbh = dbi- & gt; Connect ("DBI: WMI: $ computer", undefined, undefined, {RaiseError => 1),); Print "=== === from Win32_NetworkAdapter \ n"; My $ name = $ dbh- & gt; Selectall_arrayref ('SELECT * FROM Win32_NetworkAdapter WHERE DeviceID = 11') - & gt; [0] - & gt; [0] - & gt; {Name}; (My $ canonname = $ name) = ~ s / [^ A-Za-z0- 9] / _ / g; Print "name: $ name \ n legal name: $ canonname \ n \ n"; My $ sth = $ dbh- & gt; Prepare ('Choose * Win32_PerfRawData_Tcpip_NetworkInterface'); $ Sth- & gt; Execution; Print "=== Win32_PerfRawData_Tcpip_NetworkInterface === \ n"; While (defined (my $ adapter = $ sth-> fetchrow_arrayref)) {my $ conf = $ adapter-> [0]; My $ perfname = $ conf- & gt; {Name}; (My $ canonperfname = $ perfname) = ~ s / [^ azza-j 0-9] / _ / g; If ($ canonperfname = ~ / ^ $ canonname /) {print "name: $ perfname \ n canonical name: $ canonperfname \ n"; Print $ conf- & gt; {CurrentBandwidth}, "\ n \ n"; last; }}  

Output:

 Win32_NetworkAdapter === name ===: Intel (R) PRO / Wireless 3945ABG network connection canonical name: Intel_R__PRO_Wireless_3945ABG_Network_Connection === the 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 54,000,000 

No comments:

Post a Comment