views:

40

answers:

1

Hi all,

The title says it all - how can I query specific adapters (ideally based on the IP address) from Win32_PerfFormattedData_Tcpip_NetworkInterface? I've spent a while googling this issue, but I didn't come up with a solution.

I tried using Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration, however, I cannot link these to the performance data.

As I happen to have more than one network adapter on certain systems I cannot differentiate which adapter the returned values belong to - any ideas?

Thank you

G.

A: 
            ConnectionOptions connection = new ConnectionOptions();
            ManagementScope scope = new ManagementScope("\\root\\CIMV2", connection);
            scope.Connect();

            ObjectQuery query = new ObjectQuery(
                "SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface");

            ManagementObjectSearcher searcher =
                new ManagementObjectSearcher(scope, query);

            foreach (ManagementObject queryObj in searcher.Get())
            {
                Console.WriteLine("Name: {0}", queryObj["Name"]);
                Console.WriteLine("Current Bandwidth: {0}", queryObj["CurrentBandwidth"]);
            }

My output was

Name: Realtek PCIe GBE Family Controller - Packet Scheduler Miniport Current Bandwidth: 100000000 Name: MS TCP Loopback interface Current Bandwidth: 10000000 Press any key to continue . . .

Similar to this you can enhance the properties of this Win32_ class

qasali
Thanks for your suggestion, but unfortunately that does not help me - I already tried to use the "Name" property, however, I cannot rely on it and I also cannot relate it to an adapter's ip-address. The "Name" property does have more or less random vendor specific contents, and it may be quite different for various servers and network adapters. So your suggestion works okay for a single system where I know which adapter is which, but as I have to query a lot of different servers I would ideally need the adapter's ip-address.
Gorgsenegger