Use netstat to See Interface Statistics

We can use netstat to see interface statistics including errors. This is typically done to verify that you have don’t have layer 1/layer 2 issues. For example if a switch port is configured for 100/Auto and the device expects 1000/Auto it may have issues. Setting both ports to the same speed manually

Netstat Interface Statistics Example:

Monitor Netstat Interface Statistics (seconds)

What if you want to monitor bytes, errors, or other specific aspects of the netstat interface statistics? Netstat has an interval flag, but it shows you everything so you’ll need to use the findstr command parse out what you want:

This is all well and good for troubleshooting an interface, but you are limited to 1 second intervals. if you are want monitor errors at a different interval, you’ll need to read on…

Monitor Netstat Interface Statistics (Milli Seconds)

By using a for loop you can specify the loop interval in milliseconds. You could do it the fancy pants way with a for loop instead, though the above method is cleaner and easier to remember.

The below for loop method will allow you to run any command, even ones that don’t have a built in interval check (just replace netstat with whatever command you want to test.

The following for loop loops indefinitely, pausing for 100ms to ping the multicast address, dumping the ping results (which are invalid anyway).

Looking at Packets, but not Unicast Packets

I wouldn’t particularly need the following filter, but I wanted to expand on how powerful the proper use of ‘find’ or ‘findstr’ can be. In the following example, we look for “packets” but ignore “unicast” packets and specify a 100ms delay between checks.

Summary of Netstat Error Checking

It’s easiest to find errors and then diagnose them if you use the proper netstat searches. In large volume networks there are more appropriate tools, but for bringing a new server online and diagnosing why it is slow, netstat has a great built in statistics and error checking capability.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.