#!/bin/ksh ## ## SCRIPT NAME: sho_dns_hosts ## Where : in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################## ## PURPOSE: Uses 'nslookup' 'ls' command to show sorted list of NNS hosts ## (and various non-printer DNS devices) sorted by-name. ## ## I.e. shows devices in nns.com domain but NOT in prt.nns.com domain. ## ############################################################################## ## WHERE CALLED: by hosts_on_sgia.menu in several different menus: ## ## feamain -> feautils.menu -> hostvu.menu -> hosts_on_sgia.menu ## and feamain -> feautils.menu -> netvu.menu -> hosts_on_sgia.menu ## and feamain -> feahelpg.menu -> hosts_on_sgia.menu ## ############################################################################## ## MAINTENANCE HISTORY: ## Written by: B. Montandon 8Sep98 ## Updated by: B. Montandon 7Jun99 sort 'A' recs separate from 'CNAME' (alias) ## recs; similar to 'prtplt_sho_dns_prtrs' ## Updated by: B. Montandon 7Jun99 add opt to sort by IP-address or dev-name ############################################################################## if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi . $FEDIR/scripts/clearnns ############################################################################## ## PREP THE NAMES OF THE LIST FILE (AND AN INTERMEDIATE FILE). ############################################################################## . $FEDIR/scripts/set_localoutlist OUTLIST2=${OUTLIST}2 ############################################################################## ## PROMPT FOR SORT TYPE -- by IP-address or device-name. ############################################################################## echo "${HIbold}\ ........................................................................... ${HIdim}SHOW/PRINT *COMPLETE,CURRENT* SORTED LIST OF${HIbold} DEVICES defined in the NNS 'nns.com' domain${HIreset} i d ${HIbold}Do you want to sort by IP-address or device-name? (i/d) (Null to exit.) ==>${HIreset} \c" read SORTIND if test "${SORTIND}" = "" then # break continue fi ############################################################################## ## SET $SORTMSG. ############################################################################## if test "${SORTIND}" = "d" then SORTMSG="SORTED BY DEVICE-NAME. (Aliases ['CNAME' recs] are at the bottom.)" else SORTMSG="SORTED BY IP-ADDRESS." fi ############################################################################## ## PREP THE TOP OF THE LIST (A HEADING). ############################################################################## echo "\ ***************************** `date '+%Y %b %d %a %T%p %Z'` ***************** HOST MACHINES (& other devices) on the NNS NETWORK in the 'nns.com' domain -- according to NNS DNS (Domain Name Service) via the 'nslookup' command. Query performed from host: `hostname` $SORTMSG A description of this list is at the bottom of the list. ------------------------------------------------------------------------ " > $OUTLIST2 ############################################################################## ## GATHER THE LIST CONTENTS -- with nslookup. ############################################################################## ## For testing: # set -x nslookup > $OUTLIST << ENDofINPUT ls -t ANY nns.com exit ENDofINPUT ############################################################################## ## VARIOUS SORT TESTS/ATTEMPTS (commented). ############################################################################## # sort $OUTLIST >> $OUTLIST2 # sort +1b -2b +0 -1 $OUTLIST >> $OUTLIST2 # grep "^ " $OUTLIST | sort +1b -2b +0 -1 >> $OUTLIST2 # egrep '^ ' $OUTLIST | egrep ' A |CNAME' | sort +1b -2b +0 -1 >> $OUTLIST2 # egrep '^ ' $OUTLIST | egrep ' A |CNAME' | sort +1b -2b +0 -1 | nl >> $OUTLIST2 # egrep '^ ' $OUTLIST | egrep ' A |CNAME' | sort -f +1b -2b +0 -1 | nl >> $OUTLIST2 ############################################################################## ## EXTRACT & SORT THE LIST. ############################################################################## if test "${SORTIND}" = "d" then egrep '^ ' $OUTLIST | egrep ' A |CNAME' | sort +1b -2b +0 -1 | \ nl >> $OUTLIST2 else egrep '^ ' $OUTLIST | egrep ' A ' | \ awk '{printf "%-20s %-7s %-27s \n", $3 , $2 , $1 }' | \ sort -t. +0n -1 +1n -2 +2n -3 +3n -4 | nl >> $OUTLIST2 # awk '{printf "%-20s %-7s %-27s \n", $3 , $2 , $1 ; print "" }' | \ # awk '{print $3 " " $2 " " $1}' | \ fi # rm $OUTLIST ## For testing: # set - ############################################################################## ## PREP THE BOTTOM OF THE LIST (A TRAILER). ############################################################################## echo " ---------------------------------------------------------------------------- INFO IN THIS LIST: This is a list of many hundreds of network device-identifiers -- along with their IP-addresses. The device-identifiers are usually - Unix (or NT) hostnames -- including server names, like mail servers or web/proxy servers -OR- - communications box names, like router names. The device-identifier may be an NNS Unix host name -- like 'iaw###' for SGI IRIX hosts and 'aix###' or 'acw###' for IBM AIX hosts. NT mail server names are currently (Jun99) of the form 'nnse#'. Note1: The 'A' records show the NNS IP address associated with the device name. (IP = Internet Protocol) Note2: The 'CNAME' records (at the bottom of the list sorted by device-name) show *aliases* for NNS-assigned device names. The 'CNAME' records are not shown in the list sorted by IP-address. Note3: This list was an up-to-date image from the NNS 'nns.com' DNS domain -- at the time indicated in the time-stamp at the top of this list. ------------------------------------------------------------------------ DEVICE DESCRIPTIONS/LOCATIONS: This list does NOT include *descriptions/locations* of each of these devices. If you need device location or model information -- for example, to solve a network problem: Ask a Computer/Network Support person for help, like an SGI, or other Unix, System Administrator (of O05C 'Open Systems' Support). (If you cannot connect to a Computer/Network Support person, you could call 8-HELP to find an appropriate contact for information on an 'nns.com' device.) ------------------------------------------------------------------------ SOURCE OF THIS LIST: This list comes from the NNS DNS (Domain Name Service) via the 'nslookup' command -- applied to domain 'nns.com'. This inquiry is available among the network HOST/DEVICE inquiries & lists at nnsFEAmenu options 'h a1' (Help-general,Architecture-hosts) or 'u n hi' (Utilities,NetVu,Host-IDs) or 'u h hi' (Utilities,HostVu,Host-IDs) In particular, this list was generated by running the script $FEDIR/scripts/sho_dns_hosts on host `hostname` . ------------------------------------------------------------------------ UNDER THE COVERS: This list was assembled using the 'nslookup' command with the 'ls -t ANY' sub-command. Specifically, nslookup > $OUTLIST << ENDofINPUT ls -t ANY nns.com exit ENDofINPUT followed by an extract and a sort and numbering (with 'egrep', 'sort', 'nl'). In the case of a list sorted by IP-address, 'awk' is used to put the IP-address in the 1st column -- for easier sorting and for readability. For information on the output of 'nslookup', you can type 'man nslookup' in an SGI winterm window. Or you can refer to the 'Man Pages' or 'OnLine Books' (Search option) in the bottom Help drawer of the SGI Toolchest. ********************* END OF LIST OF DEVICE IDENTIFIERS ********************* ************** on the NNS NETWORK, in the 'nns.com' domain ****************** " >> $OUTLIST2 $FEDIR/scripts/shofil $OUTLIST2 # set -