#!/bin/ksh ## ## SCRIPT NAME: alarm_neti_1host ## ## Where: in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ## ############################################################################ ## PURPOSE: ## To check the host that this script runs on for 'exception'/'alarm' ## conditions -- with respect to 'netstat -i': ## like ethernet collisions ## greater than 10% of packets-out. ## ## Opens an alarm-msg-window on the host specified in $1. ## ## Could send alarm messages to I-DEAS Admin hosts ## -- like iaw030, iaw070, iaw025. ## Also could append the alarm messages to file $2 (name passed to ## this script). ## ############################################################################ ## CALLED BY: $FEDIR/scripts/alarm_scan script --- or manually ## ############################################################################ ## TECHNIQUE: 'alarm_scan' repeatedly does ## ## rsh iaw### script where ### is 000, 001, 002, ..., 100, ... ## ## where script is this script ## "$FEDIR/scripts/alarm_neti_1host $HOST4MSG" ## ############################################################################ ## MAINTENANCE HISTORY: ## Written by: B. Montandon 5May97 to look for clients generating heavy I/O ## on the 'sgia' file server -- or clients ## clobbering themselves or their sub-net neighbors. ## Updated by: Blaise Montandon 05jun2002 Chgd '/apps/nns_com/fea' hard-coding ## to $FEDIR var, for SGI portability. ############################################################################# ############################################################################## ## Set scripts pathname in case this script is not started from ## the nnsFEAmenu system --- and a $FEDIR utility script is needed. ############################################################################## if test "$FEDIR" = "" then FEDIR="/apps/nns_com/fea" export FEDIR fi ############################################################################ ## Set DISPLAY location for the following xwsh-winmsg display. ############################################################################ if test ! "$1" = "" then DISPLAY=${1}:0 export DISPLAY fi ############################################################################ ## Set a work file (& list file, unused at this time). But could use an in-memory# variable instead of the work file. ############################################################################ # if test -w /local/scratch # then # OUTWORK=/local/scratch/topcpu_temp.all # # OUTLIST=/local/scratch/topcpu_temp.lis # else # OUTWORK=$HOME/topcpu_temp.all # # OUTLIST=$HOME/topcpu_temp.lis # fi ############################################################################ ## Prepare alarm message heading. ############################################################################ HOSTNAME=`hostname` HOSTNAME3=`/usr/etc/arp $HOSTNAME` HOSTNAME2=`echo "$HOSTNAME3" |sed "s|-- no entry||"` # echo "*** $HOSTNAME2 ***" >> $1 BOOTTIME=`who -b` DATETIME=`date` # LIMPERCENT=5 LIMPERCENT=3 WINMSG=`echo "\ ******************** $DATETIME ******************* THIS SGI WORKSTATION HAS EXPERIENCED A PACKET COLLISION RATE (PROBABLY MUCH) GREATER THAN ${LIMPERCENT}% --- sometime since boot-up. $BOOTTIME *** HOST: $HOSTNAME2 *** (Ave. since boot) %Collisions of Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll in+out out-only ---- ----- ---------- ---------------- ----- ----- ------- ----- ----- ------ -------- "` ############################################################################## ## SAMPLE netstat -i OUTPUT . ############################################################################## ## Output of '/usr/etc/netstat -i': ## ## Cols: ## ## Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll ## ec0 1500 150.10.2 iaw030.cae.nns~ 69668 0 26274 0 229 ## lo0 8304 loopback localhost 5097 0 5097 0 0 ## ## ## Importance to this list: ## ## Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll ## * * ** * ** ** ## ## Ref. O'Reilly Assoc. 'System Performance Tuning', p.181-184 & 187-194 ## See awk-based script to diff the netstat output, p.184. ############################################################################## ################################################################################# ## Reformat the netstat -i output so that %Collisions-of-total-in&out and ## %Collisions-of-outpkts are in the last two columns. ## Put this in an environment variable, WINMSG0. ## Could use a work file if necessary. ################################################################################ # set -x WINMSG0=`/usr/etc/netstat -i | nawk 'BEGIN { } NR == 1 {next} {printf ("%s %7.1f %7.1f \n", $0, 100*$9/($7 + $5), 100*$9/$7 )} ' | sort -t: +9nr -10` ############################################################################ ## If %Collisions-of-total-in&out > 5, output those process-info ## 'exception' lines to var WINMSG2. ############################################################################ WINMSG2=`echo "$WINMSG0" | awk 'BEGIN {print ""} ( $10 > 5 ) {print $0} ' ` if test "$USER" = "bmo01" then echo "$WINMSG0" fi ############################################################################ ## Display the alarm-msg display -- if WINMSG2 is not empty. ############################################################################ if test ! "$WINMSG2" = "" then WINMSG=${WINMSG}$WINMSG2 export WINMSG MSGLINES=`echo "$WINMSG" | wc -l` MSGLINES=`expr $MSGLINES + 5` ROWLOC=`date +%S` ROWLOC=`expr 10 \* $ROWLOC` # set -x # xwsh -bg gray78 -fg black -hold -autofork \ xwsh -bg red2 -fg snow1 -autofork \ -title "COLLISIONS_$HOSTNAME" -name "COLLISIONS_$HOSTNAME" \ -fn -*-screen-medium-r-normal--15-*-*-*-m-80-iso8859-1 \ -geometry 95x${MSGLINES}+090+${ROWLOC} -e $FEDIR/scripts/winmsg fi # set -