Listing 2: George Sullivan's collision percentage calculator
#!/bin/sh
############################### GENERAL INFO #######################
#
#Title:             NC: meaning Node Collisions, Nasty Collisions
#                   Number Collisions - your choice.
#Author:            George Sullivan
#Date:              Wednesday, December 7, 1994
#Description:       NC calculates a percentage based on the number of output
#                   packets and collisions resulting from the netstat command.
#                   The number of collisions are divided by the number of output
#                   packets. Then this result is multiplied by 100 to establish the
#                   the percentage. The percentage can be monitored periodically
#                   and corrective action can be taken should the percentage be
#                   abnormal.
#Requirements:      NC requires the following unix commands: netstat, grep,
#                   awk, bc
         
#####################################################################
         
############################### VARIABLES ###########################
         
#HN=Hostname
#OP=Output Packets
#CO=Collisions
         
HN='hostname'
OP='netstat -ni | grep 'leO' | awk '{print $7}"
CO='netstat -ni | grep 'leO' | awk '{print $9}"
         
####################################################################
         
############################## FUNCTION ############################
         
CALCULATE ()
{
   DECIMAL='echo "scale=5 ; $CO/$OP" | bc'
   BASE='echo "scale=5 ; $DECIMAL*100" | bc'
   echo The collision rate for host $HN is:
   echo
   echo "$BASE"%
}  


