#!/bin/ksh ## ## SCRIPT NAME: prtplt_gen_iaw_hostslist_via_dns ## ## Where : in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################## ## PURPOSE: Uses 'nslookup' 'ls' command to generate a sorted list ## of NNS 'iaw' hosts --- ## ONLY THE HOSTNAME (not DNS type & IP address). ## ## NOTE: I.e. shows 'iaw' devices in nns.com domain. ## ## Can be used to periodically update the utility list in ## $FEDIR/lists/hosts_SGI_via_DNS.lis ## which can be used for ideasadm-cron-job & nethosts_tools queries. ############################################################################## ## CALLED BY: indirectly, by $FEDIR/scripts/runcmd_on_pingable_hosts_bygui ## ## Actually, because it takes quite a few seconds to run, this script is ## run periodically, to generate a list of hosts to use in scripts ## like 'runcmd_on_pingable_hosts_bygui'. ## ## See the comments in $FEDIR/lists/hosts_SGI_via_DNS.lis ## ##----- ## ## Can use './FIND_in_not_old ' to find other ## scripts in $FEDIR/scripts/ that call this 'gen-hostslist' script. ## ## Example: cd /apps/nns_com/fea/scripts ## ./FIND_in_not_old ############################################################################## ## BASIC PROCESSING: ## ## This script performs the following 'nslookup' command --- ## and sort|grep|awk. ## ## nslookup > /local/scratch/bmo01/temp.lis << ENDofINPUT ## ls -t A nns.com ## exit ## ENDofINPUT ## ## egrep '^ ' /local/scratch/bmo01/temp.lis | grep iaw | \ ## awk '{print $1 }' | sort >> /local/scratch/bmo01/temp.lis2 ## ############################################################################## ## MAINTENANCE HISTORY: ## Written by: B. Montandon 25Sep2000 Based on ## 'prtplt_sho_dns_hosts' ## in $FEDIR/scripts ## See also 'alarm_sethostlist' and ## 'runcmd_on_pingable_hosts_bygui'. ## Updated by: B. Montandon 26Sep2000 Move 'sort' after 'grep iaw' & 'awk', for ## better performance. Also, improve comment ## line info that is put in the list. ## Updated by: B. Montandon 2Mar2001 Add option to add line numbers to count ## number of booted-up SGI hosts (in DNS ## via DHCP) --- vi xconfirm prompt. ## Updated by: B. Montandon 12Mar2002 Chg "grep iaw" to "egrep 'iaw|ews'". ############################################################################## if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi FONT_XCONFIRM="-*-courier-bold-r-normal-*-14-*-*-*-*-*-*-*" # FONT_XCONFIRM="-adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-*" ############################################################################## ## PREP THE NAMES OF THE LIST FILE, $OUTLIST (AND AN INTERMEDIATE FILE). ############################################################################## . $FEDIR/scripts/set_localoutlist OUTLIST_UNSORTED=${OUTLIST}_unsorted ############################################################################## ## PROMPT USER WHETHER LINE NUMBERS ARE WANTED. ############################################################################## NUM_REPLY=`xconfirm -c -header "DNS Hosts List Utility" \ -B NONUM -b NUM \ -t "Do you want line numbers on the hostname lines?" \ -t "" \ -t " NUM or NONUM" \ -icon warning` ############################################################################## ## PREP THE TOP OF THE LIST (A HEADING). ############################################################################## echo "\ ################# `date '+%Y %b %d %a %T%p %Z'` ######################### # # LIST OF CURRENTLY BOOTED-UP 'iaw','ews' HOST MACHINES on the NNS NETWORK, # in the 'nns.com' domain. # # These 'iaw','ews' machines are currently known to DNS (Domain Name Service), # along with a 'dynamically-assigned' IP address, via DHCP. When the machines # booted up, DHCP (Dynamic Host Configuration Protocol) assigned the address. # # There may be other 'iaw','ews' machines that are not currently booted up. # # This list (without these '#' comment lines and without line numbering) # can be helpful to perform various queries on SGI hosts --- # for example, for Print/Plot Administration, to see which SGI hosts # have (or do not have) a particular lpr (or lp) print-queue definition. # # There is more info at the bottom of this list. # ############################################################################# " > $OUTLIST ############################################################################## ## 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) ############################################################################## ## INSTEAD OF ## ls -t ANY nns.com ## WE USE ## ls -t A nns.com ## SEE ' A ' and 'CNAME ' NOTES BELOW. ############################################################################## ############################################################################## ## 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 DNS 'iaw' hosts query will take about 10 secs to complete." \ -font $FONT_XCONFIRM \ > /dev/null & ## FOR TESTING: # set -x nslookup > $OUTLIST_UNSORTED << 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_UNSORTED << ENDofINPUT ## ls -t A nns.com ## ls -t CNAME nns.com ## exit ## ENDofINPUT ############################################################################## ############################################################################## ## EXTRACT & SORT THE 'iaw','ews' LIST. ############################################################################## ## If 'ls -t ANY nns.com' were used above instead of 'ls -t A nns.com': ## ## An egrep ' A |CNAME' extract (examples below) 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 -k2b,2b -k1,1' sorts by 'record/query-type', then 'host-name'. ############################################################################## ## EXAMPLE EXTRACTS: ## ## grep '^ ' $OUTLIST_UNSORTED | egrep ' A |CNAME' | \ ## grep iaw | awk '{print $1 }' | sort >> $OUTLIST ############################################################################## ## grep '^ ' $OUTLIST_UNSORTED | egrep ' A |CNAME' | \ ## grep iaw | awk '{print $1 }' | sort >> $OUTLIST ############################################################################## # CMD="grep '^ ' $OUTLIST_UNSORTED | grep iaw | awk '{print \$1 }' | sort" CMD="grep '^ ' $OUTLIST_UNSORTED | egrep 'iaw| ews' | \ awk '{print \$1 }' | sort" NLCMD="" if test "$NUM_REPLY" = "NUM" then NLCMD=" | nl" fi eval "$CMD $NLCMD" >> $OUTLIST # rm $OUTLIST ############################################################################## ## ADD A TRAILER TO THE REPORT. ############################################################################## echo " ############################################################################## # HOW THIS 'iaw','ews' HOSTNAMES LIST WAS GENERATED: # # This list was generated by the following 'nslookup' command --- # and a grep | awk | sort pipe. # # nslookup > $OUTLIST_UNSORTED << ENDofINPUT # ls -t A nns.com # exit # ENDofINPUT # # "$CMD $NLCMD" >> $OUTLIST # ############################################################################## # # The script $0 # # performed the above commands. # # The 'prtplt_gen_iaw_hostslist_via_dns' script has been implemented # as an option in the 'prtplt_mgr' command/toolchest --- # # option \"NNS DSN 'iaw','ews' 'nns.com' names\", in the # \"Show_many_corporate_QUEUE_IDs\" popup/cascading menu. # ############################################################################## " >> $OUTLIST ## FOR TESTING: # set - ############################################################################## ## SHOW THE LIST (IN A SCROLLABLE TEXT WINDOW). ############################################################################## $FEDIR/scripts/shofil $OUTLIST # export SHOFILENAME="$OUTLIST" # $FEDIR/tkGUIs/shofil.tk &