#!/bin/ksh ## ## SCRIPT NAME: prtplt_sho_dns_hosts_IPsort ## ## 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 & printer DNS devices) --- ## sorted by IP-address, rather than by-device-name. ## ## See 'prtplt_sho_dns_hosts' for sort by-name. ## ## NOTE: This utility shows devices in nns.com domain, but NOT in ## prt.nns.com domain. ## Starting in mid-2000, printers started showing up in the nns.com ## domain instead of the prt.nns.com domain, as DHCP was being ## implemented to recognize printer definitions. ############################################################################## ## CALLED BY: $FEDIR/scripts/prtplt_mgr -> ## $FEDIR/tkGUIs/prtplt_lists ## ## where $FEDIR/scripts/prtplt_mgr is called by 'handytools' command, ## $FEDIR/scripts/handytools -- actually by ## $FEDIR/scripts/handytools.chestdef ## ## and also by the 'screentools' command, $FEDIR/scripts/screentools ## --- actually by $FEDIR/scripts/screentools.chestdef. ## ## Can also be called user $HOME/.auxchestrc files. Example: ## /usr/people/bmo01/.auxchestrc. ## ## Could also be a desktop icon, created by 'Find, File QuickFind' on ## SGI Toolchest. ############################################################################## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 09mar2001 Based on 'prtplt_sho_dns_hosts' ## in $FEDIR/scripts ## ## Updated by: Blaise Montandon 07May2003 Add xconfirm-prompt whether to add ## line numbers to the list of IP ## addresses --- to make 'nl' an option. ############################################################################## if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi ############################################################################## ## PROMPT USER WHETHER LINE NUMBERS ARE WANTED. ############################################################################## NUM_REPLY=`xconfirm -c -header "DNS IP-sort Utility" \ -B NONUM -b NUM \ -t "Do you want line numbers on the IP-address lines?" \ -t "" \ -t " NUM or NONUM" \ -icon warning` NLCMD="" if test "$NUM_REPLY" = "NUM" then NLCMD=" | nl" fi ############################################################################## ## WARN USER THAT THIS QUERY WILL TAKE ABOUT 10 SECONDS. ## (I.e. the next popup will be in about 10 secs.) ############################################################################## xconfirm -c -B DISMISS \ -t "This ALL-DNS-devices query will take about 10 secs to complete." \ -font -*-courier-bold-r-normal-*-14-*-*-*-*-*-*-* \ > /dev/null & # -font -adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-* \ ############################################################################## ## PREP THE NAMES OF THE LIST FILE (AND AN INTERMEDIATE FILE). ############################################################################## . $FEDIR/scripts/set_localoutlist OUTLIST2=${OUTLIST}_2 ############################################################################## ## PREP THE TOP OF THE LIST (A HEADING). ############################################################################## echo "\ ****************** `date '+%Y %b %d %a %T%p %Z'` *************************** HOST MACHINES (& other devices, like routers and printers) on the NNS NETWORK, in the 'nns.com' domain -- according to NNS DNS (Domain Name Service), via the 'nslookup' command. Performed on host: `hostname` SORTED BY *IP-ADDRESS*. A description of this list is at the bottom of the list. ------------------------------------------------------------------------ " > $OUTLIST2 ############################################################################## ## GATHER THE LIST CONTENTS -- with nslookup. ############################################################################## ## 'man nslookup' shows: ## ## ls [option] domain [> filename] ## ls [option] domain [>> filename] ## List the information available for domain, optionally creating or ## appending to filename. The default output contains host names and ## their Internet addresses. Option can be one of the following: ## ## -t querytype ## lists all records of the specified type (see querytype below). ## ## -a lists aliases of hosts in the domain. synonym for -t CNAME. ## ## ***>> -d lists all records for the domain. synonym for -t ANY. ## ## -h lists CPU and operating system information for the domain. ## synonym for -t HINFO. ## ## -s lists well-known services of hosts in the domain. synonym for ## -t WKS. ## ## When output is directed to a file, hash marks are printed for every ## 50 records received from the server. ## AND: ## querytype=value ## type=value ## Change the type of information query to one of: ## ## A the host's Internet address. ## ## CNAME the canonical name for an alias. ## ## HINFO the host CPU and operating system type. ## ## MINFO the mailbox or mail list information. ## ## MX the mail exchanger. ## ## NS the name server for the named zone. ## ## PTR the host name if the query is an Internet address, ## otherwise the pointer to other information. ## ## SOA the domain's ``start-of-authority'' information. ## ## TXT the text information. ## ## UINFO the user information. ## ## WKS the supported well-known services. ## ## Other types (ANY, AXFR, MB, MD, MF, NULL) are described in the ## RFC-1035 document. ## (Default = A, abbreviations = q, ty) ############################################################################## ## FOR TESTING: # set -x nslookup > $OUTLIST << ENDofINPUT ls -t A nns.com exit ENDofINPUT ############################################################################## ## ONE COULD GENERATE JUST A LIST of ' A ' RECS and 'CNAME ' recs -- ## but the list would be missing the query-type indicators -- A & CNAME. ############################################################################## ## nslookup > $OUTLIST << ENDofINPUT ## ls -t A nns.com ## ls -t CNAME nns.com ## exit ## ENDofINPUT ############################################################################## ############################################################################## ## EXTRACT & SORT THE LIST. ############################################################################## ## THE EXTRACT eliminates records like ' TXT ' and ' NS ' and ' SOA ' recs. ## Examples: ## T141349-1 TXT "01:00:60:08:90:ad:70" ## eb NS netman4.nns.com ## nns.com. SOA netman1.nns.com netman.nns.com. (30347 900 900 604800 86400) ############################################################################## ## THE SORT sorts by 'record/query-type', then 'host-name'. ############################################################################## # egrep '^ ' $OUTLIST | egrep ' A |CNAME' | sort -k2b,2b -k1,1 | nl >> $OUTLIST2 ## FOR INITIAL DEVELOPMENT: # cat $OUTLIST | nl >> $OUTLIST2 # sort -k2b,2b -k1,1 $OUTLIST | nl >> $OUTLIST2 if test "$NUM_REPLY" = "NUM" then tail +5 $OUTLIST | egrep '^ ' | \ grep '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | \ awk '{printf ("%-15s %s \n", $2, $1)}' | \ sort -t. -k1n,1n -k2n,2n -k3n,3n -k4.1n,4.3n | nl >> $OUTLIST2 else tail +5 $OUTLIST | egrep '^ ' | \ grep '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | \ awk '{printf ("%-15s %s \n", $2, $1)}' | \ sort -t. -k1n,1n -k2n,2n -k3n,3n -k4.1n,4.3n >> $OUTLIST2 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. This list is sorted by the IP-address. This sort can help identify devices with duplicate IP addresses. And the sort reveals devices grouped essentially by subnets. (IP = Internet Protocol) The device-identifiers are frequently - 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: 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. ------------------------------------------------------------------------ PRINTERS: FOR PRINTERS, the device-identifier if often an NNS Telecomid (or an NNS-assigned 'plotter-queue' name). The IP address is actually the IP address of a 'print server' box/card to which the printer is attached. At NNS, a Telecom ID ###### is often used to make a printer 'queue' name for SGI workstations/hosts by prefixing a building name, like B600_P###### (for plot or Postscript or 'rich text' files) and B600_T###### (used for crude text printouts; automatically adds carriage-returns, and a final form feed, to files, which are assumed to be plain text). ------------------------------------------------------------------------ DEVICE DESCRIPTIONS/LOCATIONS: This list does NOT include *descriptions/locations* of each of these devices. If you need HOSTNAME 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 T05 'Distributed 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.) You may be able to find descriptions of SOME devices used on the SGI network if you search some SGI host and printer lists in the NNS-SGI print-plot utilities, 'prtplt_mgr' --- available via the 'PrtPlt_Mgr' drawer of the 'HandyTools' toolchest, of the main SGI 'Toolchest'. ------------------------------------------------------------------------ SOURCE OF THIS LIST: This list comes from the NNS DNS (Domain Name Service) via the 'nslookup' command -- applied to domain 'nns.com'. In particular, this list was generated by running the script $0 on host `hostname` . This query is available via a 'DNS Into' toolchest, which is available via the 'PrtPlt_Mgr' toolchest in the 'HandyTools' or 'Screentools' toolchests --- which are available via the SGI Toolchest. A similar inquiry, with a couple of sort options, 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, that inquiry is performed by running the script $FEDIR/scripts/sho_dns_hosts . ------------------------------------------------------------------------ UNDER THE COVERS: This list was assembled using the 'nslookup' command with the 'ls -t A' sub-command. Specifically, nslookup > $OUTLIST << ENDofINPUT ls -t A nns.com exit ENDofINPUT followed by an extract (filter) and a re-format and sort and numbering (with 'tail', grep', 'awk', 'sort', 'nl'). For details, see the script $0 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 ############################################################################## ## SHOW THE LIST (IN A SCROLLABLE TEXT WINDOW). ############################################################################## $FEDIR/scripts/shofil $OUTLIST2 # export SHOFILENAME="$OUTLIST2" # $FEDIR/tkGUIs/shofil.tk & ## FOR TESTING: # set -