#!/bin/ksh #"@(#)SysAdmin remote system gatherer script. Version 9.0" #"@(#)..by Bill Hassell, HP Atlanta Response Center" #"@(#)..email: blh@atl.hp.com" ########################################################################### # # Usage: # gatherer.sh [debug] # where: debug (if supplied exactly as "debug" will suppress # the file redicrection thus allowing -x traces) # # Test with: sh -x gatherer.sh debug 2>&1 | more # ########################################################################### GATHVER=9.0 # Version 9.0 Added chip type and PA-RISC version # Version 8.9 Fixed alignment of 1-liners (lost date field due to spelling) # Version 8.8 Added test for model(1) and use it for $MYCPU, and changed # the hardware string to use model(1) info for more details # Added: getconf for 11.x OpSystem bits (32 or 64) # Version 8.7 Changed the method for creating the local and remote hostname # file to prevent FQDN hostnames causing problems. Added a # .cronfiles check so cronlocator can update itself. # Version 8.6 Added tests for the DiagMnu2 line to prevent alignment errors # with long hostnames, long revcodes, etc. # Version 8.5 Added writable directory test for /usr/contrib/bin files # Version 8.4 Added debug option tobypass exec call for redirection. # Made a change to processor count for 10.20 funnies # Handle AUTOFS as a filesystem (from mnttab) # Version 8.3 Added socksified telnet/ftp installation # Version 8.2 Chgs to allow a missing /system directory (9.x) # Version 8.1 Fixed cronlocator.sh problem where it isn't always copied # to anon ftp..now get it directly from inforef's $HOME # Changed to ioscan -k for speed # Version 8.0 Added Y2K test and comments. Changed all grave accents # to $() for ksh/POSIX sh. Removed kernel what string # section. Fixed a missing nfs test in reading mnttab. # Added Y2K status on DiagMnu2 line at end of MYSTATUS # Change date %D to date %x (%D obsolete) # # Version 7.1 Changed QTYCPU tests to use $ARCH rather than $PROCESSOR # Version 7.0 Changed contrib programs from /usr/local/bin to contrib # Version 6.9 Changed FSTYPE code for better formatting # Version 6.8 Added installed filesystem types # Version 6.7 Added # to the list of acceptable comment chars for resolv.conf # Version 6.6 Added CPU count # Version 6.5 Added revolv.conf tests with email on relay # Version 6.4 Fixed up formatting for patches on pre-10.xx systems # Version 6.3 Added netstat -s -p udp for NFS health check # Version 6.2 Changed to $HOME/.cronfiles for all systems # Version 6.0 Major changes to the status/error logging # Version 5.3 Fixed $MYREV for internal versions (ie, 9.00b) # Version 5.2 Added bdf space check # Version 5.1 Added LVM info courtesy of Trond Hagan/HP Norway # Version 5.0 Fixup all pathnames to allow 10.xx or 9.xx w/out t-links # Version 4.7 Fixed CPU ID bogus warning and truncate long revisions # Version 4.6 Added last -R and sulog info # Version 4.5 Added a copy for /etc/resolv.conf # Version 4.4 Changed NonStd message for Status to Invalid # Version 4.3 Added a test for /bin/mail to see why it is not owned by daemon # Version 4.2 Changed the method to ID cronlocator script names # Version 4.1 Changed bootp report to add hdwe addresses # Version 4.0 Added 10.0 compatibility # ..grep for Status allows UPPERCASE or mixedCase # ..Several pathnames are set after rev is determined # ..SYSBACKUP test bypassed # ..patches and filesets different # ..awk changed (affects extract of sysmgr email addr) # ..switch from /tmp to /usr/tmp for all versions # ..change in tr not fixed; switched method to drop lead zeros # Version 3.8 Added System Manager and Status extraction # Version 3.7 Added 9.00 test for expand...expand -t is new to 9.0+ # Version 3.6 Changed the format of the DiagMenu line for new menu tool # Version 3.5 Added Mhz and memsize info using adb and memsize program # Version 3.4 Fixed invalid CPU number for more accrate test # Version 3.3 Removed suvi from all systems for security # Version 3.2 Added bdf check for full filesystems # Version 3.1 Add "uname" to System: line to find versions faster # Version 3.0 Create the diagmenu item for use with diagscript/pulldown # Version 2.9 Copy pwgrep, psgrep, rgrep to all systems # Version 2.8 Added bootpd test and syslog size warning # Version 2.7 Added lan# designation for strange lans # Version 2.6 Removed umdir stuff (no 300 client program!) # Version 2.5 Installed umdir client on all the diag machines (ONE SHOT) # Version 2.4 Commented out the JetDirect warnings for now # Version 2.3 Changed #!/bin/ksh to #!/bin/sh to drop .kshrc from running # Version 2.2 added JetDirect software test # Version 2.1 changed permissions on /etc/`hostname`.info # Version 2.0 changed router, nameserver to standard [ ] tags # added version info using a grep of the INDEX file # added kernel checks for hp-ux and SYSBCKUP # Version 1.9 changed WARNING,NOTE,INFO lines to avoid false warning messages # Version 1.8 changed Title line...pre 9.0 date doesn't have %e # added Series to make platform searches easier # Version 1.7 added /etc/exports listing # standardized WARNING, NOTE, INFO comments # Version 1.6 added test for no router and no printers; chg'd patch comments # moved LAN to follow peripherals/printers/disks # added bdf -i -t hfs to checklist and CDROM check # Version 1.5 added what /hp-ux and test for /SYSBCKUP # Version 1.4 added test for nameserver lookup and netmask # Version 1.3 added networking module # Version 1.2 added lpstat # Version 1.1 added checklist and cluster test # Version 1.0: original based on Rex's model # ########################################################################## # # Script to make a file called "/etc/SYSTEM_NAME.info" that includes # useful information such as filesets, patches, revision, etc. # # To make this worthwhile, sys managers are asked to include the following # lines in the /etc/motd file: # # Title: (name) # Location: (current physical location) # Purpose: (primary purpose(s) or usage) # SysMgr: (name phone email...) # AltMgr: (name phone email...) # CPU: (platform) # O.S. (revision) # Status: (classification: Production, Stable, Crash) # Memory: (megs) # # For example, # # Title: hpuercp # Location: Design Team Bay - J.8 # Purpose: 64000, Fax/9000, DeskScan, VideoLive, SoftPC, RTap, ME CAD # SysMgr: Roy Hancock 850-2108 (rgh@rc.atl) # AtlMgr: Rex Mayne 850-2064 (rex@rc.atl) # CPU: 9000/750 # O.S. 9.01 # Status: Stable # Memory: 64 M # # OTHER NOTES on /etc/motd: # Remove alternate character set pictures using the line drawing set. # It puts some strange chars on the screen for xterms and makes the # plain ASCII file reader harder to see. # # Keep the MOTD to the minimums. You can add patch lists automatically # by modifying /etc/profile to include an ls of /etc/filesets/PH* and # other ways to show the info at login. # # OTHER FILES: # /etc/peripherals should be kept up to date by the sysadmins. # This file can be cat'd in /etc/profile if desired, but it should # in the form: # # 8.0.0 7937A HPIB 600 meg drive (not loanable) # 8.0.1 7937A HPIB 600 meg drive (not loanable) # 8.1 Mux panel /dev/ttyd0p1: MultiTech M1432BA fax modem on x3113 # 8.2.3 C1511A HPIB DDS drive (not loanable) shared with rc # 8.2.4 7980A HPIB tape drive (not loanable) shared with rc # 8.3.0 C1707A HPIB CDROM drive (not loanable) # 8.3.1 C1707A HPIB CDROM drive (not loanable) # ###################################################################### # # Special install/update info...one shot or regular fixes/updates # to diag system software can be done here. The key is to use ftp # back to hpuerci to pull off needed files, or to manipulate local # files such /etc/profile or pushing /usr/contrib/bin files. # # Sample ftp sequence # # /usr/bin/ftp -v -n > $GATHFTP_LOG 2> $GATHFTP_ERR <> # quit # EOD # # ...followed by local customization # ########################################################################## # # Setup some global variables # START_DIR=$(pwd) MYNAME=$(hostname) MYSHORTNAME=$(echo $MYNAME | cut -f 1 -d .) MYUNAME=$(uname -a) MYMODEL=$(uname -m | cut -f 2 -d /) case $MYMODEL in 8??) ARCH="800" ;; 7??) ARCH="700" ;; 3?? | 4?? ) ARCH="300/400" ;; * ) ARCH="unknown model!" ;; esac # Setup globals...ensure that FQDN in hostname is simplified CIADDR=15.51.240.4 rm -f /etc/$MYNAME.info /etc/$MYSHORTNAME.info touch /etc/$MYSHORTNAME.info chmod 644 /etc/$MYSHORTNAME.info umask 022 PATH=/bin:/usr/bin:/usr/sbin # # find revision...code drops leading 0 for pre-10.0 # MYREV=$(uname -r | cut -f 2,3 -d .) if [ $MYREV -lt "10" ] then MYREV=$( echo $MYREV | cut -c 2- ) fi # # # -> -> -> -> -> -> -> -> -> -> -> <- <- <- <- <- <- <- <- <- <- <- <- <- <- # # Compatibility names for 10.0 support ... pathnames/files for rev compat. # ======================================================================== # # -> -> -> -> -> -> -> -> -> -> -> <- <- <- <- <- <- <- <- <- <- <- <- <- <- # # if [ "$MYREV" -lt "10.0" ] then TRUE=/bin/true FALSE=/bin/false TEST=/bin/test TENO=$FALSE BDF=/usr/bin/bdf NOTTENO=$TRUE HPUX=/hp-ux CHECKLIST=/etc/checklist SYSLOG=/usr/adm/syslog SULOG=/usr/adm/sulog LAST=/etc/last LASTB=/etc/lastb FTP=/usr/bin/ftp CUT=/usr/bin/cut GREP=/bin/grep MODEL=/bin/model TAIL=/bin/tail IFCONFIG=/etc/ifconfig USRTMP=/usr/tmp IOSCAN=/etc/ioscan Y2KOSCHECK=/usr/contrib/bin/y2koscheck else TRUE=/usr/bin/true FALSE=/usr/bin/false TEST=/usr/bin/test TENO=$TRUE BDF=/usr/bin/bdf NOTTENO=$FALSE HPUX=/stand/vmunix CHECKLIST=/etc/fstab SYSLOG=/var/adm/syslog/syslog.log SULOG=/var/adm/sulog LAST=/usr/bin/last LASTB=/usr/bin/lastb FTP=/usr/bin/ftp CUT=/usr/bin/cut GREP=/usr/bin/grep MODEL=/usr/bin/model TAIL=/usr/bin/tail IFCONFIG=/usr/sbin/ifconfig USRTMP=/var/tmp IOSCAN=/usr/sbin/ioscan Y2KOSCHECK=/usr/contrib/bin/y2koscheck fi # # Setup central location for logfile names: # GATH_ERR=/tmp/crongath.err GATHFTP_ERR=/tmp/cronftp.err GATHFTP_LOG=/tmp/cronftp.log # # exec to change stdout and stderr; set up ENV variables # if [ $# -gt 0 ] then if [ "$1" != "debug" ] then exec > /etc/$MYSHORTNAME.info 2> $GATH_ERR fi else exec > /etc/$MYSHORTNAME.info 2> $GATH_ERR fi ############################################################################# # Copy COMMON scripts and programs to all machines. Keep a setup of stuff # on hpuerci in the ftp/dist/setup directory. This section is reserved # for files copied common to all NARC machines. Test to see if # /usr/contrib/bin is writable though. # if ($TEST -w /usr/contrib/bin) then mkdir $USRTMP/tmp > /dev/null 2>&1 rm -r $USRTMP/tmp/* > /dev/null 2>&1 mkdir $USRTMP/gatherertmp > /dev/null 2>&1 echo "$(date): Start common script transfer..." > $GATHFTP_LOG echo "$(date): Start common script transfer..." > $GATHFTP_ERR $FTP -n -v >> $GATHFTP_LOG 2>> $GATHFTP_ERR < /dev/null fi # ############################################################################### # Now start the gathering process# # Set up the fancy boxes # TOP_BOT="+---------------------------------------------------------------------------+" LEFT="| --------> " RIGHT=" <------- |" # # Title the document for CSCinfo # echo "Title: $MYSHORTNAME as of $(date)" echo "HP Internal Use only" echo "CSCinfo locator system (blh@rc.atl.hp.com)" # ############################################################################### # # Y2K tests and documentation # # To avoid filling up log files with daily swinstalls of the y2koscheck # patch, we'll just copy the latest version with the setup files. # # For systems prior to 10.x, all are non-compliant. We won't test for # 300/400's at 9.10 since there is no equivalent y2koscheck program. # if [ $MYREV -lt 10.00 ] then echo echo "\t\t******************************************" echo "\t\t** Y2K O.S. status: NOT COMPLIANT **" echo "\t\t** HP-UX version $MYREV not patchable **" echo "\t\t******************************************" echo Y2KOK="-" else if [ -f $Y2KOSCHECK ] then /usr/contrib/bin/y2koscheck > /dev/null Y2KSTATUS=$? if [ $Y2KSTATUS -eq 0 ] then echo echo "\t\t\t***************************" echo "\t\t\t** Y2K O.S. status: OK **" echo "\t\t\t***************************" echo Y2KOK="+" else echo echo "\t\t****************************************" echo "\t\t** Y2K O.S. status: NOT COMPLIANT **" echo "\t\t** see patch exception report below **" echo "\t\t****************************************" echo Y2KOK="-" fi else echo echo "\t\t********************************************" echo "\t\t** Y2K O.S. status: NOT TESTED **" echo "\t\t** /usr/contrib/bin/y2koscheck not found **" echo "\t\t********************************************" echo Y2KOK="*" fi fi echo # # ####################### # # General information # # ####################### # # # find the rev of the PCO from the INDEX file in /system/UX-CORE/index # (for 8.0 and 9.0 systems) or from /system/UX_CORE/kernrel for 7.0. # # if [ "$MYREV" -lt "8.00" ] then MYPCO=$(head -1 /system/UX_CORE/kernrel) else if $TENO then MYPCO=$(/usr/sbin/swlist -l fileset OS-Core.UX-CORE | \ $GREP -F CORE|awk '{ printf $2 }') else MYPCO=$($GREP -F fv /system/UX-CORE/index | $CUT -f 2) fi fi if [ "$MYPCO" = "" ] then MYPCO=Unknown fi # # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # # Note: for 8, 9, 10 media, here are the revision locations (cat kernrel file) # # type of media location # ------------- ----------------------------------------- # 8.xx and 9.xx Media... # netdist tree /netdist/xxxxxx/UX-CORE/product/system/UX-CORE/kernrel # CDROM /xxxxx/system/UX-CORE/kernrel # installed /system/UX-CORE/kernrel # # 10.xx Media... # CDROM grep title /mount_point/catalog/INDEX | head -1 # # Check for OpSystem bit width (64 or 32) on 11.x and up if [ "$MYREV" -ge "11" ] then OSBITS="running in $(getconf KERNEL_BITS) bit mode" else OSBITS="" fi # # Figure out what the CPU clock speed is and set the executable type # 700's and 800's will have the PROCESSOR type 800 while ARCH will # have the true platform number (300, 700, 800) # if [ "$ARCH" = "700" -o "$ARCH" = "800" ] then PROCESSOR=800 MHZ=$(echo itick_per_tick/D | adb -k $HPUX /dev/kmem \ | $TAIL -1 | awk '{print $2/10000}') else PROCESSOR=300 MHZ="n/a" fi # # Find out the number of CPUs in the system # # Don't check for revs prior to 8.xx; multi-CPUs not supported before # 8.xx. 800's (like the 870) were supported in 8.xx but no multi-CPU # 700's. Multi-CPU 700's supported starting at 10.xx but J-series # could run on a 2-CPU system but only one CPU would be used. # # Even though ioscan exists on 700's at 9.xx, the processor count is # not available so always return 1 for 700's prior to 10.xx # # Method #1: QTYCPU=$(echo processor_count/D \ # | adb -k $HPUX /dev/kmem | $TAIL -1 | awk '{print $2}') # Method #2: QTYCPU=$(IOSCAN -k | $GREP -F processor | wc -l) # # Some recent versions of 10.20 don't return anything for processor_count # so check for nothing as a return value and use method 2 # if [ "$ARCH" -eq "300" ]; then QTYCPU=1 elif [ "$MYREV" -lt "8.00" ]; then QTYCPU=1 elif [ "$ARCH" -eq "800" ]; then QTYCPU=$(echo processor_count/D \ | adb -k $HPUX /dev/kmem | $TAIL -1 | awk '{print $2}') if [ "$QTYCPU" -eq "" ] then QTYCPU=$($IOSCAN -k | $GREP -F processor | wc -l) fi elif [ "$MYREV" -lt "10.00" ]; then QTYCPU=1 else QTYCPU=$(echo processor_count/D \ | adb -k $HPUX /dev/kmem | $TAIL -1 | awk '{print $2}') fi # Make plural for multi-procesors if [ $QTYCPU -gt 1 ]; then CPUWORD="s" else CPUWORD="" fi # # Get the actual CPU name from uname and add the MHz for 700's since these # are unique CPU models but not shown in uname -m. # # Use the model command (if available) for more details from later HP-UX's # MYCPU=$( uname -m | $CUT -f 2- -d / ) # Lots of things to do...older models and opsystems report 9000/### # while newer systems with the model command report 9000/###/XXXX # where XXXX is the family number versus product number (9000/871/D370) # # So, divide the CPU info into MYCPU (whatever follows 9000) and an # optional family member (MYFAMILY) and MYPROD for product. For several # flavors of 700's, the true model also included Mhz but uname didn't # always report anything except 715 as opposed to 715/60. if [ -f $MODEL ] then MYPRODFAM=$($MODEL | cut -f 2- -d / ) else MYPRODFAM=$MYCPU fi MYMODEL=$(echo $MYPRODFAM | $CUT -f 1 -d /) MYFAMILY=$(echo $MYPRODFAM | $CUT -f 2 -d /) if [ "$MYFAMILY" = "" ] then if [ "$ARCH" -lt "800" ] then MYCPU="$MYCPU/$MHZ" fi fi # Get the PA-RISC revision and family (if available) Note that # sched.models is constantly updated in the library patches and # may not contain a specific model unless a recent library # patch has been supplied. if [ $MYREV -ge 11.00 ] then SCHEDMODEL=/opt/langtools/lib/sched.models else SCHEDMODEL=/usr/lib/sched.models fi if [ -f $SCHEDMODEL ] then CHIPS=$(grep ^$MYMODEL $SCHEDMODEL | wc -l) case $CHIPS in 1) PAVER=$(grep ^$MYMODEL $SCHEDMODEL | awk '{print $2}') PARISC=$(grep ^$MYMODEL $SCHEDMODEL | awk '{print $3}') ;; *) PAVER="n/a" PARISC="n/a" ;; esac else PAVER="n/a" PARISC="n/a" fi # # And get the memory size from memsize (source is memsize.c from blh) # MYMEM=$(/usr/contrib/bin/memsize.$PROCESSOR | awk '{print $1/1024/1024}') # QUICK REFERENCE # --------------- echo "System uname: $MYUNAME" echo "Series: $ARCH at revision $MYREV, PCO level is $MYPCO $OSBITS" echo "Hardware: $MYPRODFAM @ $MHZ Mhz with $QTYCPU CPU$CPUWORD (Chip=$PARISC, Ver=$PAVER), $MYMEM Megs RAM" # # Check CPU ID. Allow 300/400 to have hex numbers # if [ $MYREV -ge "8.00" ] then if uname -i | $GREP -q [g-zA-Z] then echo echo "[-WARNING-] CPU ID number ($(uname -i)) is invalid!" fi fi # # /etc/motd # echo echo $TOP_BOT echo "$LEFT /etc/motd $RIGHT" echo $TOP_BOT echo if [ -f /etc/motd ] then if [ -s /etc/motd ] then cat /etc/motd else echo "[-WARNING-] /etc/motd file is zero length!" fi else echo "[-WARNING-] /etc/motd file is missing!" fi # # Check on Status: (allows UPPERCASE or MiXeDcAsE) # tmpMYSTATUS=$(awk ' /Status:/ { if (foo = match($0,".*Status:[ ]*")) { bar = substr($0, RLENGTH+1); gsub(" "," ",bar) len = index(bar," "); myusage = toupper(substr(bar, 0, len - 1 )); print myusage; } else printf "Unknown usage" } ' < /etc/motd ) # # Find the type in all caps first, then make it look pretty # for SYSTYPE in PRODUCTION STABLE TEST TRAINING CRASH BURN INSTALL UPDATE do if [ $(echo $tmpMYSTATUS | $GREP -Fic $SYSTYPE) = 1 ] then MYSTATUS=$(echo $SYSTYPE | \ awk '{ printf toupper(substr($1, 1, 1)) tolower(substr($1, 2)) }') # MYSTATUS=$SYSTYPE fi done # # set to Invalid if none of above # MYSTATUS=${MYSTATUS:=Invalid} if [ $MYSTATUS = Unknown ] then echo "[-WARNING-] /etc/motd file does not have a Status: line!" elif [ $MYSTATUS = Invalid ] then echo "[-WARNING-] /etc/motd file has a non-standard Status: entry!" fi # # if Combinations, use a standard value -- note: limited to 12 chars # Otherwise, the field size will mes up DiagMnu2 alignment later # if [ $MYSTATUS = Install -o $MYSTATUS = Update ] then MYSTATUS="Instl/Updt" fi if [ $MYSTATUS = Crash -o $MYSTATUS = Burn ] then MYSTATUS="Crash/Burn" fi ######################################################################## # # Y2K details # echo echo $TOP_BOT echo "$LEFT Y2K Information $RIGHT" echo $TOP_BOT echo if [ $MYREV -lt 10.00 ] then echo echo "$MYREV cannot be made Y2K compliant." echo else echo $Y2KOSCHECK -v echo fi ######################################################################## # # add IO info if ioscan is available # echo echo $TOP_BOT echo "$LEFT I/O Information $RIGHT" echo $TOP_BOT echo if [ -x $IOSCAN ] then $IOSCAN -kf else echo " This system does not have the $IOSCAN command." fi # # add the peripheral info if the file /etc/peripherals exists # echo echo $TOP_BOT echo "$LEFT Peripherals $RIGHT" echo $TOP_BOT echo if [ -f /etc/peripherals ] then cat /etc/peripherals else echo echo "[-WARNING-] The file /etc/peripherals does not exist for this system!" echo " Please contact the system administrator" fi # # Get a copy of /etc/fstab or checklist # echo echo $TOP_BOT echo "$LEFT Filesystems $RIGHT" echo $TOP_BOT echo # # How many filesystem types are mounted? (Translate FSTYPES to UPPERCASE) # FSTYPES=$($CUT -f 3 -d \ /etc/mnttab | grep -v ignore | sort \ | uniq | tr "\012" " " | tr "[:lower:]" "[:upper:]") echo "\t\t\t** Mounted filesystems: **" echo echo "\t\t\t\t$FSTYPES" echo echo # # checklist/fstab list # MAXLIST=10 echo "Contents of $CHECKLIST (first $MAXLIST lines):" echo "-------------------------------------------" if [ -f $CHECKLIST ] then if [ -s $CHECKLIST ] then head -${MAXLIST} $CHECKLIST LEN=$(wc -l $CHECKLIST | awk '{print $1}') if [ $LEN -gt $MAXLIST ] then echo echo " ($CHECKLIST is $LEN lines in length, only first $MAXLIST shown)" fi else echo "[-NOTE-] $CHECKLIST is zero-length...might be pre-10.xx diskless" fi else echo "[-WARNING-] $CHECKLIST does not exist!" fi echo # # show inode usage (-i) # show filesystem swapping (-b) # show different filesystems (not NFS) # # To avoid stale NFS problems, don't use bdf on NFS--use mounttab # for FS in $(echo $FSTYPES) do FSlowercase=$(echo $FS | tr "[:upper:]" "[:lower:]") if [ "$FS" = "NFS" ] then echo echo echo "NFS Filesystem(s):" echo "-------------------" cat /etc/mnttab | while read FSSOURCE FSLOCAL MOUNTEDAS OPTIONS do if [ $MOUNTEDAS = "nfs" ] then echo "$FSSOURCE mounted at $FSLOCAL" fi done elif [ "$FS" = "AUTOFS" ] then echo echo "AUTOFS Filesystem(s) from /etc/mnttab:" echo "--------------------------------------" echo grep autofs /etc/mnttab else INODES="-i" echo echo echo "$FS Filesystem(s):" echo "-------------------" echo $BDF $INODES -b -t $FSlowercase fi done # # LVM (if present) # if [ -r /etc/lvmtab ] then echo if $TENO then DIRPATH=/usr/sbin else DIRPATH=/etc fi # # Info # LVLNBOOT=$DIRPATH/lvlnboot VGDISPLAY=$DIRPATH/vgdisplay echo "+------------------+" echo "| BDRA definitions |" echo "+------------------+" echo echo "lvlnboot -v" $DIRPATH/lvlnboot -v 2>&1 echo echo "+--------------+" echo "| Volumegroups |" echo "+--------------+" echo echo "vgdisplay -v | grep -i name | grep -iv lv" $DIRPATH/vgdisplay -v | $GREP -i name | $GREP -iv lv echo echo "+-----------------+" echo "| Logical Volumes |" echo "+-----------------+" echo echo "vgdisplay -v | grep -i name | grep -iv pv" $DIRPATH/vgdisplay -v | $GREP -i name | $GREP -iv pv fi # # Test for CD-ROM's (not used...) # ##if [ $(/usr/bin/bdf -t cdfs | wc -l) -gt 1 ] ##then ##echo ##echo "CD-ROM list:" ##echo "------------" ##/usr/bin/bdf -t cdfs ##fi # # Test exported filesystems # if [ -s /etc/exports ] then echo echo "NFS exported filesystems:" echo "-------------------------" cat /etc/exports echo echo "NFS health check (netstat -p udp):" netstat -p udp else echo echo "[-NOTE-] No NFS exported filesystems" fi # # Test for clustered: if /etc/clusterconf exists, then we're clustered ####################################################################### if [ -f /etc/clusterconf ] then echo echo $TOP_BOT echo "$LEFT Clustered CPU $RIGHT" echo $TOP_BOT echo # # Give decoded info about this node; first determine if cnode or server # CLUSTERINFO=$(GREP -F $MYSHORTNAME /etc/clusterconf | $CUT -f 4 -d : | \ tr "[:upper:]" "[:lower:]" | $CUT -c 1) if [ "$CLUSTERINFO" = "c" ] then # # we're a cnode; find the server by looking for the entry which has the # letter r instead of the letter c (cnode). # SERVER=$(GREP -F ":r:" /etc/clusterconf | $CUT -f 3 -d :) CNODENUM=$(GREP -F $MYSHORTNAME /etc/clusterconf | $CUT -f 2 -d :) echo "$MYSHORTNAME is cnode #$CNODENUM booted from $SERVER." else # # Server # echo "$MYSHORTNAME is a cluster server for:" for MYCNODE in $(GREP -Fv $MYSHORTNAME /etc/clusterconf | \ $GREP -Fv clustercast | $CUT -f 3 -d :) do CNODENUM=$(GREP -F $MYCNODE /etc/clusterconf | $CUT -f 2 -d :) echo " $MYCNODE, node #$CNODENUM" done fi echo echo "/etc/clusterconf contents" echo "^^^^^^^^^^^^^^^^^^^^^^^^^" cat /etc/clusterconf echo fi # # # Check out the kernel # # test to see if the current kernel matches /hp-ux...a quick hack is # to use ipcs and compare the output. Different sysgens (kernel params # and drivers will affect the ipcs listing) # if [ $(ipcs | sed '/^[^msq]/d' | wc -l) -eq 0 ] then echo "[-WARNING-] The in-core kernel does NOT match the file: $HPUX" fi # # show the printers # echo echo $TOP_BOT echo "$LEFT Printers $RIGHT" echo $TOP_BOT echo /usr/bin/lpstat -v if [ $(/usr/bin/lpstat -v | wc -l) = "0" ] then echo "[-NOTE-] no printers installed on the computer." fi echo # # Get the network params and settings from lanscan, netstat and ifconfig # echo echo $TOP_BOT echo "$LEFT LAN Information $RIGHT" echo $TOP_BOT echo # # First, get the lanscan and netstat stuff into a file for easy grep'ing # /etc/lanscan > $USRTMP/tmp/lanscan$$ /usr/bin/netstat -i > $USRTMP/tmp/netstat$$ LANS=$(cat $USRTMP/tmp/lanscan$$|awk '{print $5}' |$GREP -F lan \ |wc -l|awk '{ printf $1 }') echo echo "Number of LAN cards installed: $LANS" echo "--------------------------------" for MYLAN in $(cat $USRTMP/tmp/lanscan$$ | awk '{print $5}' | $GREP -F lan) do echo echo "******************" echo "* Lan name: $MYLAN *" echo "******************" echo echo "[ ifconfig for $MYLAN ]" echo echo "$IFCONFIG $MYLAN" $IFCONFIG $MYLAN if [ $? -ne 0 ] then echo "WARNING: $MYLAN is not configured (ifconfig)" echo else NETMASK=$($IFCONFIG $MYLAN | $GREP -F netmask | awk '{print $4}' ) if [ "$NETMASK" != "fffff800" ] then echo "[-WARNING-] non-standard netmask: $NETMASK on $MYLAN" echo fi fi echo echo "[ lanscan for $MYLAN ]" head -2 $USRTMP/tmp/lanscan$$ $GREP -F $MYLAN $USRTMP/tmp/lanscan$$ echo echo '[ netstat -i for $MYLAN ]' head -1 $USRTMP/tmp/netstat$$ $GREP -F $MYLAN $USRTMP/tmp/netstat$$ done rm $USRTMP/tmp/lanscan$$ rm $USRTMP/tmp/netstat$$ echo echo "************************" echo "** General Networking **" echo "************************" echo echo "[ Routing info ]" echo echo "netstat -rn | grep (for default routing):" echo "-----------------------------------------" echo "Routing table" echo "Destination Gateway Flags Refs Use Interface" /usr/bin/netstat -rn | $GREP -F default if [ $? -ne 0 ] then echo "[-WARNING-] no router specified on this LAN" fi echo echo "[ nameserver ]" echo if [ -f /etc/resolv.conf ] then echo "Using nameserver (/etc/resolv.conf):" echo "------------------------------------" $GREP -Fv \; /etc/resolv.conf # # Test for more than 3 hosts and relay # ..skip comments (ie, ; or #) # ..look for nameserver and ignore leading spaces # ..extract the second field (the IP address) # ..count the lines (max = 3) or grep for relay # NS=$(grep -Ev "^\;|^#" /etc/resolv.conf|grep -F nameserver|awk '{ print $2}'|wc -l) if [ $NS -gt 3 ] then echo echo "[-NOTE-] /etc/resolv.conf contains more than 3 nameserver refs" fi if grep -Ev "^\;|^#" /etc/resolv.conf|grep -F nameserver \ | awk '{ print $2}' | grep 15\.255\.152\.2 then echo echo "[-WARNING-] /etc/resolv.conf has relay.hp.com listed" fi else if [ -f /etc/nsswitch.conf ] then echo "[-NOTE-] NameServer Switch is configured but no /etc/resolv.conf." echo else echo "[-NOTE-] $MYSHORTNAME is NOT using NAMESERVER, /etc/hosts is:" echo "--------------------------------------------------------" /bin/ls -l /etc/hosts echo echo "and /etc/hosts is $(cat /etc/hosts | wc -l) lines in length." fi fi # bootp daemon test # # Skip comments in bootptab and the 'test' entry # ps -ef|$GREP -F bootpd|$GREP -Fqv grep if [ $? = 0 ] then echo echo "BOOTPD (bootp daemon) is running on this node." $GREP -F "ha=" /etc/bootptab | $GREP -v "^#" | $GREP -Fv 000000 > $USRTMP/tmp/locboot$$ echo echo "BOOTPD: LinkLevel addresses currently managed:" for bootpMGR in $(cat $USRTMP/tmp/locboot$$) do echo "bootpMGR: $bootpMGR" done rm $USRTMP/tmp/locboot$$ fi # # syslog size test # if [ -f $SYSLOG ] then SYSLOGSZ=$(ll $SYSLOG | awk '{printf "%s",$5}') if [ $SYSLOGSZ -gt 1000000 ] then echo KB=$(expr $SYSLOGSZ / 1000) echo "[-WARNING-] $SYSLOG is getting large: $KB,000 Kbytes" echo fi else echo "[-WARNING-] $SYSLOG does NOT exist!" echo fi if $NOTTENO then # # list the patch filesets if there are any for 9x and earlier. 10.x is # listed in the swdepot filesets. # echo echo $TOP_BOT echo "$LEFT Patch Listing $RIGHT" echo $TOP_BOT echo # # set our current directory to /etc/filesets...then read # cd /system if [ -d PH* ] then echo "Patch\t Bytes\tPatch Description" echo "--------- ---------\t-----------------" for PATCH in $(ls -1d PH*) do DESC=$(grep "fd:" $PATCH/index | cut -d':' -f2) typeset -R SIZE=$(grep "fs:" $PATCH/index | cut -d':' -f2) echo "$PATCH: $SIZE $DESC " done else echo "/system/PH_#### indicates that no patches are installed" fi fi echo echo $TOP_BOT echo "$LEFT List FILESETS $RIGHT" echo $TOP_BOT if $NOTTENO then # get all the filesets in column format to keep the file from being too long ls -C /system else /usr/sbin/swlist -l product fi # # look in the list of misc dirs for other executables # echo echo $TOP_BOT echo "$LEFT Misc Software $RIGHT" echo $TOP_BOT MISC_DIRS="/usr/local/bin /usr/contrib/bin" for LOCAL_DIR in $MISC_DIRS do if [ -d $LOCAL_DIR ] then echo echo $LOCAL_DIR: echo ======================== cd $LOCAL_DIR # # This is a recursive list thru the subdirectories # ls -RC * fi done # # SECURITY CHECKS # --------------- # echo echo $TOP_BOT echo "$LEFT root logins $RIGHT" echo $TOP_BOT echo # # Two strangies here: can't use eval $LAST_CMD (no action occurs) and # last -R will produce no output, perhaps because of the exec of # this script? # Failed root logins (lastb) LAST_CMD="$LASTB -R -10 root" echo "$LAST_CMD (10 most recent FAILED root logins)" COUNT=$($LASTB -R -10 root | tee $USRTMP/tmp/LASTSU.$$ | wc -l) if [ $COUNT -eq 0 ] then echo echo "(none)" else cat $USRTMP/tmp/LASTSU.$$ fi # Successful root logins echo LAST_CMD="$LAST -R -10 root" echo "$LAST_CMD (10 most recent SUCCESSFUL root logins)" COUNT=$($LAST -R -10 root | tee $USRTMP/tmp/LASTSU.$$ | wc -l) if [ $COUNT -eq 0 ] then echo echo "(none)" else cat $USRTMP/tmp/LASTSU.$$ fi # su to root attempts echo SU_CMD="$GREP root $SULOG | sort -r | head -10" echo "$SU_CMD (10 most recent su/root actions, + = success)" COUNT=$($GREP root $SULOG \ | sort -r \ | head -10 \ | tee $USRTMP/tmp/LASTSU.$$ \ | wc -l) if [ $COUNT -eq 0 ] then echo echo "(none)" else cat $USRTMP/tmp/LASTSU.$$ fi echo # # SYSADMIN SPECIALTY INFORMATION # ------------------------------ # echo $TOP_BOT echo MYMODEL=$(uname -m|cut -d / -f 2) if [ -f /etc/clusterconf ] then if [ "$CLUSTERINFO" = "c" ] then CLUSTERED="(cluster cnode)" else CLUSTERED="(cluster server)" fi else CLUSTERED="(not clustered)" fi # # DiagMenu information line # # typeset -L9 MYFNAME="$MYSHORTNAME" typeset -L8 MYFCPU="$MYPRODFAM" typeset -L12 MYFPCO="$MYPCO" typeset -L12 MYFSTATUS="$MYSTATUS$Y2KOK" typeset -L8 MYFDATE=$(date '+%x') # expand changed option format to: expand -t at 9.0+ if [ $MYREV -le "9.00" ] then echo "DiagMnu2:\t$MYFNAME\t$MYFCPU\t$MYFPCO\t$MYFSTATUS\t$MYFDATE" \ | expand -10,20,29,42,55 else echo "DiagMnu2:\t$MYFNAME\t$MYFCPU\t$MYFPCO\t$MYFSTATUS\t$MYFDATE" \ | expand -t 10,20,29,42,55 fi # Add the system manager's email address as last line awk ' /SysMgr:/ { if (foo = match($0,"\(.*\)")) { printf "%s\n",substr($0,RSTART+1,RLENGTH-2) } else exit 1 } ' /dev/null # Bring over the latest version of cronlocator.sh # # The latest cronlocator.sh script is copied to the .cronfiles # 'standard' directory since each machine might have a different root # and cron directory. To fix this, $HOME/.cronfiles is now standard. # This doesn't solve the problem where a machine's cron job points to # another copy of cronlocator.sh...hummmm # # So verify that .cronfiles is a directory. If not, remove it and # create a symlink (if needed) to this system's standard location # for the cronlocator script. # It's an ordinary file - replace it if [ $(find $HOME/.cronfiles -type f | wc -l) -gt 0 ] then rm $HOME/.cronfiles mkdir $HOME/.cronfiles chmod 755 $HOME/.cronfiles fi # Now get a copy of cronlocator.sh echo "\n\n$(date): Copy latest cronlocator.sh into place..." >> $GATHFTP_LOG echo "\n\n$(date): Copy latest cronlocator.sh into place..." >> $GATHFTP_ERR $FTP -n -v >> $GATHFTP_LOG 2>> $GATHFTP_ERR < /dev/null 2>&1 ############################################################################### # # ###### # # # # # ##### #### # # # # # # # # # # # ##### # ## # # # # #### # # # ## # # ##### # # # # # # # # # # # # # # # # #### # #### # # ################################ # Special fixups as needed... ################################ # # # Done with fixups # cd $START_DIR # # Cleanup 'here' doc temp files of the form: $USRTMP/sh$$.* just in case # rm -f $USRTMP/sh$$.* exit 0