#! /bin/ksh # Script Name: pingaddrs_bysubnet # Where: in $FEDIR/scripts where FEDIR=/apps/nns_com/fea # # Purpose: Shows a menu of FEA dept hosts; inquires on who is on them. # # Called by: feamain -> feautils.menu -> netvu.menu # # Written by: B.Montandon C61 4Sep97 from$FEDIR/scripts/whosgihosts_bysubnet # Updated by: " C61 4Sep97 # if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi #. $FEDIR/scripts/set_localoutlist if test -d /local/scratch/$USER then OUTLIST="/local/scratch/$USER/pingaddrs_bysubnet.lis" else OUTLIST="$HOME/pingaddrs_bysubnet.lis" fi HOSTNAME=`hostname` # NNS_WHO_MSG=" Users and their terminal processes on host " # # Gives a list of 'iaw' ip addresses (and host names) sorted by ip address. # # # # # ypcat hosts | grep "iaw" | \ # ypcat hosts | egrep "iaw|sgia|sgib" | \ # awk '{printf "%-20s %-25s %-25s", $1 , $2 , $3 ; print "" }' | \ # sort -t. +0n -1 +1n -2 +2n -3 +3n -4 # # Gives a list of 'iaw' ip addresses (w/o host names) sorted by ip address. # # Last line extracts unique subnet addresses. # # # ypcat hosts | grep "iaw" | \ # ypcat hosts | egrep "iaw|sgia|sgib" | \ # awk '{printf "%-20s \n", $1 }' | \ # sort -t. +0n -1 +1n -2 +2n -3 +3n -4 | \ # cut -d. -f1,2,3 | uniq # SUBNETS=`ypcat hosts | grep "iaw" | \ # SUBNETS=`ypcat hosts | egrep "iaw|sgia|sgib" | \ SUBNETS=`ypcat hosts | \ awk '{printf "%-20s \n", $1 }' | \ sort -t. +0n -1 +1n -2 +2n -3 +3n -4 | \ cut -d. -f1,2,3 | uniq` # SUBNETSCMD="ypcat hosts | \ # awk '{printf \"%-20s \n\", $1 }' | \ # sort -t. +0n -1 +1n -2 +2n -3 +3n -4 | \ # cut -d. -f1,2,3 | uniq" winterm -name sgiSUBNETs -title sgiSUBNETs \ -hold -e $FEDIR/scripts/sho_sgisubnets # -hold -e "$SUBNETSCMD" # -hold -e echo "$SUBNETS" # while true while : do . $FEDIR/scripts/clearnns echo "\ ****************************************************************************** ${HIbold}\ Ping possible SGI-IRIX addresses (0 thru 255) -- on a subnet known to the 'sgia' network ${HIdim} Host: $HOSTNAME HOME Directory: $HOME Current Directory: `pwd` ${HIreset}" # ${HIreset}\ # Subnet ${HIdim} # ----------- ${HIreset}" # # echo "$SUBNETS" echo " ${HIdim} NOTE0: This utility should be used at quiet times (2nd,3rd shift;weekend). NOTE1: You can paste a subnet id from the list in the window that pops up. NOTE2: See nnsFEAmenu options 'h a1' or 'u h hi' or 'u n hi' for listings that indicate location of the following IP addresses (& subnets). NOTE3: You can use Alt-Break to break out if an address is not responding. NOTE4: Output is shown on screen and put in $OUTLIST ${HIbold}SUBNET (or null to exit) ==>${HIreset} \c" read feopt1 feopt2 feopt3 #${HIreset} Enter ? to pop up menu of SGI host display options. Try 3,i. # ###################### Exit checks ##################################### if test \( "$feopt1" = "x" -o "$feopt1" = "X" -o "$feopt1" = "" \) then # . $FEDIR/scripts/mv_rhosts # exit break fi if test \( "$feopt1" = "z" -o "$feopt1" = "Z" \) then # . $FEDIR/scripts/mv_rhosts exit fi # ###################### On ?, show subnet hosts ############################ if test "$feopt1" = "?" then winterm -name sgiSUBNEThosts -title sgiSUBNEThosts \ -e $FEDIR/scripts/hosts_on_sgia.menu # break continue fi # ###################### Subnet check/processing ############################ . $FEDIR/scripts/mak_rhosts SUBNET1="${feopt1}" SUBNETCHK=`echo "$SUBNETS" | grep "${SUBNET1}"` # # For test: # set -x if test "$SUBNETCHK" = "" then echo" Invalid subnet id: $SUBNET1 *** Press Enter to continue." read NNS_JUNK continue else echo " Do you want printout from IP-addresses that do NOT seem to be pingable? (y/n) Default = n" read NOTPING_OUT NNS_JUNK if test "$NOTPING_OUT" = "" then NOTPING_OUT="n" fi NOTPING_OUT=`echo $NOTPING_OUT | tr "[A-Z]" "[a-z]"` if test \( "$NOTPING_OUT" = "y" -a "$NOTPING_OUT" = "n" \) then echo" Invalid response to Not-Pingable/Output(y/n): $NOTPING_OUT *** Press Enter to continue/exit." read NNS_JUNK continue fi SUBNETADDRS="" # NODENUM=0 NODENUM=1 echo "\ .................... `date` ................... Ping of addresses Ping of possible SGI-IRIX addresses (0 thru 255) -- for 'sgia' subnet ${SUBNET1} Ping from Host: $HOSTNAME " > $OUTLIST # while test $NODENUM -lt 256 while test $NODENUM -lt 255 do SUBNETADDRS="$SUBNETADDRS ${SUBNET1}.$NODENUM" NODENUM=`expr $NODENUM + 1` done for ipaddr in $SUBNETADDRS do # HOSTNAME1=`ypcat hosts | grep "${ipaddr} " | awk '{printf "%-20s \n", $2 }'` # HOSTNAME1=`ypcat hosts | grep "${ipaddr} " | awk '{printf "%s \n", $2 }'` # The above grep with the trailing blank does not return some entries, and # without the trailing blank returns too many. # The following awk assures that a blank is after the IP-address, rather than a # tab or whatever. HOSTNAME1=`ypcat hosts | awk -v IPADDR=${ipaddr} '$1 ~ IPADDR {printf "%s %s \n", $1, $2 }' | grep "${ipaddr} "` echo " ......................................................................... Ping of $ipaddr (ypcat hosts Alias: $HOSTNAME1 ): " PINGOUT=`/usr/etc/ping -s 4 -c 1 $ipaddr` PINGCHECK=`echo $PINGOUT | grep '100% packet loss'` if test "$PINGCHECK" = "" then echo " ......................................................................... Ping of $ipaddr (ypcat hosts Alias: $HOSTNAME1 ): " >> $OUTLIST # set -x /usr/etc/ping -s 56 -c 5 $ipaddr | tee -a $OUTLIST # set - else if test "$NOTPING_OUT" = "y" then echo " ......................................................................... Ping of $ipaddr (ypcat hosts Alias: $HOSTNAME1 ): " >> $OUTLIST echo "$PINGOUT" | tee -a $OUTLIST fi fi done . $FEDIR/scripts/shofil $OUTLIST # echo " # *** Press Enter to continue." # read NNS_JUNK fi done