Network Bandwidth Monitoring Made Easy

First, let’s take a look at the performance counters we used for this monitor and the information each metric provides.

Metrics

BytesReceivedPersec

Bytes Received/sec is the rate at which bytes are received over each network adapter, including framing characters.

BytesSentPersec

Bytes Sent/sec is the rate at which bytes are sent over each network adapter, including framing characters.

BytesTotalPersec

Bytes Total/sec is the rate at which bytes are sent and received over each network adapter, including framing characters.

PacketsOutboundDiscarded

Packets Outbound Discarded is the number of outbound packets that were chosen to be discarded even though no errors had been detected to prevent transmission. One possible reason for discarding packets could be to free up buffer space.

PacketsOutboundErrors

Packets Outbound Errors is the number of outbound packets that could not be transmitted because of errors.

PacketsPersec

Packets/sec is the rate at which packets are sent and received on the network interface.

PacketsReceivedDiscarded

Packets Received Discarded is the number of inbound packets that were chosen to be discarded even though no errors had been detected to prevent their delivery to a higher-layer protocol. One possible reason for discarding packets could be to free up buffer space.

PacketsReceivedErrors

Packets Received Errors is the number of inbound packets that contained errors preventing them from being deliverable to a higher-layer protocol.

PacketsReceivedPersec

Packets Received/sec is the rate at which packets are received on the network interface.

PacketsSentPersec

Packets Sent/sec is the rate at which packets are sent on the network interface.

Source Code

The complete source code can be downloaded from Git. We’ll go over the parts of the source code that create the monitor and add the data.

Total Throughput Monitors

In the snippet below the monitor name is provided and the parameters are defined. The TotalBytesThroughput represents the sum of all network adapters’ throughput. The Total Packets/Sec monitor is the sum of all network adapters’ packet counters. The function “AddCustMon” adds the monitor to the dashboard using the standard Monitis API calls.

[gist]http://gist.github.com/1696401[/gist]

 

Individual Network Adapter Monitors

Next we need to add the two monitors for each network adapter in our system. We query the Win32_NetworkAdapterConfiguraiton object to only retrieve those adapters with a valid TCP/IP configuration. This will prevent inactive network connections from being added to the dashboard. We also need to name the monitors using the unique name of the network adapter so we can address the correct adapter when adding data.

[gist]http://gist.github.com/1696441[/gist]

 Pushing Data to the Monitors

Now that we have the monitor definitions added to the dashboard, it’s time to add the actual performance counter data to them.

First we initialize our variables to calculate the total throughput and total packets for all adapters. Then we loop through each network adapter in similar fashion as we did before and retrieve the metrics from the WMI class Win32_NetworkAdapter.

The metrics for each adapter are pushed to the custom monitor on the dashboard and we make sure to add the individual adapter metrics to the total counters. Once we’ve looped through all adapters, we push the calculated totals to the summary counters.

[gist]http://gist.github.com/1696447[/gist]

 Installing the monitor

After you downloaded the code from Git, you can install the custom monitor by executing the following command from a command window:

Cscript AddCustomBandwidthMonitor.vbs

clip_image001

This command creates a new monitor page on the Monitis dashboard called “Bandwidth” and adds the specific monitors. Of course no data is displayed until we actually run the monitor. To run the monitor and start collecting performance data execute the following command:

Cscript PushDataBandwidthMonitor .vbs

clip_image002

Once performance data is being collected you’ll be able to bring up your dashboard, select the Bandwidth tab and monitor the performance of your network adapter(s).

As said, the monitor will support multiple network adapters. We’ll create a monitor window for total bytes throughput for all adapters and another one for total packet traffic. We’ll also create the same monitors for each individual network adapter. The screenshot below shows two sets of monitors; one for the total traffic and one set for the network adapter in our system.

clip_image004

After you download the code from Git, you can of course edit the script and add other counters if you want.

You might also like