1

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

foreachin
  • 91
  • 6
  • I checked [this](http://stackoverflow.com/questions/6572397/reading-performance-counter-from-c-instance-does-not-exist-in-the-specified-ca?rq=1) and it seems similar so I checked the program pointing to the IP of a 32 bit system and it returns network activity so I am assuming this is the problem, not sure how to change to any CPU using VS express 2010 though – foreachin Aug 07 '13 at 13:54
  • Tried the solution from [Here](http://stackoverflow.com/questions/4104228/change-target-cpu-settings-in-visual-studio-2010-express) but I cannot debug and I do not get any results generated so I am again stuck – foreachin Aug 07 '13 at 14:27
  • Looks like I'm talking to myself but just in case someone finds this, I have managed to do a build using x64 which runs on 64 bit machines successfully - it generates a different list of network instances though so my next quest is to find how to get the 64 bit list of instances from a server when the program is running on a 32 bit system! – foreachin Aug 07 '13 at 15:29

0 Answers0