2 ################################################################################
5 # Description: Displays information about a machine including hardware and
7 # Author: Andrew@DeFaria.com
8 # Created: Fri Jun 15 15:26:27 PDT 2001
11 # (c) Copyright 2001, Andrew DeFaria, all rights reserved.
13 ################################################################################
14 # Set me to command name
18 adm_base=${adm_base:-$HOME/adm}
21 adm_fpath=${adm_fpath:-$adm_base/functions}
26 tmpprefix=${TMPDIR:-/tmp}/$me.$$
28 tmpfile=~v801310/adm/data/$(hostname).sysinfo
32 print -u2 "Usage: $me -[h|ardware] -[s|oftware] -[da|emon]"
36 function display_inventory {
37 # This function displays the "inventory" for this machine. Currently
38 # "inventory" consists of hardware, software and daemons.
39 display_hardware_inventory
40 display_software_inventory
41 display_daemon_inventory
44 function display_hardware_inventory {
45 # This function displays the hardware inventory. Only "important" hardware
46 # values are displayed.
48 # This function may be enhanced in the future.
52 host=$(grep ^HOSTNAME: $tmpfile | cut -c16-)
58 model=$(grep ^MODEL: $tmpfile | cut -c16-)
61 cpu_speed=$(grep "^CPU SPEED:" $tmpfile | cut -c16-)
64 cpus=$(grep ^CPUS: $tmpfile | awk '{print $2}')
67 memory=$(grep MEMORY: $tmpfile | awk '{printf "%s %s", $2, $3}')
71 swap=$(swapinfo -m -t | tail -1 | awk '{print $2}')
74 swap="(Not run as root)"
79 verbose "Determining the number of disks"
80 nbr_disks=$(ioscan -C disk | grep -ve "^H/W" -e "^==" -e "CD-ROM" | wc -l)
82 nbr_disks="(Not run as root)"
85 # Volume groups and logical volumes
89 verbose "Determining volume groups and logical volumes"
90 for vg in $(vgdisplay | grep "^VG Name" | awk '{print $NF}'); do
92 for v in $(vgdisplay -v $vg | grep " LV Name" | awk '{print $NF}'); do
98 display "Machine: $host"
100 display "Model: $model"
101 display "CPUs: $cpus ($cpu_speed)"
102 display "Memory: $memory"
103 display "Swap: $swap"
104 display "Number of disks: $nbr_disks"
105 display "Volume Groups: $nbr_vg"
106 display "Logical Volumes: $nbr_lv"
108 # Print filesystems with percentage filled in descending order:
110 bdf -l | grep -ve "^Filesystem" -e "^AFS" |
111 awk '{printf "%s\t%s\n", $(NF-1), $NF}' | sort -nr
113 } # display_hardware_inventory
115 function display_software_inventory {
116 # This function displays the software inventory. Only "important" software
117 # values are displayed. Currently these are:
119 # . Certain "interesting" software registered in the SD-UX product
121 # . Certain "interesting" 3rd party software (typically not recorded
122 # properly in the SD-UX product database)
124 # This function may be enhanced in the future.
127 verbose "Checking for certain important software (SD-UX)"
128 display "\nInstalled software (SD-UX):\n"
151 grep "$package" $tmpfile > /dev/null 2>&1
153 if [ $? -eq 0 ]; then
154 if [ -n "$packages" ]; then
155 packages="$packages, $package"
161 display "\t$packages"
163 display "\nNumber of patches: \c"
164 grep -c "^ PH" $tmpfile
166 display "\nContents of /usr/local/bin:\n\t\c"
169 display "\nOther software:\n"
171 for other_software_dir in \
179 if [ -d $other_software_dir ]; then
180 if [ -n "$other_software_dirs" ]; then
181 other_software_dirs="$other_software_dirs, $other_software_dir"
183 other_software_dirs="$other_software_dir"
188 display "\t$other_software_dirs"
191 } # display_software_inventory
193 function display_daemon_inventory {
194 # This function displays the daemon inventory. Only "important" daemon
195 # values are displayed.
197 # This function may be enhanced in the future.
200 display "\nRunning daemons on $(uname -n):\n"
202 # Check to see if Oracle is running
203 if [ $(who | cut -f1 -d' ' | sort -u | grep -c oracle) -eq 1 ]; then
207 verbose "Checking for running daemons"
208 # Check other running daemons
212 /opt/perf/bin/midaemon \
213 /usr/afs/bin/bosserver \
214 /usr/afs/bin/busserver \
215 /usr/afs/bin/fileserver \
216 /usr/afs/bin/kasserver \
217 /usr/afs/bin/ptserver \
218 /usr/afs/bin/runntp \
219 /usr/afs/bin/vlserver \
220 /usr/afs/bin/volserver \
222 /usr/sbin/inetd.afs \
225 integer n=$(ps -ef | grep "$daemon" | grep -v "grep $daemon" | wc -l)
227 if [ $n -gt 0 ]; then
228 if [ -n "$daemons" ]; then
229 daemons="$daemons, $daemon"
238 } # display_daemon_inventory
244 while [ $# -ge 1 ]; do
271 error "Unknown parameter encounter: \"$1\""
280 # First check to see if we can access our own sysinfo
281 sysinfo=/usr/contrib/bin/sysinfo
283 if [ ! -x $sysinfo ]; then
284 # Next check to see if we can find sysinfo on PATH
285 sysinfo=$(whence sysinfo)
286 if [ "_$sysinfo" = "_" ]; then
287 error "Unable to find sysinfo!" 1
289 warning "Using nonstandard sysinfo: $sysinfo. Results may vary"
292 verbose "Using sysinfo: $sysinfo"
294 # Hack alert! During testing I'm letting $tmpfile hang around. Therefore if it
295 # exists already we'll simply use it assuming it contains valid output from
296 # a previous run. This speeds up things quite a bit
297 if [ ! -f $tmpfile ]; then
298 # Check to see if user is running as root
300 error "You must run this as root" 1
302 verbose "Gathering information...\c"
303 $sysinfo -a > $tmpfile
304 chown v801310:sfokt $tmpfile