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+

IT ManagementWhite Papers & Webcasts

See more White Papers | Webcasts

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question