#!/bin/ksh
#"@(#)SysAdmin remote system gatherer script. Version 9.5"
#"@(#)..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.5
# Version 9.5 Changed search for model info to: /usr/sam/lib/mo/sched.models
# as it is part of SAM and does not rely on compilers
# Version 9.4 Changed swlist from fileset to bundle
# Version 9.3 Changed processor count to ioscan only (11.11 problems with
# adb). Changed Y2K tests to eliminate them for 11.01 and
# higher. (specifically 11.11). Fixed Mhz and RAM calcs to
# handle frational values (round off to int value).
# Version 9.2 Fixed (finally) pre-10.x scripts in /usr/contrib to force
# /bin/ksh. Checks for /usr/bin/*sh.
# Version 9.1 Changed memory size to adb command - memsize not needed
# 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.
#
##########################################################################
#
# 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
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
MAJORREV=$(echo $MYREV | cut -f 1 -d .)
#
#
# -> -> -> -> -> -> -> -> -> -> -> <- <- <- <- <- <- <- <- <- <- <- <- <- <-
#
# Compatibility names for pre-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
HEAD=/bin/head
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
HEAD=/usr/bin/head
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
#
###############################################################################
# Make some temporary directories
rm -rf $USRTMP/tmp/* > /dev/null 2>&1
mkdir $USRTMP/tmp > /dev/null 2>&1
mkdir $USRTMP/gatherertmp > /dev/null 2>&1
trap "rm -rf $USRTMP/tmp $USRTMP/gatherertmp" 0 1 2 3 15
# 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)"
#
###############################################################################
#
# 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 -a $MYREV -lt 11.01 ]
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
if [ $MYREV -lt 11.01 ] # starting with 11.11 don't use
then
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="*"
else
Y2KOK="+" # MYREV > 11.00 is Y2KOK
fi
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 int($2/10000+.5)}')
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)
#
# With 11.0 and higher, ioscan seems to be more stable than adb
#
if [ "$ARCH" -eq "300" ]; then
QTYCPU=1
elif [ "$MYREV" -lt "8.00" ]; then
QTYCPU=1
elif [ "$ARCH" -eq "800" ]; then # all 800's at 9.0+ have ioscan
QTYCPU=$($IOSCAN -k | $GREP -F processor | wc -l)
elif [ "$MYREV" -lt "10.00" ]; then # 700's prior to 10 = no multiCPU
QTYCPU=1
else
QTYCPU=$($IOSCAN -k | $GREP -F processor | wc -l)
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. However, SAM keeps it's own copy
# so we'll go with SAM's copy.
#
# History: 11.xx and after: /opt/langtools/lib/sched.models
# 10.xx and earlier: /usr/lib/sched.models
SCHEDMODEL=/usr/sam/lib/mo/sched.models
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)
#
# Get the memory size from adb to avoid requiring a separate program
if [ $MAJORREV -ge "11.0" ]
then
MYSYMBOL="phys_mem_pages"
else
MYSYMBOL="physmem"
fi
MYMEM=$(echo "${MYSYMBOL}/D" \
| adb $HPUX /dev/kmem \
| grep "${MYSYMBOL}: *." \
| awk '{print int($2*4/1024+.5)}')
# 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
########################################################################
#
# Y2K details - no Y2K if greater than 11.00
#
if [ $MYREV -lt 11.01 ]
then
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
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
#
# 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 BUNDLES $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 bundle # use bundle to keep the list short
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
echo $TOP_BOT
echo
#
# Finish up
#
rm -rf $USRTMP/tmp/* > /dev/null 2>&1
cd $START_DIR
#
# Cleanup 'here' doc temp files of the form: $USRTMP/sh$$.* just in case
#
rm -rf $USRTMP/sh$$.* > /dev/null 2>&1
exit 0