#! /bin/ksh # # Report HP-UX machine configuration. # # (Use ksh as /bin/sh on HP-UX 9.X doesn't pass arguments to functions # as one might expect. /bin/posix/sh at 9.X and /usr/bin/sh at 10.X # should be OK as well.) # # This code is not copyright; it is placed in the public domain. # # Usage: machine_report [-v] # # Options: # # -v Report verbose information. (e.g. lvdisplay -v ...) # This PATH should be OK for 9.X and 10.X PATH=/bin:/usr/bin:/etc:/usr/sbin:/sbin USAGE="`basename $0 [-v]" for arg do case "$arg" in -v) verbose="-v" ;; *) echo $USAGE 1>&2 exit 1 esac done exec 2>&1 # Use stdout to keep the line count right MACHINE="`uname -m`" OS=`uname -r` case "$MACHINE" in 9000/8*) LVM=true # we don't run any non-LVM 800s ;; esac case "$OS" in *.10.*) LVM=true # all our 10.X machines use LVM ;; esac PAGELEN=56 # Default print lines when using pr(1) CURLINES=0 # # All items should start on a new page if they won't fit entirely # on the current page. # # Co-operate with pr when producing formfeeds; the last line of # a page is a special case since pr will do the formfeed for us. # # Fold everything to 80 characters. The width of the report # could be made an option. # startpage() { if [ $CURLINES -eq $PAGELEN -o $CURLINES -eq 0 ] then CURLINES=`expr $LINES % $PAGELEN` else TOTLINES=`expr $CURLINES + $LINES + 1` if [ $TOTLINES -gt $PAGELEN ] then echo "\014\c" # Formfeed CURLINES=`expr $LINES % $PAGELEN` else echo "" CURLINES=`expr $CURLINES + $LINES + 1` fi fi } report_cmd() { echo "=== $* ===" > /tmp/report$$page "$@" | fold >> /tmp/report$$page 2>&1 LINES=`wc -l < /tmp/report$$page` startpage cat /tmp/report$$page } report_file() { if [ -f $1 ] then LINES=`fold $1 | wc -l` LINES=`expr $LINES + 1` startpage echo "=== $* ===" cat $1 else echo "$1: no such file or directory" | report_stdin fi } report_stdin() { read title echo "=== $title ===" > /tmp/report$$page fold >> /tmp/report$$page LINES=`wc -l < /tmp/report$$page` startpage cat /tmp/report$$page } report_first_file() { FOUND="" for f in "$@" do if [ -f $f ] then report_file $f FOUND=true break fi done if [ -z "$FOUND" ] then echo "unable to find any of $*" | report_stdin fi } # # MAIN # { report_cmd uname -a # # /etc/fstab (HP-UX 10.X, BSD, ...) # /etc/checklist (HP-UX 9.X, SysV, ...) # report_first_file /etc/fstab /etc/checklist # # Sample bdf # report_cmd bdf # # Filesystem Tuning # (REVISIT for jfs!) # mount -p | awk '/hfs/ { sub(/dsk/, "rdsk", $1) sub(/lvol/, "rlvol", $1) print $1 }' | while read d do case "$verbose" in -v) report_cmd dumpfs $d ;; *) dumpfs $d | (echo "dumpfs $d"; egrep 'maxcontig|minfree') | report_stdin esac done # # Installed software and patches # case "$OS" in *.09.*) report_cmd ls -C /system ;; *) # Assume HP-UX 10.X # REVISIT check that this lists patches (we don't # have any installed yet). report_cmd swlist -l fileset esac # # kernel configuration file # (Alternative: read from /hp-ux via the command SAM uses.) # report_first_file /stand/system /etc/conf/gen/S800 /etc/conf/dfile # # Ioscan # # On 800s at 9.X and all machines at 10.X report both the hardware # and the kernel configuration via the '-k' option. # # On the 700s at 9.X the undocumented -b option provides the device # types, which on 800s at 9.X must be dug out with diskinfo. On # At 10.X both 700s and 800s display the device types when using # ioscan -f, so the whole fuss is over ... # case "$OS" in *.09.*) case "$MACHINE" in 9000/7*) report_cmd ioscan -fb ;; 9000/8*) report_cmd ioscan -f report_cmd ioscan -fk ;; esac ;; *) # Assume HP-UX 10.X or later, and that they don't change it again. report_cmd ioscan -f report_cmd ioscan -fk esac # # Report the disk types on 800s at 9.X, since ioscan doesn't display this. # # Attempt to ignore NFS mounts. # case "$OS" in ?.09.*) case "$MACHINE" in 9000/8*) ioscan -f | grep disc3 | while read disk lu hwpath rest do device=/dev/rdsk/c${lu}d0s2 if [ -c $device ] then report_cmd diskinfo $device else echo "disk $hwpath: missing or non-character device file $device" | report_stdin fi done ;; esac ;; esac # # LAN information # (ifconfig -a would be nice) # report_cmd lanscan lanscan | sed '1,2d' | while read lan do set -- $lan report_cmd ifconfig $5 done # # Urk. NIS, just in case. # NIS_DOMAIN=`domainname` case "$NIS_DOMAIN" in "") echo "NIS appears not to be configured (good!)." | report_stdin ;; *) report_cmd domainname report_cmd ypwhich report_cmd grep '+' /etc/passwd report_cmd grep '+' /etc/group report_file /etc/netgroups esac # # lp spooler information # (This doesn't include the interface scripts, but does indicate # which printers are setup on each machine, and whether they are # local or remote.) # report_cmd lpstat -s # # LVM information # # This is *very* verbose. Keep it at the end of the report. # Much of this information is only useful in the case of severe # LVM trauma. # if [ -n "$LVM" ] then report_cmd vgdisplay -v report_cmd lvlnboot -v report_cmd strings /etc/lvmtab vgdisplay -v | sed -n '/PV Name/s/.* //p' | while read pv_name do report_cmd pvdisplay $verbose $pv_name done # A single lvdisplay command could be used, but this gives a title # for each LV. vgdisplay -v | sed -n '/LV Name/s/.* //p' | while read lv_name do report_cmd lvdisplay $verbose $lv_name done fi } | pr -h`hostname`