My basic problem is that I want to find the total network IO from a list of IP addresses. Many of the servers have different NICs and some have teamed NICs.
Since it seems that I need to have the exact name for the network interface instance I have created an array of instance names:
Dim category As New PerformanceCounterCategory("Network Interface")
Dim instancenames As String() = category.GetInstanceNames()
I then step through the names and add to a list of performancecounter objects:
For Each instancename In instancenames
network.Add(New PerformanceCounter())
With network(i)
.CategoryName = "Network Interface"
.CounterName = "Bytes Total/sec"
.InstanceName = instancename
.MachineName = ip_address
End With
Try
network_usage = network_usage + network(i).NextValue()
Catch ex As Exception
End Try
i = i + 1
Next
The problem is that the names generated from the first part of the code raise an exception when I try to get the next value: "Instance 'Local Area Connection* 12' does not exist in the specified Category."
The names retrieved seem to be different from the names used when looking at perfmon on the particular server, not sure if this matters though