#!/bin/ksh ## ## SCRIPT: prtplt_chk_netconnect ## ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ############################################################################## ## ## PURPOSE: ## For a given NNS 'TelecomID' (like t123654 or h12345), ## 1) checks for IP address in a user specified NNS DSN domain, ## like 'prt.nns.com' or 'nns.com', ## and ## 2) if IP address exists, pings it to determine if the ## device (print-server box/card) is responding. ## ## ############################################################################## ## ## CALLED BY: 'prtplt_mgr' script in $FEDIR/scripts ## where FEDIR=/apps/nns_com/fea ## actually, by 'prtplt_mgr.chestdef' in $FEDIR/scripts. ## ## I.e. called by clicking on the PrtPlt_Mgr menu item (toolchest drawer) ## ## 'CHECK_NET_CONNECTION; of TelecomID' ## ############################################################################## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon O06 4Jun1999 Based on prtplt_sho_Qstatus ## in $FEDIR/scripts/ ## Updated by: Blaise Montandon O06 29Apr2000 Chgd from '100% packet loss' ## to '100.0% packet loss'. ## Updated by: Blaise Montandon O06 27Jun2000 Removed -s & -T parms from ping. ## Updated by: Blaise Montandon 19Jul2001 Chg GUI to get 'domain' as well ## as 'telecomID' from user. I.e. ## allow for 'nns.com' domain (or ## other) as well as 'prt.nns.com'. ############################################################################## if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi THISHOST=`hostname` ##################################################################### ## SET WINDOW TITLE FOR PROMPT FOR NNS TELECOM_ID & DOMAIN_NAME --- ## and initialize 'TELECOM_ID' and 'DOMAIN_NAME' vars. ##################################################################### WINTITLE="PrtPlt_Mgr, Chk_TELECOM_ID_NetConnection" export WINTITLE TELECOM_ID="" export TELECOM_ID DOMAIN_NAME="prt.nns.com" export DOMAIN_NAME ##################################################################### ## START OF PROMPT-LOOP FOR NNS TELECOM_ID. ##################################################################### while : do # TELECOM_ID=`$FEDIR/tkGUIs/enter_telcomid.tk` TEMP=`$FEDIR/tkGUIs/enter_telcomid_domain.tk` eval "$TEMP" ##################################################################### ## The var TEMP contains a string like ## TELECOM_ID="h#####" ; DOMAIN_NAME="prt.nns.com" ##################################################################### if test "$TELECOM_ID" = "" then exit fi # if test "$DOMAIN_NAME" = "" # then # exit # fi ##################################################################### ## REMOVE BLANKS (esp. trailing) from TELECOM_ID. ##################################################################### TELECOM_ID=`echo "$TELECOM_ID" | sed 's| ||g'` ##################################################################### ## DETERMINE IF THE TELECOM_ID is in the specified DOMAIN. ##################################################################### ## I.e. get an IP-address corresponding to the TELECOM_ID. ## If IP-address found, put out a 'not found in DNS' message. ## If IP-address found, do a ping test: ## If ping test returns 100% packets, put out 'good' message; ## else put out a 'not-good' message. ##################################################################### NSLOOKUP_MSG=`/usr/sbin/nslookup ${TELECOM_ID}.$DOMAIN_NAME 2>/dev/null` ## For testing: # echo "$NSLOOKUP_MSG" IP_ADDRESS=`echo $NSLOOKUP_MSG | awk '{print $8}'` ##################################################################### ## if test "$IP_ADDRESS" = "" ##################################################################### if test "$IP_ADDRESS" = "" then NNS_JUNK=`xconfirm -c -header "TelecomID Query" -B DISMISS \ -t "An IP-Address for TelecomID ${TELECOM_ID} was not found " \ -t "in DNS domain '$DOMAIN_NAME' via the 'nslookup' command. " \ -t "" \ -t "TelecomID ${TELECOM_ID} DOES NOT SEEM TO BE DEFINED" \ -t "in the NNS DNS '$DOMAIN_NAME' domain." \ -t "" \ -t "(DNS = Domain Name System)" \ -t "" \ -t "** TRY ANOTHER DOMAIN, OR, if TelecomID was mis-spelled," \ -t "** CORRECT THE TELECOMID --- and try this query again." \ -t "" \ -t "NOTE: Use 't' in front of an all-numeric TelecomID." \ -icon warning` # -t "" \ # -t "Try another TelecomID or call SGI SysAdmins at 8-HELP -- " \ # -t "or call an I-DEAS Administrator." \ # exit continue ##################################################################### ## ELSE for -- if test "$IP_ADDRESS" = "" ##################################################################### else NNS_JUNK=`xconfirm -c -header "TelecomID Query" -B DISMISS \ -t "'Pinging' IP Address $IP_ADDRESS" \ -t "" \ -t "which is assigned to TelecomID ${TELECOM_ID}," \ -t "in the NNS '$DOMAIN_NAME' domain." \ -t "" \ -t "Results will be displayed in several seconds." \ -icon warning` & # /usr/etc/ping -c5 $IP_ADDRESS # /usr/etc/ping -s 4 -c 1 $IP_ADDRESS > /dev/null # PINGOUT=`/usr/etc/ping -s 4 -c 1 -T 1 $IP_ADDRESS` PINGOUT=`/usr/etc/ping -c 5 $IP_ADDRESS` PINGCHECK=`echo "$PINGOUT" | grep '100.0% packet loss'` ## FOR TESTING: # echo " " # echo "$PINGOUT" # echo " " # echo "$PINGOUT" | fold -s -w60 if test ! "$PINGCHECK" = "" then NNS_JUNK=`xconfirm -c -header "TelecomID Query" -B DISMISS \ -t "IP address $IP_ADDRESS (for TelecomID ${TELECOM_ID})" \ -t "is NOT PINGABLE." \ -t "" \ -t "Result from 'ping' test:" \ -t "" \ -t "Less than 100% of 5 ping packets returned." \ -t "" \ -t "Network connection appears to be 'broken'." \ -t "" \ -t "Try this query two more times. If it still fails and" \ -t "" \ -t "if you think this TelecomID's IP-address should be reachable," \ -t "call SGI SysAdmins at 8-HELP -- " \ -t "or call an I-DEAS Administrator." \ -icon warning` else NNS_JUNK=`xconfirm -c -header "TelecomID Query" -B DISMISS \ -t "IP address $IP_ADDRESS (for TelecomID ${TELECOM_ID})" \ -t "IS PINGABLE." \ -t "" \ -t "Result from 'ping' test:" \ -t "" \ -t "100% of 5 ping packets returned." \ -t "" \ -t "Network connection appears to be GOOD." \ -icon warning` fi fi ##################################################################### ## END OF -- if test "$IP_ADDRESS" = "" ##################################################################### ##################################################################### ## SHOW OUTPUT QUEUED, IF ANY. (Not used. Output is put in ## xconfirm window.) ##################################################################### # echo " # `date '+%d%b%Y %I:%M%p'` # # ********* END OF QUERY ON STATUS OF $TELECOM_ID ******** # " >> $OUTLIST # set -x # export SHOFILENAME="$OUTLIST" # $FEDIR/tkGUIs/shofil.tk & # set - export TELECOM_ID DOMAIN_NAME done ## END OF 'while' PROMPT-LOOP FOR NNS TELECOM_ID