# Script: netstat_ifpakets_delta # Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea # # Purpose: Shows 'delta' packet activity by protocol on a specified host # using the 'netstat -i' command. # Ref: p.184 of 'System Performance Tuning', Mike Loukides, # O'Reilly & Associates, 1992 # # Called by: feautils.menu/netvu.menu script (or manually) # # Written by : B. Montandon 28Oct96 # Updated by : B. Montandon 4Nov96 # Updated by : B. Montandon 8May97 better .rhosts handling # set -v # HOSTNAME=`hostname` OUTLIST=$HOME/temp.lis . $FEDIR/scripts/clearnns echo "\ .......................................................................... ${HIbold}\ SHOW PACKET ACTIVITY AT A COMMUNICATIONS INTERFACE ON A HOST (like ethernet interface 'ec0') This Host: `hostname` ${HIreset} Commands used: /usr/etc/netstat -i ten times, with 'sleep 1' ten times -- and a rather complex implementation of the 'awk' command. ${HIdim} You will be given an opportunity to browse output in $OUTLIST in this window. .......................................................................... ${HIreset} NOTE: You can start a 'net-packets-delta' display for this host and display its results with the 'w' display option. Then use this nnsFEAmenu option again ... say, in another nnsFEAmenu session in another window ... to start another 'net-packets-delta' display for another host -- for comparison of packet activity. .......................................................................... ${HIbold} Enter HOSTNAME (default = this host, `hostname` ) ('x' to exit) ==>${HIreset} \c" read hostname1 if test "$hostname1" = "x" then continue # break fi HOSTNAME=$hostname1 LOCALHOST="N" if test \( "${hostname1}" = "" -o "${hostname1}" = "`hostname`" \) then HOSTNAME=`hostname` LOCALHOST="Y" fi echo " .........................................................................." if test "$LOCALHOST" = "Y" then /usr/etc/netstat -i | tail +2 | awk '{ print $1 }' else # echo "+ $USER" > $HOME/.rhosts . $FEDIR/scripts/mak_rhosts rsh $HOSTNAME /usr/etc/netstat -i | tail +2 | awk '{ print $1 }' # . $FEDIR/scripts/mv_rhosts fi echo "${HIbold} Enter an Interface name from the list above (like ec0 or ipg1). ('x' to exit) ==>${HIreset} \c" read ifname1 if test "$ifname1" = "x" then continue # break fi echo "\ ............................................................................. SHOW PACKET ACTIVITY AT COMMUNICATIONS INTERFACE $ifname1 ON HOST $HOSTNAME Commands used: /usr/etc/netstat -i ten times, with 'sleep 1' ten times -- and a rather complex implementation of the 'awk' command. More than 100 packets in or out in each snapshot indicates a heavy load (or loop) if the packets are more than 1,000 bytes in size. The first line contains totals since the last bootup of this host, $HOSTNAME. ____________________ `date` _______________________ " > $OUTLIST echo " Wait about 15 seconds ... " if test "$LOCALHOST" = "Y" then # set -x $FEDIR/scripts/netstat_ifdelta 10 $ifname1 >> $OUTLIST # set - else # echo "+ $USER" > $HOME/.rhosts . $FEDIR/scripts/mak_rhosts ( rsh $HOSTNAME $FEDIR/scripts/netstat_ifdelta 10 $ifname1 ) >> $OUTLIST # . $FEDIR/scripts/mv_rhosts fi echo " _____________________________________________________________________________ " >> $OUTLIST . $FEDIR/scripts/shofil $OUTLIST