Unix How-To: Checking on Collisions

By  

Note that we're omitting the loopback in this command.

ifconfig -a | grep -v ^lo | grep UP | awk '{print $1}' | sed 's/://'
dmfe0

A script that runs through all operational interfaces and provides a collision rate might
look like this:

#!/bin/bash

NICS=`ifconfig -a | grep -v ^lo | grep UP | awk '{print $1}' | sed 's/://'`

for if in $NICS
do
    echo -n "$if "
    netstat -i | grep ^$if | awk '{print $9 / $7 }' 2>/dev/null
done
echo

Your output would look something like this:

./getColls
dmfe 0.000159242

The extra caution of sending errors to /dev/null is just in case an interface is active but has seen no traffic. We won't be comitting the high crime of dividing by zero. This is also the reason for the extra echo at the bottom of the script -- to make sure we're not ending without a linefeed.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Spotlight on ...
Online Training

    Upgrade your skills and earn higher pay

    Readers to share their best tips for maximizing training dollars and getting the most out self-directed learning. Here’s what they said.

     

    Learn more

IT ManagementWhite Papers & Webcasts

See more White Papers | Webcasts

Answers - Powered by ITworld

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question
randomness