#!/bin/ksh # # Script Name: alarm_nfs_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 'nfsstat -cr': # like 'badcalls' # greater than 5% of 'calls'. # # Opens an alarm-msg-window on the host specified in $1. # # Could send alarm messages/mail to I-DEAS Admin hosts/people # -- like iaw030/bmo01, iaw070/rgb07, iaw025/wcs05. # # Also could append the alarm messages to file $2 (a 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" # # 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: B. Montandon 5May97 ############################################################################ # 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=2 WINMSG=`echo "\ **************** $DATETIME ****************** THIS SGI WORKSTATION HAS EXPERIENCED BAD NFS (2 or 3) CALLS in some category -- MORE THAN ${LIMPERCENT}% OF TOTAL CALLS --- sometime since boot-up. $BOOTTIME *** HOST: $HOSTNAME2 *** calls badcalls %badc retrans %retr badxid %badx timeout %timo wait %wait newcred ---------- -------- ----- -------- ----- -------- ----- -------- ----- -------- ----- -------- "` ############################################################################## ############### SAMPLE nfsstat -cr OUTPUT ######################## ############################################################################## ## Output of '/usr/etc/nfsstat -cr': ## ## Client RPC: from NFS2 ## calls badcalls retrans badxid timeout wait newcred ## 17142 11 33 12 35 0 0 ## ## Client RPC: from NFS3 ## calls badcalls retrans badxid timeout wait newcred ## 17142 11 33 12 35 0 0 ## ## ## Ref. O'Reilly Assoc. 'System Performance Tuning', p.184 & 197 ################################################################################# # Reformat the 'nfsstat -cr' output so that %badcalls, %retrans, %badxid, %timeout, # %wait columns are added. # Put this output in an environment variable, WINMSG0. Could use a work file if necessary. ################################################################################ # set -x WINMSG0=`/usr/etc/nfsstat -cr | nawk 'BEGIN { } length == 0 {next} /Client RPC:/ {next} /calls/ {next} # {printf ("%10s %8s %4.1f %-8s %4.1f %-8s %4.1f %-8s %4.1f %-8s %+4.1f %-8s \n", \ {printf ("%10s %8s %5.1f %8s %5.1f %8s %5.1f %8s %5.1f %8s %5.1f %8s \n", \ $1 , $2 , 100*$2/$1 , $3, 100*$3/$1 , $4, 100*$4/$1 , $5, 100*$5/$1 , $6, 100*$6/$1 , $7)} '` ############################################################################ # If %badcalls, %retrans, %badxid, %timeout, or %wait > 5, output those # nfs-info 'exception' lines to var WINMSG2. # The value to the right of the '>' sign should be the value of LIMPERCENT # which was set above. ############################################################################ WINMSG2=`echo "$WINMSG0" | awk 'BEGIN {print ""} ( $3 > 2 || $5 > 2 || $7 > 2 || $9 > 2 || $11 > 2 ) {print $0} ' ` # ( $3 > 0.1 || $5 > 0.1 || $7 > 0.1 || $9 > 0.1 || $11 > 0.1 ) {print $0} ' ` # ( $3 > 5 || $5 > 5 || $7 > 5 || $9 > 5 || $11 > 5 ) {print $0} ' ` # ( $3 > 2 || $5 > 2 || $7 > 2 || $9 > 2 || $11 > 2 ) {print $0} ' ` ############################################################################ # 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 98x${MSGLINES}+010+${ROWLOC} -e /apps/nns_com/fea/scripts/winmsg fi # set -