#!/bin/ksh ############################################## # sysdoc: System documentor # Author: Doug O'Leary # Created: 01/14/00 - 01/18/00 # Updated: # 01/31/00: UPdated logic to ID printer IP # addresses & NIC interface device # drivers. Doug O'Leary # 02/02/00: Updated the size of the printfs in # general_info. Doug O'Leary # 11/13/00: # * Merged Malcom Marshall's code into # general_info function. # * Added function to generate and print # a new system file from the kernel. # Doug O'Leary # 11/16/00: # * Rewrote kernel parameter section # based on input from Tom Bonnevier. # Uses kmtune/kmsystem functionality # vs deprecated sysdef. # * Fixed a formatting bug in bdf_info; # problem with bdf output that covered # multiple lines. Doug O'Leary # ############################################## ############################################## # Functions ############################################## ######## Prints header msg ################# print_hdr() { ######## Create local variables ########### typeset l_max; typeset len; typeset num; typeset x l_max=45 #### Print centered msg #################### print "#############################################" if [ ${#1} -lt ${l_max} ] then len=${#1} num=$((l_max-len)) num=$((num/2)) x=0; while [ $x -lt ${num} ] do echo " \c" x=$((x+1)) done fi print "$1" print "#############################################" print } ######## Disk H/W information ############## get_disk_info() { ######## Create local variables ########### typeset md; typeset mh; typeset mdsc typeset class; typeset i; typeset hw; typeset mv typeset dr; typeset state; typeset type typeset desc; typeset tmp; typeset disk ######## Print header message ########### print_hdr "Disk Hardware Information" md=""; mh=""; mdsc=""; Tmp=/tmp/${0}.$$ ### Send all output to the ${Tmp} file. { # For each disk as reported by ioscan for disk in $(ioscan -funC disk | grep -i dsk | awk '{print $1}') do # read class, instance, h/w, driver, state, type, & description ioscan -funC disk ${disk}| grep '^disk' | \ read class i hw dr state type desc # Check/set maximum length as needed. [ ${#hw} -gt ${#mh} ] && mh=${hw} disk=${disk##*/} [ ${#disk} -gt ${#md} ] && md=${disk} [ ${#desc} -gt ${#mdsc} ] && mdsc="${desc}" # Check for cd-rom; set vg/size. echo "${desc}" | grep -i "cd-rom" > /dev/null 2>&1 if [ $? = 0 ] then size="N/A" vg="N/A" else # If the disk doesn't belong to a volume group... vg=$(pvdisplay /dev/dsk/${disk} 2>/dev/null | \ awk '/VG Name/ {print $3}') if [ -z "${vg}" ] then size="Unknown" vg="N/A" else # Otherwise, get size information. vg=${vg##*/} [ ${#vg} -gt ${#mv} ] && mv=${vg} pe=$(pvdisplay /dev/dsk/${disk} | awk '/PE Size/ {print $4}') size=$(pvdisplay /dev/dsk/${disk} | awk '/Total PE/ {print $3}') size=$((size*pe)) fi fi print "${disk} ${hw} ${vg} ${size} ${desc}" done } > ${Tmp} ### End send all output to the ${Tmp} file. # print column headers with appropriate widths. printf "%-${#md}s %-${#mh}s %-${#mv}s %8s %-${#mdsc}s\n" \ "Disk" "H/W Path" "VG" "Size" "Description" # print ${Tmp} sorted by disk. sort -k1 ${Tmp} | while read disk hw size vg desc do printf "%-${#md}s %-${#mh}s %-${#mv}s %8s %-${#mdsc}s\n" \ ${disk} ${hw} ${size} ${vg} "${desc}" done print # Cleanup. rm ${Tmp} } ####### IDs unallocated disks ############### id_unalloc_disks() { ### Create local variables. typeset disk; typeset disks; typeset i; typeset hw; typeset driver; typeset state; typeset type; typeset desc ### Print header information. print_hdr "Unallocated disks" ### For each disk as reported by ioscan, read class, instance, ### h/w, driver, state, type, and description. ioscan -funC disk | grep '^disk' | \ while read class i hw driver state type desc do ### skip cd-roms. echo ${desc} | grep -i "cd-rom" > /dev/null 2>&1 if [ $? != 0 ] then ### Get the disk device dirver & run pvdisplay against it. disk=$(ioscan -funH ${hw} | grep dsk | awk '{print $1}') pvdisplay ${disk} > /dev/null 2>&1 ### If it returns an error, it's not part of a vg & isn't allocated. if [ $? != 0 ] then set -A disks ${disks[*]} ${disk} fi fi done if [ -n "${disks[*]}" ] then for disk in ${disks[*]} do printf "\t%s\n" ${disk} done fi print } ###### IDs altnerate links ################# id_alt_links() { ### Create local variables. typeset pri; typeset alt; typeset alternate; typeset disk typeset disks; typeset vg; typeset pv; typeset name; typeset dsk; typeset link; typeset Tmp typeset mvg; typeset mpri; typeset malt ### Initialize variables and print header information. mvg=""; mpri=""; malt="" Tmp=/tmp/${0}.$$ print_hdr "Alternate Links" ### Send all output to ${Tmp} { ### Set the disks[*] array. set -A disks $(ioscan -funC disk | grep -i dsk | awk '{print $1}' | sort) ### Iterate through each disk for disk in ${disks[*]} do ### Reset primary/alternate pri=""; alt="" ### Get the volume group vg=$(pvdisplay ${disk} 2>/dev/null | awk '/VG Name/ {print $3}') if [ -n "${vg}" ] then ### If the disk belongs to a vg, check vg size. vg=${vg##*/} [ ${#vg} -gt ${#mvg} ] && mvg=${vg} ### pvdisplay the disk; checking for "alternate" pvdisplay ${disk} | grep -i "pv name" | \ while read pv name dsk alternate link do ### If "alternate, not found, the disk is primary if [ -z "${alternate}" ] then pri=${dsk##*/} [ ${#pri} -gt ${#mpri} ] && mpri=${pri} else ### Otherwise, it's the alternate alt=${dsk##*/} [ ${#alt} -gt ${#malt} ] && malt=${alt} fi done if [ ${pri} = ${disk##*/} ] then printf "%s %s %s\n" ${vg} ${pri} ${alt} fi else ### If the disk isn't part of a vg printf "%s %s %s\n" ${vg:=N/A} ${disk##*/} ${alt:=N/A} fi done } > ${Tmp} ### End redirected output pri="Primary" alt="Alternate" [ ${#pri} -gt ${#mpri} ] && mpri=${pri} [ ${#alt} -gt ${#malt} ] && malt=${alt} ### print column headings using correct width printf "%-${#mvg}s %-${#mpri}s %-${#malt}s\n" "VG" "Primary" "Alternate" ### Print ${Tmp} sorting on disk sort -k2 ${Tmp} | while read vg pri alt do printf "%-${#mvg}s %-${#mpri}s %-${#malt}s\n" ${vg} ${pri} ${alt:=N/A} done print ### Cleanup rm ${Tmp} } ######### Shows pri/alt boot paths ######### show_boot() { ### Set local variables typeset disk; typeset pri; typeset garb1; typeset garb2 typeset hw; typeset dsk; typeset mpri; typeset mdisk; typeset mhw; typeset Tmp ### Print header information print_hdr "Boot H/W Paths" Tmp=/tmp/${0}.$$ ### Redirect all output to ${Tmp} { ### Get the current boot paths setboot | grep -i bootpath | while read pri garb1 garb2 hw do ### Get the device driver for the h/w path. disk=$(ioscan -funH ${hw} | grep dsk | awk '{print $1}') disk=${disk##*/} ### If it doesn't exist, print N/A if [ -z "${disk}" ] then printf "%s %s %s\n" "N/A" "N/A" "N/A" else ### Otherwise, print appropriate information. printf "%s %s %s\n" ${pri} ${disk##*/} ${hw} fi [ ${#pri} -gt ${#mpri} ] && mpri=${pri} [ ${#disk} -gt ${#mdisk} ] && mdisk=${disk} [ ${#hw} -gt ${#mhw} ] && mhw=${hw} done } > ${Tmp} ### End redirected output ### Print header information with correct column sizes. printf "%-${#mpri}s %-${#mdisk}s %-${#mhw}s\n" "Pri|Alt" "Disk" "H/W Path" ### Print boot information cat ${Tmp} | while read primary disk hw do printf "%-${#mpri}s %-${#mdisk}s %-${#mhw}s\n" ${primary} ${disk} ${hw} done print ### Cleanup rm ${Tmp} } ####### Displays the current boot defs ##### lvlnboot_info() { ### Print hdr info print_hdr "Boot Definitions" ### Execute command; eliminate annoying "skippy" messages. lvlnboot -v | grep -v skip print } ###### Formats & prints fstab ############## fstab_info() { ### Set local variables # dev dir type options bkup_freq pass_num comment typeset mdev; typeset mdir; typeset mt; typeset mo; typeset mbf; typeset mpn; typeset mc; typeset dev; typeset dir; typeset type; typeset opt; typeset bf; typeset pn; typeset comment typeset Tmp; typeset file ### Print header information & initialize vars. print_hdr "Active fstab partitions" file=/etc/fstab; mdev=""; mdir=""; mt=""; mo=""; mbf=""; mpn=""; mc="" Tmp=/tmp/${0}.$$ ### Send all output to ${Tmp} { ### Read fstab, eliminate commented filesystems grep -v '^#' ${file} | while read dev dir type opt bf pn comment do ### Set biggest sizes. [ ${#dev} -gt ${#mdev} ] && mdev=${dev} [ ${#dir} -gt ${#mdir} ] && mdir=${dir} [ ${#type} -gt ${#mt} ] && mt=${type} [ ${#opt} -gt ${#mo} ] && mo=${opt} [ ${#bf} -gt ${#mbf} ] && mbf=${bf} [ ${#pn} -gt ${#mpn} ] && mpn=${pn} [ ${#comment} -gt ${#mc} ] && mc=${comment} print "${dev} ${dir} ${type} ${opt} ${bf} ${pn} ${comment}" done } > ${Tmp} ### End redirected output bf="BF" pn="PN" comment="Comment" [ ${#bf} -gt ${#mbf} ] && mbf=${bf} [ ${#pn} -gt ${#mpn} ] && mpn=${pn} [ ${#comment} -gt ${#mc} ] && mc=${comment} ### Print column headings with appropriate sizes. printf "%-${#mdev}s %-${#mdir}s %-${#mt}s %-${#mo}s \ %-${#mbf}s %-${#mpn}s %-${#mc}s\n" "Device" "Dir" \ "Type" "Options" "BF" "PN" "Comment" ### Print ${Tmp} sorted by device. sort -k1 ${Tmp} | while read dev dir type opt bf pn comment do printf "%-${#mdev}s %-${#mdir}s %-${#mt}s %-${#mo}s \ %-${#mbf}s %-${#mpn}s %-${#mc}s\n" ${dev} ${dir} \ ${type} ${opt} ${bf} ${pn} "${comment}" done print ### Cleanup rm ${Tmp} } ######## Reports on swap space alloc ######## show_swap() { ## Print header information. print_hdr "Swap space information" ## Execute swapinfo -tm swapinfo -tm print } ######## formats and prints bdf ############ bdf_info() { ### Localize variables typeset Tmp; typeset fs; typeset kb; typeset used; typeset avail; typeset perc; typeset mp typeset mfs; typeset mkb; typeset mused; typeset mavail; typeset mperc; typeset mpc; typeset nf; typeset line typeset lines; typeset flag ### Print header and initialize vars print_hdr "Current Filesystem Usage" mfs=""; mkb=""; mused=""; mavail=""; mperc=""; mpc="" flag=1; Tmp=/tmp/${0}.$$ ### Redirect all output to ${Tmp} { # bdf | grep dev | while read fs kb used avail perc mp bdf | tail +2 | while [ ${flag} -eq 1 ] do read line if [ $? = 0 ] then nf=$(echo "${line}" | awk '{print NF}') if [ ${nf} -eq 1 ] then fs=${line} read line line="${fs} ${line}" fi set -A lines ${line} fs=${lines[0]} kb=${lines[1]} used=${lines[2]} avail=${lines[3]} perc=${lines[4]} mp=${lines[5]} [ ${#fs} -gt ${#mfs} ] && mfs=${fs} [ ${#kb} -gt ${#mkb} ] && mkb=${kb} [ ${#used} -gt ${#mused} ] && mused=${used} [ ${#avail} -gt ${#mavail} ] && mavail=${avail} [ ${#perc} -gt ${#mperc} ] && mperc=${perc} [ ${#mp} -gt ${#mpc} ] && mpc=${mp} print "${fs} ${kb} ${used} ${avail} ${perc} ${mp}" else flag=0 fi done } > ${Tmp} ### End redirected output ### Ensure biggest sizes are correct. fs="Filesystem" kb="Kbytes" used="Used" avail="Avail" perc="Used" mp="Mount Point" [ ${#fs} -gt ${#mfs} ] && mfs=${fs} [ ${#kb} -gt ${#mkb} ] && mkb=${kb} [ ${#used} -gt ${#mused} ] && mused=${used} [ ${#avail} -gt ${#mavail} ] && mavail=${avail} [ ${#perc} -gt ${#mperc} ] && mperc=${perc} [ ${#mp} -gt ${#mpc} ] && mpc=${mp} ### Print column headings with appropriate sizes. printf "%-${#mfs}s %${#mkb}s %${#mused}s %${#mavail}s %${#mperc}s %-${#mpc}s\n" "Filesystem" "Kbytes" "Used" "Avail" "Used" "Mount Point" ### Print ${Tmp} sorted by device. sort -k1 ${Tmp} | while read fs kb used avail perc mp do printf "%-${#mfs}s %${#mkb}s %${#mused}s %${#mavail}s %${#mperc}s %-${#mpc}s\n" ${fs} ${kb} ${used} ${avail} "${perc}" ${mp} done ### Cleanup rm ${Tmp} } ######## Get Volume Group Info ############# get_vg_info() { ### Localize vars typeset vg; typeset total; typeset unalloc; typeset free typeset pe ### Print header print_hdr "Summary Volume Group Information" ### Iterate through each volume group. for vg in $(vgdisplay | awk '/VG Name/ {print $3}' | sort) do vg_sum ${vg##*/} # Volume group summary vg_disks ${vg##*/} # Volume group disks vg_lvs ${vg##*/} # Volume group logical volumes done } ######## Print VG Summary info ############## vg_sum() { ### Localize variables typeset vg typeset pe typeset total typeset free ### Obtain vg size, and free space vg=${1} pe=$(vgdisplay ${vg} | awk '/PE Size/ {print $4}') total=$(vgdisplay ${vg} | awk '/Total PE/ {print $3}') free=$(vgdisplay ${vg} | awk '/Free PE/ {print $3}') total=$((total*pe)) free=$((free*pe)) ### Print information print "#############################################" printf "VG: %6s\n" ${vg} printf "Allocated: %6s Megs\n" ${total} printf "Free: %6s Megs\n" ${free} } ###### Print VG disk information ########### vg_disks() { ### Localize variables typeset vg typeset disk typeset disks typeset x vg=${1} x=0 print "=============================================" printf "\tDisks\n\t" ### print each disk that belongs to the VG, four per line for disk in $(vgdisplay -v ${vg} | awk '/PV Name/ {print $3}') do # set -A disks ${disks[*]} ${disk} printf "\t%s" ${disk##*/} x=$((x+1)) if [ ${x} -eq 4 ] then printf "\n\t" x=0; fi done printf "\n" } ###### Get LV info by VG ################### vg_lvs() { ### Localize variables typeset vg; typeset lv; typeset mp; typeset size typeset mirror; typeset stripe; typeset Tmp; typeset mlv; typeset msize; typeset mm; typeset ms typeset fs; typeset mfs; typeset swap ### Initialize variables mlv=""; msize=""; mm="Mir"; ms="Stri"; mfs="" Tmp=/tmp/${0}.$$ vg=${1} print "=============================================" printf "\tLogical Volumes\n\n" ### Redirect all output to ${Tmp} { ### For each lv in the vg for lv in $(vgdisplay -v ${vg} | awk '/LV Name/ {print $3}') do ### Is it mirrored? mirror=$(lvdisplay ${lv} | awk '/Mirror copies/ {print $3}') if [ ${mirror} -eq 0 ] then mirror='N' else mirror='Y' fi ### What's the size size=$(lvdisplay ${lv} | awk '/LV Size/ {print $4}') ### Is it striped? stripe=$(lvdisplay ${lv} | awk '/Stripes/ {print $2}') if [ ${stripe} -eq 0 ] then stripe='N' else stripe='Y' fi ### Is the LV a mount point? fs=$(mount | grep "${lv} " | awk '{print $1}') if [ -z "${fs}" ] then ### If not, is it a swap device? swapinfo -tm | grep "${lv}" > /dev/null 2>&1 if [ $? -eq 0 ] then fs="Swap" else ### If not, dunno what it is. fs="Unknown" fi fi ### Update max sizes as appropriate [ ${#lv} -gt ${#mlv} ] && mlv=${lv} [ ${#size} -gt ${#msize} ] && msize=${size} [ ${#fs} -gt ${#mfs} ] && mfs=${fs} [ ${#mirror} -gt ${#mm} ] && mm=${mirror} [ ${#stripe} -gt ${#ms} ] && ms=${stripe} printf "%s %s %s %s %s\n" ${lv} ${size} ${fs} ${mirror} ${stripe} done } > ${Tmp} ### End redirected output ### Print header information printf "%-${#mlv}s %-${#msize}s %-${#mfs}s %-${#mm}s %-${#ms}s\n" \ "LV" "Size" "Use" "Mirror" "Stripe" ### Print ${Tmp} sorted by logical volume. sort -k1 ${Tmp} | while read lv size fs mirror stripe do printf "%-${#mlv}s %${#msize}s %-${#mfs}s %${#mm}s %${#ms}s\n" \ ${lv} ${size} ${fs} ${mirror} ${stripe} done print ### Cleanup. rm ${Tmp} } response() { read -p title read -p resp eval $(echo $resp | sed "s/: */=/") } sysinfo() { ### Sysinfo function taken, with only limited editions ### from Malcolm Marshall's sysinfo script. Uname="/sbin/uname" # script is HP-UX specific; check OK to run & determine release level if [ `${Uname} -s` != "HP-UX" ]; then echo "Incompatible kernel; script is HP-UX specific." >&2 exit 1 fi VER=`${Uname} -r | cut -c3-4` case $VER in 09) # HP-UX 9.x KERNEL=/hp-ux ;; 10|11) # HP-UX 10.x or 11.x KERNEL=/stand/vmunix ;; *) # HP-UX < 9.0 echo "This script only supports HP-UX versions 9.0 and later." >&2 exit 1 ;; esac # make sure /usr filesystem is mounted mount | grep "^/usr " >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "/usr filesystem is not mounted. " \ "Please mount it, then try again." >&2 exit 1 fi # make sure /dev/mem is readable MEMDEV=/dev/mem if [ ! -r "$MEMDEV" ]; then echo "$MEMDEV read access denied. Log in as root, then try again." >&2 exit 1 fi # determine if kernel is 32 or 64 bit if [ "$VER" = 11 ]; then KBITS=`getconf KERNEL_BITS` kbits=" ($KBITS-bit)" else KBITS=32 kbits= fi if [ "$KBITS" -eq 64 ]; then ADB=adb64 else ADB=adb fi # start adb $ADB -k $KERNEL $MEMDEV |& # make sure adb started up ok if [ -z `jobs -l` ]; then echo "adb failed to start;" \ "you might try increasing the maxdsiz kernel param." >&2 exit 1 fi # get kernel data from adb external variables # alias setvar ='read -p title ; read -p resp ; eval $(echo $resp | sed "s/: */=/")' print -p hostname/s response print -p pdc_model_string/s response print -p processor_count/D response print -p cpu_arch_is_2_0/D response print -p cpu_arch_is_1_1/D response print -p cpu_arch_is_1_0/D response print -p hz/D response print -p itick_per_usec/D response if [ "$VER" -eq "11" ]; then print -p phys_mem_pages/D response mem=$phys_mem_pages else print -p physmem/D response mem=$physmem fi # determine page size eval $(grep "define *PAGESIZE" /usr/include/limits.h | \ sed 's/# *define *//;s/ /=/;s/ *//g') if [ "$PAGESIZE" = "" ]; then echo "PAGESIZE not explicitly defined; assuming 4096 KB" PAGESIZE=4096 fi # convert mem size from pages to megabytes mem=`echo "scale=1; $mem * $PAGESIZE / 1024 / 1024" | bc` mem_units=MB # if mem is greater than 1 gigabyte, convert the units to GB if [ "$mem" -ge 1024 ]; then mem=`echo "scale=1; $mem / 1024" | bc` mem_units=GB fi # no need for a decimal part if it's 0 mem=`echo $mem | sed 's/\.0//'` # display results if [ "$cpu_arch_is_2_0" = "1" ]; then cpu_arch="PA20" elif [ "$cpu_arch_is_1_1" = "1" ]; then cpu_arch="PA11" elif [ "$cpu_arch_is_1_0" = "1" ]; then cpu_arch="PA10" else cpu_arch="PAXX" fi echo "hostname\t= $hostname" echo "model\t\t= $pdc_model_string" echo "OS release level= `uname -r`$kbits" echo "processor count\t= $processor_count" echo "CPU type\t= $cpu_arch" echo "clock speed\t= $itick_per_usec MHz" echo "memory\t\t= $mem $mem_units" # kill off adb & exit print -p '$q' } ###### Obtain general system info ########## general_info() { ### Localize variables typeset max; typeset Tmp ### Print hdr info print_hdr "General Information" Tmp=/tmp/${0}.$$ sysinfo > ${Tmp} ### Hostname # host=$(uname -n) host=$(grep '^hostname' ${Tmp} | awk -F= '{print $2}') ### OS level # os_level=$(uname -r) os_level=$(grep "^OS release level" ${Tmp} | awk -F= '{print $2}') ### Number of processors # proc_num=$(ioscan -fkC processor | grep '^proc' | wc -l) proc_num=$(grep '^processor' ${Tmp} | awk -F= '{print $2}') proc_type=$(grep '^CPU' ${Tmp} | awk -F= '{print $2}') proc_speed=$(grep '^clock' ${Tmp} | awk -F= '{print $2}') procs=$(printf "%s %s %s(s)" ${proc_num} "${proc_speed}" "${proc_type}") ### Amount of memory; Need a better way to ID this!! # mem_num=$(grep Physical ${kern} | tail -1 | awk '{print $7}') # mem_num=$(echo $ | awk -v mem=$mem_num '{printf ("%.2f\n",mem/1024)}') mem_num=$(grep '^memory' ${Tmp} | awk -F= '{print $2}') ### ID model # model=$(model | awk -F/ '{print $3}') model=$(grep "^model" ${Tmp} | awk -F= '{print $2}') ### What's the NIS master? nis_master=$(ypwhich 2>/dev/null) ### Print information. [ ${#host} -gt ${#max} ] && max=${host} [ "${#os_level}" -gt ${#max} ] && max="${os_level}" [ "${#procs}" -gt ${#max} ] && max="${procs}" [ "${#mem_num}" -gt ${#max} ] && max="${mem_num}" [ ${#model} -gt ${#max} ] && max=${model} [ ${#nis_master} -gt ${#max} ] && max=${nis_master} printf "Host: %${#max}s\n" ${host} printf "OS Level: %${#max}s\n" "${os_level}" printf "Processors: %${#max}s\n" "${procs}" printf "Memory: %${#max}s\n" "${mem_num}" printf "Model: %${#max}s\n" ${model} if [ -n "${nis_master}" ] then printf "NIS Master: %${#max}s\n" ${nis_master} fi print ### Print the uptime report. print "Uptime report:" uptime print rm ${Tmp} } ####### swlist cmd outputs ################# swlist_info() { ### Print hdr info print_hdr "Software and Patch information" ### Print installed s/w and patches. swlist -l product print "=============================================" print "Unconfigured software/patches" print "=============================================" ### Print unconfigured s/w and patches. swlist -a state -l fileset | grep -i installed } ###### Print cron files ################### crontab_info() { ### Localize variables typeset cron ### Print hdr print_hdr "Cron tables" ### For each cron in the cron directory, for cron in $(ls /var/spool/cron/crontabs) do ### Print small hdr print "=============================================" print "${cron}" print "=============================================" ### Get rid of annoying tabs and extra spaces sed 's/ / /g' /var/spool/cron/crontabs/${cron} | tr -s " " print done } ####### Obtain/print network info ########## net_info() { ### Print header print_hdr "Network information" print "=============================================" print "Network adapters" print "=============================================" ### Print network adapters lanscan ### print config info by adapter # for lan in $(netstat -ain | tail +2 | awk '{print $1}' | \ # sed 's/\*//g' | sort) for lan in $(lanscan | tail -4 | grep '^[0-9]' | awk '{print $5}') do print "=============================================" ifconfig ${lan} ### Attempted to find speed of adapter, but didn't work. # print # lanadmin -x ${lan} done print "=============================================" print "Routing table" print "=============================================" ### print routing table. netstat -rn print "=============================================" print "Arp cache" print "=============================================" ### print arp cache arp -a } ######## Cat output of system files ######## important_files() { ### Localize variables & print header typeset file print_hdr "System Files" for file in /etc/mail/aliases /etc/exports /etc/group \ /etc/hosts /etc/inetd.conf /etc/MANPATH /etc/nsswitch.conf \ /etc/passwd /etc/PATH /etc/profile /etc/resolv.conf \ /etc/services do if [ -f ${file} ] then print "=============================================" print "${file}" print "=============================================" cat ${file} fi done print } ######## Report on attached tapes ########## id_tapes() { ## print header information print_hdr "Tape Drive Information" ## execute ioscan -funC tape ioscan -funC tape print } ####### ID Lan information ################# id_lan() { ## print header information print_hdr "Local Area Network Information" ## execute ioscan -funC lan ioscan -funC lan print } ######## Report kernel information ######### show_kernel() { ### Different kernel structures shown based on system ### capabiliies. 11.X & higher systems that support ### km* functionality will show current and default ### kernel parms; otherwise, a sysdef gets run. ### Localize variables typeset Kmtune; typeset Kmsystem Kmtune="/usr/sbin/kmtune" Kmsystem="/usr/sbin/kmsystem" if [ -x ${Kmtune} -a -x ${Kmsystem} ] then show_kmtune show_kmsystem else show_sysdef fi show_system } ### Parses & displays kmtune -l outputd ###### show_kmtune() { ### Localize variables typeset parm; typeset value; typeset default; typeset min; typeset module; typeset Kmtune; typeset Kmsystem; typeset Tmp; typeset line; typeset tmp typeset maxp; typeset maxv; typeset maxd; typeset maxmin typeset maxmod Kmtune="/usr/sbin/kmtune" Kmsystem="/usr/sbin/kmsystem" Tmp=/tmp/${0}.$$ print_hdr "Kernel parameters" ${Kmtune} -l | awk 'BEGIN {FS ="\n"; RS="" } { split($1,array," "); parm=array[2]; split($2,array," "); value=array[2]; split($3,array," "); default=array[2]; split($4,array," "); min=array[2]; split($5,array," "); module=array[2]; printf ("%s\t%s\t%s\t%s\t%s\n", parm,value,default,min,module); }' > ${Tmp} ### ID max column sizes cat ${Tmp} | while read parm value default min module do [ ${value} = ${default} ] && value="default" [ ${#default} -gt 35 ] && default='(( B.A.Function ))' [ ${#parm} -gt ${#maxp} ] && maxp=${parm} [ ${#value} -gt ${#maxv} ] && maxv=${value} [ ${#default} -gt ${#maxd} ] && maxd=${default} [ ${#min} -gt ${#maxmin} ] && maxmin=${min} [ ${#module} -gt ${#maxmod} ] && maxmod=${module} done printf "%-${#maxp}s %-${#maxv}s %-${#maxd}s %-${#maxmin}s %-${#maxmod}s\n" "Parameter" "Value" "Default" "Min" "Module" cat ${Tmp} | while read parm value default min module do [ ${value} = ${default} ] && value="default" [ ${#default} -gt 35 ] && default='(( B.A.Function ))' printf "%-${#maxp}s %-${#maxv}s %-${#maxd}s %-${#maxmin}s %-${#maxmod}s\n" ${parm} ${value} "${default}" ${min} ${module} done echo rm ${Tmp} } ######## Displays the kernel modules list ##### show_kmsystem() { ### Print header info print_hdr "Kernel Modules Listing" typeset Kmsystem Kmsystem="/usr/sbin/kmsystem"; ${Kmsystem} echo } show_sysdef() { ## print header info print_hdr "Kernel Parm Information" ## execute sysdef sysdef print } show_system() { typeset Tmp Tmp=/tmp/${0}.$$ ### Print header into print_hdr "Kernel System File Information" /usr/lbin/sysadm/system_prep -v -s ${Tmp} > /dev/null cat ${Tmp} rm ${Tmp} print } ######## Display exported filesystems ###### show_exports() { ## Print header information print_hdr "NFS Information" print print "=============================================" print "Exported filesystems" print "=============================================" exportfs print print "=============================================" print "NFS Clients" print "=============================================" showmount -a 2>/dev/null print print "=============================================" print "Remote mounts" print "=============================================" mount | awk '{print $3}' | grep : print } ######### Display full h/w report ########## show_ioscan() { ## Print header info print_hdr "Full h/w listing" ioscan -f print } show_printers() { ## Localize variables typeset prn; typeset mprn; typeset ip; typeset mip; typeset en; typeset ac; typeset Tmp ## print header print_hdr "Printer information" ## Initialize variables. mprn=""; mip=""; Tmp=/tmp/${0}.$$ ## Redirect output to ${Tmp} { ## For each printer defined... for prn in $(lpstat -t | grep '^device' | awk '{print $3}' | \ sed 's/://g' | sort ) do ## Lookup the IP ip=$(nslookup ${prn} 2>/dev/null | tail -4 | \ grep -i '^address' | awk '{print $2}') ## If it doesn't exist, set ip=N/A [ -z "${ip}" ] && ip="N/A" ## Is it accepting jobs? lpstat -a${prn} | head -1 | grep "not" > /dev/null 2>&1 if [ $? = 0 ] then ac='N' else ac='Y' fi ## Is it enabled? line=$(lpstat -p${prn} | head -1) echo "${line}" | grep enabled > /dev/null 2>&1 if [ $? = 0 ] then en="Y" else ## Is it disabled? echo "${line}" | grep disabled > /dev/null 2>&1 if [ $? = 0 ] then en="N" else ## If not enable, and not disabled, then I dunno... en="?" fi fi ## Set max column widths. [ ${#prn} -gt ${#mprn} ] && mprn=${prn} [ ${#ip} -gt ${#mip} ] && mip=${ip} printf "%s %s %s %s\n" ${prn} ${ip} ${en} ${ac} done } > ${Tmp} prn="Printer" [ ${#prn} -gt ${#mprn} ] && mprn=${prn} ## print column headers. printf "%-${#mprn}s %-${#mip}s Enabled Accept\n" "Printer" "IP" ## print printers. cat ${Tmp} | while read prn ip en ac do printf "%-${#mprn}s %-${#mip}s %4s %6s\n" ${prn} ${ip} ${en} ${ac} done print ## Cleanup rm ${Tmp} } ############################################## # End functions ############################################## Cmd=${0##*/} Dir=${0%/*} serial=$1 host=$(hostname) serial_file=/usr/local/etc/serial_number # kern=/var/logs/kernel.log kern=/var/adm/syslog/syslog.log if [ -z "${serial}" ] then if [ -f ${serial_file} ] then serial=$(cat ${serial_file}) else serial="Not recorded" fi fi dt=$(date "+%H:%M %m/%d/%y") msg="System Report: ${host} ${dt} Serial number: ${serial}" print_hdr "${msg}" export PATH=/bin:/usr/bin:/usr/sbin:/sbin set -A functions general_info show_kernel show_ioscan \ id_tapes id_lan show_printers get_disk_info id_alt_links \ id_unalloc_disks show_boot lvlnboot_info show_swap \ get_vg_info fstab_info bdf_info show_exports net_info \ swlist_info crontab_info important_files # set -A functions bdf_info for func in ${functions[*]} do ${func} done print_hdr "End of report"