It is currently April 23rd, 2024, 6:09 am

Getting network adapter name with SysInfo?

Get help with creating, editing & fixing problems with skins
TTW
Posts: 3
Joined: February 22nd, 2019, 1:23 am

Getting network adapter name with SysInfo?

Post by TTW »

I'd like to get the name (not the description, they're different!) of a network adapter, but based on the SysInfo docs, it doesn't seem to be possible. Is there some way I'm not aware of?

As a workaround, I'm trying to just do things manually with a "Substitute" string and the description, but I've noticed something strange. First, here's the relevant part of my skin:

Code: Select all

[MeasureAdapter]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=ADAPTER_DESCRIPTION
SysInfoData=#network.Adapter#
Substitute="Intel(R) I211 Gigabit Network Connection":"wired","foo":"bar"
UpdateDivider=36000

[MeasureLAN]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=IP_ADDRESS
SysInfoData=#network.Adapter#
UpdateDivider=36000
For some reason, the IP address given does not match with the adapter given in the description. Is this a known bug?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Getting network adapter name with SysInfo?

Post by jsmorley »

I don't fully understand.

As far as I know, ADAPTER_DESCRIPTION is the "name" of the adapter. I don't know of any distinction between "description" and "name".

I don't know what you have set for your variables #network.Adapter#, but if you use "Best" as that value, I'm pretty sure the LAN IP address will match the correct adapter. Always has for me anyway.
TTW
Posts: 3
Joined: February 22nd, 2019, 1:23 am

Re: Getting network adapter name with SysInfo?

Post by TTW »

The names are different from the description in the control panel (Control Panel\Network and Internet\Network Connections). The first line is the "name", and the last (third) line is the description. They are different, but I see no way to retrieve the name.

As for the #network.Adapter# variable, I've just been setting it to different integers try to get the correct interface. However, my description doesn't match the IP for that interface, so I have no idea which interface I'm actually referring to. I also don't know if this in any way relates to the "Interface" parameter for the NetUp/Down measures, but I would hope they use the same index number, otherwise I have no idea how I can figure out which interface I'm measuring, beyond manipulating traffic on it and correlating that with some other measurement (e.g. the Task Manager).
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Getting network adapter name with SysInfo?

Post by jsmorley »

That first line in Control Panel\Network and Internet\Network Connections is the name of an "Alias", not the name of the "adapter". I'm not sure where those are stored.

As to the SysinfoData in SysInfo, and the Interface option in Net/In/Out/Total, I would use "Best" and let it figure it out.

If you open the Mange dialog and go to Settings.

1) Turn on Debug Mode
2) Turn on Log to File
3) Exit Rainmeter
4) Start Rainmeter
5) Click Show Log File

That will give you all the information, including index numbers, that Rainmeter has for your network. That section of the log will look something like:

Code: Select all

DBUG (23:23:20.424) : * NETWORK-INTERFACE: Count=44
DBUG (23:23:20.426) : 1: TAP-Windows Adapter V9-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.427) :   Alias: Ethernet 2-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.429) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.430) : 2: TAP-Windows Adapter V9-QoS Packet Scheduler-0000
DBUG (23:23:20.432) :   Alias: Ethernet 2-QoS Packet Scheduler-0000
DBUG (23:23:20.433) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.435) : 3: TAP-Windows Adapter V9-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.437) :   Alias: Ethernet 2-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.438) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.440) : 4: Realtek PCIe GBE Family Controller-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.442) :   Alias: Ethernet-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.443) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.445) : 5: Realtek PCIe GBE Family Controller-QoS Packet Scheduler-0000
DBUG (23:23:20.447) :   Alias: Ethernet-QoS Packet Scheduler-0000
DBUG (23:23:20.448) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.449) : 6: Realtek PCIe GBE Family Controller-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.451) :   Alias: Ethernet-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.453) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.455) : 7: WAN Miniport (IP)-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.456) :   Alias: Local Area Connection* 8-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.458) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.460) : 8: WAN Miniport (IP)-QoS Packet Scheduler-0000
DBUG (23:23:20.461) :   Alias: Local Area Connection* 8-QoS Packet Scheduler-0000
DBUG (23:23:20.463) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.464) : 9: WAN Miniport (IPv6)-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.466) :   Alias: Local Area Connection* 9-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.467) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.469) : 10: WAN Miniport (IPv6)-QoS Packet Scheduler-0000
DBUG (23:23:20.471) :   Alias: Local Area Connection* 9-QoS Packet Scheduler-0000
DBUG (23:23:20.473) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.474) : 11: WAN Miniport (Network Monitor)-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.476) :   Alias: Local Area Connection* 11-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.477) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.479) : 12: WAN Miniport (Network Monitor)-QoS Packet Scheduler-0000
DBUG (23:23:20.481) :   Alias: Local Area Connection* 11-QoS Packet Scheduler-0000
DBUG (23:23:20.482) :   Type=Ethernet(6), Hardware=No, Filter=Yes
DBUG (23:23:20.484) : 13: Microsoft Kernel Debug Network Adapter
DBUG (23:23:20.486) :   Alias: Ethernet (Kernel Debugger)
DBUG (23:23:20.487) :   Type=Ethernet(6), Hardware=No, Filter=No
DBUG (23:23:20.489) : 14: Realtek PCIe GBE Family Controller
DBUG (23:23:20.490) :   Alias: Ethernet
DBUG (23:23:20.492) :   Type=Ethernet(6), Hardware=Yes, Filter=No
DBUG (23:23:20.494) : 15: WAN Miniport (IP)
DBUG (23:23:20.495) :   Alias: Local Area Connection* 8
DBUG (23:23:20.497) :   Type=Ethernet(6), Hardware=No, Filter=No
DBUG (23:23:20.498) : 16: WAN Miniport (IPv6)
DBUG (23:23:20.500) :   Alias: Local Area Connection* 9
DBUG (23:23:20.502) :   Type=Ethernet(6), Hardware=No, Filter=No
DBUG (23:23:20.503) : 17: WAN Miniport (Network Monitor)
DBUG (23:23:20.505) :   Alias: Local Area Connection* 11
DBUG (23:23:20.507) :   Type=Ethernet(6), Hardware=No, Filter=No
DBUG (23:23:20.508) : 18: TAP-Windows Adapter V9
DBUG (23:23:20.510) :   Alias: Ethernet 2
DBUG (23:23:20.512) :   Type=Ethernet(6), Hardware=No, Filter=No
DBUG (23:23:20.513) : 19: WAN Miniport (PPPOE)
DBUG (23:23:20.515) :   Alias: Local Area Connection* 7
DBUG (23:23:20.517) :   Type=PPP(23), Hardware=No, Filter=No
DBUG (23:23:20.518) : 20: Software Loopback Interface 1
DBUG (23:23:20.520) :   Alias: Loopback Pseudo-Interface 1
DBUG (23:23:20.522) :   Type=Loopback(24), Hardware=No, Filter=No
DBUG (23:23:20.523) : 21: Qualcomm Atheros AR938x Wireless Network Adapter-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.525) :   Alias: Wi-Fi-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.527) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.528) : 22: Qualcomm Atheros AR938x Wireless Network Adapter-Virtual WiFi Filter Driver-0000
DBUG (23:23:20.530) :   Alias: Wi-Fi-Virtual WiFi Filter Driver-0000
DBUG (23:23:20.532) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.533) : 23: Qualcomm Atheros AR938x Wireless Network Adapter-Native WiFi Filter Driver-0000
DBUG (23:23:20.535) :   Alias: Wi-Fi-Native WiFi Filter Driver-0000
DBUG (23:23:20.537) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.538) : 24: Qualcomm Atheros AR938x Wireless Network Adapter-QoS Packet Scheduler-0000
DBUG (23:23:20.540) :   Alias: Wi-Fi-QoS Packet Scheduler-0000
DBUG (23:23:20.542) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.543) : 25: Qualcomm Atheros AR938x Wireless Network Adapter-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.545) :   Alias: Wi-Fi-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.547) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.548) : 26: Microsoft Wi-Fi Direct Virtual Adapter-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.550) :   Alias: Local Area Connection* 1-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.552) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.554) : 27: Microsoft Wi-Fi Direct Virtual Adapter-Native WiFi Filter Driver-0000
DBUG (23:23:20.555) :   Alias: Local Area Connection* 1-Native WiFi Filter Driver-0000
DBUG (23:23:20.557) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.559) : 28: Microsoft Wi-Fi Direct Virtual Adapter-QoS Packet Scheduler-0000
DBUG (23:23:20.560) :   Alias: Local Area Connection* 1-QoS Packet Scheduler-0000
DBUG (23:23:20.562) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.564) : 29: Microsoft Wi-Fi Direct Virtual Adapter-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.565) :   Alias: Local Area Connection* 1-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.567) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.569) : 30: Microsoft Wi-Fi Direct Virtual Adapter #2-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.570) :   Alias: Local Area Connection* 2-WFP Native MAC Layer LightWeight Filter-0000
DBUG (23:23:20.572) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.573) : 31: Microsoft Wi-Fi Direct Virtual Adapter #2-Native WiFi Filter Driver-0000
DBUG (23:23:20.575) :   Alias: Local Area Connection* 2-Native WiFi Filter Driver-0000
DBUG (23:23:20.576) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.578) : 32: Microsoft Wi-Fi Direct Virtual Adapter #2-QoS Packet Scheduler-0000
DBUG (23:23:20.580) :   Alias: Local Area Connection* 2-QoS Packet Scheduler-0000
DBUG (23:23:20.581) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.583) : 33: Microsoft Wi-Fi Direct Virtual Adapter #2-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.585) :   Alias: Local Area Connection* 2-WFP 802.3 MAC Layer LightWeight Filter-0000
DBUG (23:23:20.586) :   Type=IEEE802.11(71), Hardware=No, Filter=Yes
DBUG (23:23:20.588) : 34: Qualcomm Atheros AR938x Wireless Network Adapter
DBUG (23:23:20.589) :   Alias: Wi-Fi
DBUG (23:23:20.591) :   Type=IEEE802.11(71), Hardware=Yes, Filter=No
DBUG (23:23:20.593) : 35: Microsoft Wi-Fi Direct Virtual Adapter
DBUG (23:23:20.594) :   Alias: Local Area Connection* 1
DBUG (23:23:20.596) :   Type=IEEE802.11(71), Hardware=No, Filter=No
DBUG (23:23:20.598) : 36: Microsoft Hosted Network Virtual Adapter
DBUG (23:23:20.599) :   Alias: Local Area Connection* 10
DBUG (23:23:20.601) :   Type=IEEE802.11(71), Hardware=No, Filter=No
DBUG (23:23:20.603) : 37: Microsoft Wi-Fi Direct Virtual Adapter #2
DBUG (23:23:20.604) :   Alias: Local Area Connection* 2
DBUG (23:23:20.606) :   Type=IEEE802.11(71), Hardware=No, Filter=No
DBUG (23:23:20.608) : 38: Microsoft Teredo Tunneling Adapter
DBUG (23:23:20.609) :   Alias: Teredo Tunneling Pseudo-Interface
DBUG (23:23:20.611) :   Type=Tunnel(131), Hardware=No, Filter=No
DBUG (23:23:20.612) : 39: Microsoft IP-HTTPS Platform Adapter
DBUG (23:23:20.614) :   Alias: Microsoft IP-HTTPS Platform Interface
DBUG (23:23:20.616) :   Type=Tunnel(131), Hardware=No, Filter=No
DBUG (23:23:20.617) : 40: Microsoft 6to4 Adapter
DBUG (23:23:20.619) :   Alias: 6to4 Adapter
DBUG (23:23:20.621) :   Type=Tunnel(131), Hardware=No, Filter=No
DBUG (23:23:20.623) : 41: WAN Miniport (SSTP)
DBUG (23:23:20.624) :   Alias: Local Area Connection* 3
DBUG (23:23:20.626) :   Type=Tunnel(131), Hardware=No, Filter=No
DBUG (23:23:20.627) : 42: WAN Miniport (IKEv2)
DBUG (23:23:20.629) :   Alias: Local Area Connection* 4
DBUG (23:23:20.631) :   Type=Tunnel(131), Hardware=No, Filter=No
DBUG (23:23:20.632) : 43: WAN Miniport (L2TP)
DBUG (23:23:20.634) :   Alias: Local Area Connection* 5
DBUG (23:23:20.636) :   Type=Tunnel(131), Hardware=No, Filter=No
DBUG (23:23:20.637) : 44: WAN Miniport (PPTP)
DBUG (23:23:20.639) :   Alias: Local Area Connection* 6
DBUG (23:23:20.640) :   Type=Tunnel(131), Hardware=No, Filter=No
DBUG (23:23:20.642) : ------------------------------
DBUG (23:23:20.643) : ------------------------------

Save that file if you want for reference, then turn off Debug Mode and Delete Log.

To be honest though, I would NEVER use Index Number for any purpose. I don't trust it. I would use either "Best" or a specifically named network adapter, like "Qualcomm Atheros AR938x Wireless Network Adapter".
TTW
Posts: 3
Joined: February 22nd, 2019, 1:23 am

Re: Getting network adapter name with SysInfo?

Post by TTW »

I can't use "Best" as this system is multi-homed and I want to monitor several different interfaces. Also, what do you consider the difference to be between "adapter" and "interface"? Except for multi-port cards (which I do not have), I don't see how these are any different.

I'll try the debug log, which I assume will let me know the value to use for the NetUp & NetDown, but does that translate into the SysInfo interface index at all? Also, why do I get IPs for one interface and yet a description for another interface, even though I'm using the same value for SysInfoData?

Edit: I'll also try using the description instead, it just makes things a bit more tedious.
Last edited by TTW on February 22nd, 2019, 4:41 am, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Getting network adapter name with SysInfo?

Post by jsmorley »

TTW wrote: February 22nd, 2019, 4:38 am I can't use "Best" as this system is multi-homed and I want to monitor several different interfaces. Also, what do you consider the difference to be between "adapter" and "interface"? Except for multi-port cards (which I do not have), I don't see how these are any different.

I'll try the debug log, which I assume will let me know the value to use for the NetUp & NetDown, but does that translate into the SysInfo interface index at all? Also, why do I get IPs for one interface and yet a description for another interface, even though I'm using the same value for SysInfoData?
As I said, I would not use Index number at all. I don't trust it, and I don't think it is even the name number in SysInfo and Net. Use the full name of the adapter.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Getting network adapter name with SysInfo?

Post by jsmorley »

I would do something like:

Code: Select all

[Variables]
AdapterName=Qualcomm Atheros AR938x Wireless Network Adapter

[MeasureAdapter]
Measure=Plugin
Plugin=SysInfo
SysInfoType=ADAPTER_DESCRIPTION
SysinfoData=#AdapterName#

[MeasureType]
Measure=Plugin
Plugin=SysInfo
SysInfoType=ADAPTER_TYPE
SysinfoData=#AdapterName#

[MeasureLANIP]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysinfoData=#AdapterName#

1.jpg


I really don't know off the top of my head how to get that "Alias" like "Wi-Fi" and such.

Edit: get-wmiobject win32_networkadapter | select netconnectionid, name, InterfaceIndex, netconnectionstatus in Powershell.

2.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2604
Joined: March 23rd, 2015, 5:26 pm

Re: Getting network adapter name with SysInfo?

Post by SilverAzide »

I don't mean to toot my own horn, but if you get my Gadgets suite here you can use it with multi-homed systems to monitor up to 3 network adapters simultaneously (wired, wireless, and 1 other). In addition, it includes a plugin which will retrieve the network alias value I think you are looking for.

Another way to get the "alias" is to use Powershell:

Code: Select all

powershell -Command "Get-WmiObject -Class MSFT_NetAdapter -Namespace root\StandardCimv2 | Sort-Object -Property InterfaceType, Virtual, InterfaceDescription | Format-Table -Property @{Label='Interface Name'; Expression={$_.InterfaceDescription}}, @{Label='Alias'; Expression={$_.Name}}, Virtual, State, @{Label='Type'; Expression={$_.InterfaceType}} -AutoSize"
The Network Meter combines the 3 possible adapters into a single view, but you can easily tweak it (by making copies) to have one for each network adapter so you can monitor each individually.
Gadgets Wiki GitHub More Gadgets...