#!/bin/ksh # Script: netstat_ifdelta # 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. Gets a series of netstat reports # and normalizes them. # Ref: p.184 of 'System Performance Tuning', Mike Loukides, # O'Reilly & Associates, 1992 # # Call format: $FEDIR/scripts/netstat_ifdelta # # Called by: feautils.menu/netvu.menu/netstat_ifpakets_delta script (or manually) # # Written by : B. Montandon 28Oct96 # Last Update: B. Montandon 4Nov96 # if test "$1" = "" then echo " Need to supply a number of snapshots to take (every 1 sec) to script $0. Exiting ... " exit fi if test "$2" = "" then echo " Need to supply an interface name (like ec0) to script $0. Exiting ... " exit fi count=0 # set -x # one delta report every 'sleep 1' secs (like vmstat, sar, nfsstat,etc.) ( while test $count -lt $1 do /usr/etc/netstat -i sleep 1 count=`expr $count + 1` done ) | nawk -v IFACE=$2 \ 'BEGIN { print " New-Ipkts New-Ierrs New-Opkts New-Oerrs Collis \n"; pipkts=0; pierrs=0; popkts=0; poerrs=0; pcollis=0; # IFACE = ARGV[1] # delete ARGV[1] } # end of BEGIN # find the line describing the interface specified in $2 #g /^ec0/ \ $1 ~ IFACE \ { ipkts = $5 - pipkts; ierrs = $6 - pierrs; opkts = $7 - popkts; oerrs = $8 - poerrs; collis = $9 - pcollis; printf ("%5s %12d %12d %12d %12d %12d", $1, ipkts, ierrs, opkts, oerrs, collis); print "\n"; pipkts = $5; pierrs = $6; popkts = $7; poerrs = $8; pcollis = $9; }' - # }' > $HOME/temp.lis # set -