Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / adm / bin / sysinfo
1 #!/bin/bash
2 #
3
4 # Title:         sysinfo
5 # Author:        Scott Truesdale
6 # Organization:  Hewlett-Packard Account Support Organization 
7 #                America's Engineering Services Team
8 #
9 # NOTE: This script is a contributed utility. No official support for it
10 #       will be provided by Hewlett-Packard. Any requests for bug fixes
11 #       or enhancements will be handled by the author, time permitting.
12 #
13 # Version:       1.00 08/01/96
14 # Changes:       1.01 08/05/96 added functions to handle each module
15 #                1.02          \ cleaned up various 
16 #                1.03          / output screens
17 #                1.04 08/20/96 added filesystem check using lvol
18 #                1.05 08/25/96 added savecore flag and space check
19 #                1.06 09/03/96 changed filesystem check to use mnttab
20 #                1.07 09/03/96 fixed filesystem check when bdf is 2 lines
21 #                1.08 10/10/96 general cleanup, added more dump checking
22 #                1.09 10/10/96 added use of pager variable for output
23 #                1.10 10/23/96 fixed dump checking section (I hope)
24 #                              added 10.10 compression calculation (-s)
25 #                1.11 10/30/96 fixed display of number of stale extents (-l)
26 #                              added comments to help document functions.
27 #                1.12 10/31/96 added -N option to disable paging option.
28 #                1.13 11/06/96 added cpu speed display (in MHz). (-s)
29 #                1.14 11/08/96 removed tabs and added comments.
30 #                1.15 11/11/96 added check for non HP-UX systems.
31 #                1.16 11/20/96 expanded mapping to include number of
32 #                              extents and mirrors. (-m)
33 #                1.17 11/21/96 added kernel size display (-k)
34 #                              added check for non-LVM disks (-p)
35 #                1.18 11/26/96 added license, machine id (-s)
36 #                              added domain name (-k)
37 #                              fixed batch to include header information
38 #                              added check for vgcfg files > 1 year old. (-v)
39 #                              added kernel size to memory dump calculations
40 #                1.19 12/03/96 fixed error if no CD mounted in CD-ROM drive
41 #                              changed help (-h) to use man page
42 #                1.20 12/12/96 added physical disk mapping option (-M)
43 #                              for 10.x systems
44 #                              added dbc_max_pct kernel parm
45 #                1.21 12/17/96 added physical disk mapping for 9.x
46 #                1.22 01/07/97 fixed bug in path display for cdroms
47 #                1.23 02/04/97 added last patch date display
48 #                1.24 02/10/97 fixed bug in physical check for cdrom
49 #                              device busy error
50 #                1.25 02/12/97 fixed display of dump on default for 9.x
51 #                1.26 02/28/97 added display of default router
52 #                1.27 03/10/97 added display of MAC address
53 #                1.28 03/18/97 added display of alternate links
54 #                              added bootable check to Physical info
55 #                1.29 04/15/97 added check for dynamic buffer caching
56 #                              added nflocks kernel parm
57 #                              added check for async disk write
58 #                              added check for savecore compression in
59 #                                    /etc/rc.config.d/savecore
60 #                              fixed exit code for warnings
61 #                              added auto boot string output
62 #                1.30 04/22/97 cleaned up swap and dump disk display
63 #                              added check for cdfs to % full warning
64 #                              fixed dbc and its warning for only 10.x 
65 #                              added ability to specify savecore
66 #                                    compression factor as variable
67 #                1.31 04/22/97 fixed bug in calculating savecore capacity
68 #                1.32 04/22/97 added display of boot disks
69 #                1.33 07/08/97 fixed pre 10.20 warning for not
70 #                              enough savecore space
71 #                1.34 07/19/97 added dns server display
72 #                              changed netmask to decimal.dot format
73 #                1.35 07/29/97 added use of model command to detect new
74 #                                    system models
75 #                              added following from Mike Ryan:
76 #                                fixed display of multiple MAC addresses
77 #                                patch for pvdisplay difference in 10.20
78 #                                fix VG display when PVG-strict policies used
79 #                                (thanks Mike!)
80 #                1.36 07/31/97 fixed bug in alternate PV link detection
81 #                1.37 08/01/97 added super page check
82 #                              removed dynamic buffer warning
83 #                              improved debug message handling
84 #                              changed debug messages to tee to file
85 #                1.38 08/17/97 added check for number of volume groups equal
86 #                                to maxvgs
87 #                              started adding HTML hooks (-H option)
88 #                                added HTML headers to each section
89 #                                added HTML links to each section
90 #                                added HTML info to man page
91 #                1.39 08/20/97 added check for existing logfiles
92 #                              ask user if we should delete batch logfile
93 #                              automatically delete HTML logfile
94 #                              changed temp file names to sysinfo.$$.
95 #                1.40 08/26/97 changed physical disk section to not query
96 #                              alternate links
97 #                1.41 08/28/97 added kernel parms section extracted using
98 #                              tools from SAM.
99 #                1.42 09/19/97 changed network to use lanscan due to
100 #                              problems with multiple I/F cards.
101 #                1.43 10/21/97 added hw path to network card info.
102 #                              added fstype display to filesystem info.
103 #                              fixed display of cdfs space usage.
104 #                              fixed man page that incorrectly stated free
105 #                                space threshold was 10% instead of 5%.
106 #                1.44 04/09/98 major enhancements
107 #                                added ioscan listing.
108 #                                added software listing (10.x only)
109 #                                added listing of striped discs.
110 #                                launched io, kernel and lvm scans
111 #                                  as background jobs to speed things up.
112 #                1.45 04/17/98 fixed bug that caused dbc parms not to
113 #                                be displayed.
114 #                1.46 04/30/98 changed swap disk header to swap data
115 #                                added fs swaptype to total swap display
116 #                1.47 05/03/98 added warning about static buffer cache
117 #                                numbers reported from kernel.
118 #                1.48 05/20/98 added variable for logfile directory.
119 #                              removed user query if removing existing logfile.
120 #                              reworked logical volume section into two parts.
121 #                1.49 07/01/98 first set of changes to work on 11.x
122 #                                savecore now called savecrash
123 #                                changed BOOTABLE to check for >= 10
124 #                                physmem now called phys_mem_pages
125 #                1.49a         added host name to WARNING messages
126 #                              added TOP link to html output
127 #                1.49b 07/16/98 fixed problems for 9.x induced by background
128 #                              scans of sam, swap and ioscan
129 #                                samscan, ioscan, swapmem
130 #                                removed samscan (getkinfo) from 9.x
131 #                              changed to force getkinfo to rescan (-b)
132 #                1.49c 07/23/98  more ioscan changes for 9.x
133 #                1.49d 07/27/98 major kernel changes
134 #                1.49e 08/01/98 fixed problem with filesystem display 
135 #                                  if size greater than 65 GB.
136 #                1.49f 08/03/98 added separate 9.x kernel function
137 #                                 including many more kernel metrics
138 #                               moved kernel size to system section
139 #                               rewrote header section for HTML
140 #                               added batch print for software section
141 #                               changed lanscan -i for 9.x
142 #                1.49g 08/05/98 lots
143 #                1.50 08/06/98 fixed kernel parms on 10.x & 11.x
144 #                1.51 08/27/98 fixed savecore free space calculation when
145 #                                using non-standard lvol name
146 #                              added cstm extract of cpu & memory info
147 #                1.52 10/14/98 fixed adb on 11.0 with 64 bit kernel
148 #                              added display of 32 or 64 bit kernel on 11.0
149 #                1.53 10/16/98 added processor info from stm
150 #                              removed old SAM kernel code
151 #                1.54 10/20/98 increased field for PDC to 12 chars
152 #                1.55 10/20/98 fixed ifconfig problem with grep
153 #                1.56 10/20/98 added No such file or directory check to diskinfo
154 #                              changed rphysvol to use ioscan rather than
155 #                                      calculating
156 #                              increased display of hwpath for EMC drives
157 #                1.57 10/22/98 fixed bug in getting rdsk name
158 #                1.58 10/27/98 added bad block relocation to logical display
159 #                              added warning for EMC disks with LVM bad 
160 #                                     block relocation enabled
161 #                1.59 11/3/98  added check for iodevice w/o phyvol
162 #                                
163 #                1.70 04/12/99 added check for unsupported cstm versions
164 #                               < 09 & > 13
165 #                1.71 04/12/99 Numerous changes by Greg Sterling
166 #                              Code handles CRASHCONF utility
167 #                              Allows for dump devices in V11.x.
168 #                              Dump devices can be disk drives in addition
169 #                                  to logical volumes.
170 #                              Allow for Fibrechannel devices to be
171 #                                  accurately parsed in the Phys Device section.
172 #                              Updated the wait for ioscan to complete.
173 #                                  The prior time was 15 seconds, this is not
174 #                                  enough for a large system with many devices.
175 #                                  I increased the wait to 125 seconds.
176 #                              Fixed the "Last Patch" section to work with
177 #                                  a standard swinstall type system.
178 #                              Added security check. Checks file permissions
179 #                                  on some critical files and dirs, and checks
180 #                                  modem access.
181 #                              Check system log files (i.e.  syslog.log,
182 #                                  mail.log, btmp, and wtmp). These files are
183 #                                  known to get large very quickly.
184 #                              Changes the Date stamp on output files
185 #                                  to include a four digit year for Y2K reasons.
186 #                              Check the sendmail queue for old (older than
187 #                                  2 days) or large qty of entries.
188 #                              Added code to check/output information
189 #                                  related to system diags (if its installed).
190 #                                  This included diags and predictive.
191 #                                  This option only applies to V10.x and up.
192 #                              Fixed a few bugs in the code which limited
193 #                                  output to 10.10 or 10.20 systems. I had
194 #                                  to change some of the IF statements.
195 #                              For V10.x systems and higher I added the
196 #                                  /var/adm/sw/*.log files to the logfile
197 #                                  check routine.
198 #                1.72 04/25/99 fixed bug in crashconf size calculation
199 #                              added ip name to ip addr in networking
200 #                              moved 32/64 bit to follow OS version
201 #                              added check for non-configured software
202 #                                    i.e. transient, corrupt, available
203 #                                    or installed
204 #                              added listing of boot paths under bootable disks
205 #                1.73 05/14/99 fixed cstm hang problem - finally!
206 #                                 vers 12 reversed the meanings of the
207 #                                 SaveAs and Print commands for Infolog
208 #                1.74 05/25/99 improved formatting of cstm output
209 #                1.75 06/02/99 fixed bug when cstm_tot_phys = N/A
210 #                              added path to crashconf executable (/sbin/)
211 #                              fixed bug when Online dir has .2 suffix
212 #                1.76 07/12/99 several performance changes thanks to J. Semroc
213 #                              changed filesystem section 
214 #                                 added vxfs fragmentation; removed inodes
215 #                              added check if Vxfs version < 3 on > 10.10
216 #                              replaced cstm memory output
217 #                              added umask of 077 for security purposes
218 #                1.77 08/03/99 fixed Ignite version check for older versions
219 #                              removed cd-rom size from total p_size
220 #                1.78 09/07/99 added PA RISC chip and version
221 #                              removed cstm upper version check
222 #                1.78a 9/14/99 removed DVD size from total p_size
223 #                              increased sum lines for CAPACITY
224 #                              increased display size of product (model)
225 #                1.78b 9/18/99 Incorporated numerous changes by Jerry Schwartz:
226 #                                changed HTML output to use frames
227 #                                #fixed bug in physical disk enumeration
228 #                                fixed bug in check for /.profile
229 #                                made cosmetic changes to error messages
230 #                                   ("Logfile" changed to "Important file",
231 #                                   "doesn not" changed to "does not")
232 #                1.78c 10/2/99 Added cstm disk scan to retrieve firmware
233 #                                    and serial number info.
234 #                1.78d 10/11/99 Updated models table
235 #                1.78e
236 #                1.78f          Added XP256 information
237 #                1.79b
238 #                  |
239 #                1.79f 04/18/00 Added INSTALL script
240 #                               Added checks for diagmond to prevent hangs
241 #                               Added disk array checks for FC60, AutoRaid
242 #                                  Cascade, and Nike.
243 #                1.79g 04/19/00 Added return to diagmond check
244 #                1.79h 05/15/00 Added additional system models
245 #                               Removed get_array_data due to cstm problem
246 #
247 #
248 # Acknowledgements:
249 # I would like to acknowledge the following for assistance in 
250 #               developing and testing this tool. 
251 #
252 # Jerry Schwartz, Jeff Semroc, Greg Sterling, Mike Ryan & Bill Taylor
253 # from the HP Account Support Organization for their help in debugging 
254 # and improving the code.
255 #
256 # LVMcollect.* scripts from Peter Van Giel in the Hewlett-Packard 
257 #        Country Response Center Belgium.
258 # capture script from Dave Olker of the Hewlett-Packard Worldwide 
259 #        Technology Expert Center.
260 #
261 # Most of all I would like to thank the PRODUNIX support team 
262 # at Oracle Corp. for allowing me access and time to develop 
263 # and test using their systems.
264 #
265 #
266 version="1.79h"                     #
267 umask 077
268 ROOT=$PWD                           #
269 export RESOLV_CONF=/etc/resolv.conf #
270 #script=`basename $0`               #
271 script="SysInfo"                    #
272 typeset PAGER=${PAGER:-more}        #
273 typeset -x osmajor                  #
274 typeset -R4 lcount=0                # number of logical volumes
275 typeset -R4 pcount=0                # number of physical volumes
276 typeset -R4 vgcount=0               # number of volume groups
277 typeset -i total_stale=0            # number of stales extents
278 typeset stale=0                     # flag set if stale extents found
279 typeset all_logvols                 # list of all logical volumes
280 typeset -L17 physvol                # name of phyical volume
281 typeset -R21 rphysvold              # name of raw phyical volume
282 typeset -R24 hwpathd                # path information for disk
283 typeset -L8 vendor                  # vendor id string from disk
284 typeset EMC_found=0                 # flag for EMC disks
285 typeset -R14 product                # vendor model number from disk
286 typeset -R1 bootable_pv             # is disk bootable?
287 typeset -R5 rev_level               # firmware revision code from disk
288 #typeset -R12 kernel_size           #\
289 typeset -i shmem                    # \
290 typeset -R8 shmmni                  #  \
291 typeset -R8 shmmax                  #   \
292 typeset -R8 shmseg                  #   \
293 typeset -R8 maxfiles                #    \
294 typeset -R8 maxfiles_lim            #     \
295 typeset -R8 maxuprc                 #      \
296 typeset -R8 nproc                   #       \ 
297 typeset -R8 fs_async                #        \ 
298 typeset -R8 nfile                   #           kernel parameters
299 typeset -R8 nflocks                 #          
300 typeset -R8 super_page_support      #        /
301 typeset -R8 dbc_max_pct             #       /
302 typeset -R8 dbc_min_pct             #      /
303 typeset -R8 ninode                  #     /  
304 typeset -R8 npty                    #    /
305 typeset -R8 nbuf                    #   /
306 typeset -R8 bufpages                #  /
307 typeset -R8 maxvgs                  # /
308 typeset SAVECORE                    # flag set if savecore is enabled
309 typeset COMPRESS=0                  #
310 typeset COMPRESSION="N/A"           # set if on 10.10 or later
311 typeset Compress_Option="N/A"       # enabled in /etc/rc.config.d/savecore
312 typeset -R8 lv_pbuf_cnt             # \
313 typeset -R8 lv_pbuf_inuse           #  \
314 typeset -R8 lv_pbuf_maxuse          #     more kernel parameters
315 typeset -R8 lv_pbuf_pending_Q       #     for lvm
316 typeset -R8 lv_vgs_opn              #  /
317 typeset -R8 lv_lvs_opn              # /
318 typeset -i psize                    # physical disk size (in KBytes)
319 typeset -R8 psize_mb                # physical disk size (in Mbytes)
320 ### Changed 6/15/99 J.Semroc - Changed to handle large systems with 1000+ LU's
321 ### typeset -R3 lu                      # physical disk logical unit number
322 typeset -R4 lu                      # physical disk logical unit number
323 ### end of Change
324 typeset -L20 volgroup               #
325 typeset -R6  CURLV                  #
326 typeset -R10 CURPV                  #
327 typeset -R8  PeSize                 #
328 typeset -R9  AllocPe                #
329 typeset -R8  FreePe                 #
330 typeset -R8  TotalPe                #
331 typeset -R11 AllocMb                #
332 typeset -R8  FreeMb                 #
333 typeset -R8  TotalMb                #
334 typeset -R8 TotalAllocMb=0          # total allocated Megabytes
335 typeset -R8 TotalFreeMb=0           # total free Megabytes
336 typeset -R8 SystemTotalMb=0         # total of all Megabytes
337 typeset -R8 MirrorMb=0              # size of mirror
338 typeset -R8 TotalMirrorMb=0         # total size of mirrors
339 typeset -R8 OtherMb=0               #
340 typeset -R11 total_p_mb=0           # total physical Megabytes
341 typeset -R8 total_l_mb=0            # total logical Megabytes
342 typeset -R8 unused_cap=0            #
343 typeset -L4 fs_type                 #
344 typeset -R4 vxfs_frag               #
345 typeset -i no_lost=0                # flag if lost+found/.fsadm not found
346 typeset  logvol                     #
347 typeset -L40 logvold                #
348 typeset  pvol                       #
349 typeset -L16 statusout              # status of extents (e.g. stale)
350 typeset -R6 LVSize                  # size of logical volume
351 typeset -R7 LogicalExtents          #
352 typeset -R8 StaleExtents            #
353 typeset -L35 MOUNT                  #
354 typeset -R8 MirrorCopies            # number of mirrors
355 typeset -R8 Consistency             # mirror consistency strategy
356 typeset -i REAL_MEM                 # memory size (in pages)
357 typeset -i memory                   # memory size (in MBytes)
358 typeset -i num_cpus                 # number of active CPUs
359 typeset -i StaleMB=0                # stale Megabytes
360 typeset -i TotalStaleMb=0           # total stale Megabytes
361 typeset -i cpu_speed=0              # clock speed in MHz
362 typeset exit_code=0                 # exit code [ 0, 1, 2, 3 ]
363 typeset ERROR=1                     # exit condition (program error)
364 typeset WARN=2                      # exit condition (system warning)
365 typeset SYS_ERROR=3                 # exit condition (system error)
366 typeset SYSTEM=0                    # \
367 typeset FULL_KERNEL=0               #  \
368 typeset LITE_KERNEL=0               #   \
369 typeset FILESYSTEM=0                #    \
370 typeset NETWORK=0                   #     \
371 typeset DEBUG=0                     #      \
372 typeset SWLIST=0                    #       \
373 typeset PHYSICAL=0                  #         flags set at runtime via
374 typeset LOGICAL=0                   #         command line options
375 typeset IOSCAN=0                    #       /
376 typeset -x HTML=0                   #      /
377 typeset NOPAGER=0                   #     /
378 typeset VOLUMES=0                   #    /
379 typeset CAPACITY=0                  #   /
380 typeset BATCH=0                     #  /
381 typeset LMAP=0                      # /
382 typeset PMAP=0                      #/
383 typeset KernelSafetyFactor=2        # adds two MBytes to kernel size
384 typeset lvm_installed=0             # flag set if lvm present
385 typeset -R6 DumpDiskCapacity=0      # space to hold memory dump
386 typeset -R6 CompressedMemoryDumpSize #
387 typeset -R6 compression_factor      #
388 typeset -i MemoryDumpSize           # amount of memory (in MBytes)
389 typeset -i TotalMemoryDumpSize      # amount of memory + kernel size
390 typeset -R6 MemoryDumpSizeOut       # display version of MemoryDumpSize
391 typeset -R6 TotalMemoryDumpSizeOut  # display version of TotalMemoryDumpSize
392 typeset -R6 SaveCoreAvail_Out       # space to hold savecore
393                                     # can be compressed on 10.10 and later
394 ##############
395 # Variables for Chk_Logfiles section
396 ##############
397 LOGFILELISTV10="/var/adm/syslog/syslog.log /var/adm/syslog/mail.log \
398  /var/adm/btmp /var/adm/wtmp /var/adm/sw/swagent.log /var/adm/sw/swagentd.log \
399  /var/adm/sw/swconfig.log /var/adm/sw/swcopy.log /var/adm/sw/swinstall.log \
400  /var/adm/sw/swmodify.log /var/adm/sw/swreg.log /var/adm/sw/swremove.log"
401
402 LOGFILELISTV9="/usr/adm/syslog /usr/spool/mqueue/log /etc/btmp /etc/wtmp"
403 ##############
404 # Variables for Chk_SysAccess section
405 ##############
406 WORLDREADFILES="/etc/passwd /etc/group /etc/hosts /etc/services \
407  /etc/inetd.conf"
408
409 NOREADFILES=~root/.profile
410 ##############
411 # variables for io_scan section
412 ##############
413 GREP_ARGS=""
414 GREP_V_ARGS="-eNO_HW"
415 typeset -x ioscan_args="-F"
416 typeset -x io_scan_out=/tmp/sysinfo.$$.io_scan.out
417 typeset -x io_scan_tmp=/tmp/sysinfo.$$.io_scan.tmp
418 typeset -x io_scan_done=/tmp/sysinfo.$$.io_scan_done
419 typeset -x io_scan_command_file=/tmp/sysinfo.$$.io_scan_command_file
420 ##############
421 # variables for lvm_scan section
422 ##############
423 typeset -x vg_list_file=/tmp/sysinfo.$$.vg.list
424 typeset -x vg_out_file=/tmp/sysinfo.$$.vg.out
425 typeset -x lvol_list_file=/tmp/sysinfo.$$.lvol.list
426 typeset -x lvol_out_file=/tmp/sysinfo.$$.lvol.out
427 typeset -x pvol_list_file=/tmp/sysinfo.$$.pvol.list
428 typeset -x pvol_out_file=/tmp/sysinfo.$$.pvol.out
429 typeset -x lvm_scan_command_file=/tmp/sysinfo.$$.lvm_scan_command_file
430 typeset -x lvm_scan_done=/tmp/sysinfo.$$.lvm_scan_done
431 ##############
432 # variables for sam_scan section
433 ##############
434 typeset -x sam_scan_command_file=/tmp/sysinfo.$$.sam_scan_command_file
435 typeset -x sam_scan_done=/tmp/sysinfo.$$.sam_scan_done
436 typeset -x sam_out_file=/tmp/sysinfo.$$.sam.out
437 #typeset -x sam_kinfo=/tmp/sysinfo.$$.kinfo
438 typeset -x sam_kinfo_new=/tmp/sysinfo.$$.kinfo_new
439 ##############
440 # variables for kernel section
441 ##############
442 typeset -x sam_kinfo=${sam_kinfo:-/tmp/sysinfo.$$.sam_kinfo}
443 typeset -x all_parms_file=/tmp/sysinfo.$$.all_parms
444 typeset -x all_classes_file=/tmp/sysinfo.$$.all_classes
445 ##############
446 # variables for cstm section
447 ##############
448 typeset -x cstm_command_file=/tmp/sysinfo.$$.cstm_command_file
449 typeset -x cstm_cpu_out=/tmp/sysinfo.$$.cstm_cpu_out
450 typeset -x cstm_cpu_out2=/tmp/sysinfo.$$.cstm_cpu_out2
451 typeset -x cstm_mem_out=/tmp/sysinfo.$$.cstm_mem_out
452 typeset -x cstm_disk_out=/tmp/sysinfo.$$.cstm_disk_out
453 typeset -x cstm_array_out=/tmp/sysinfo.$$.cstm_array_out
454 #############
455 # variables for sap section
456 #############
457 # translate uppercase to lowercase
458 TRUL='tr "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"'
459 typeset -x r3_dir=/var/opt/perf/datafiles/r3dsi
460 typeset -x r3_prog=${r3_dir}/r3agent
461 typeset -i num_instances=0
462
463
464 ALL="TRUE"
465 FORCE="FALSE"
466 TEMPFILE=/var/sam/sam.$$
467 save_lang=$LANG
468 LANG=C
469
470
471 ################################################################################
472 # Function:    DebugOn()
473 # Description: Turns debugging mode on.
474 # Arguments:   none
475 # Returns:     none
476
477 DebugOn() {
478 #   set -o xtrace
479     export _DEBUG=1
480     export _DEBUG_FILE=/tmp/sysinfo_${sysname}_`date '+%Y%m%d'`_debug
481     #Debug Debug ON: info will be logged to screen and to $_DEBUG_FILE
482     print "\nDebug ON: info will be logged to $_DEBUG_FILE"
483     Debug  Debug ON: info will be logged to $_DEBUG_FILE
484 }
485
486 ################################################################################
487 # Function:    DebugOff()
488 # Description: Turns debugging mode off.
489 # Arguments:   none
490 # Returns:     none
491
492 DebugOff() {
493
494     Debug Debug OFF
495     _DEBUG=0
496     _DEBUG_FILE=$ROOT/debug.out
497 }
498
499 ###############################################################################
500 # Function:    Debug()
501 # Description: Prints debug statements to stderr when debug mode is on.
502 # Arguments:   Text to echo.
503 # Returns:     none
504
505 Debug() {
506
507     if [ "$_DEBUG" -gt 0 ]
508     then
509         #echo "DEBUG (PID $$): $*" | tee -a $_DEBUG_FILE 1>&2
510         echo "DEBUG (PID $$): $*" >> $_DEBUG_FILE 2>&1
511     fi
512 }
513
514
515 #-----------------------------------------------------------#
516 # Exit function, called by trapped signals
517 #-----------------------------------------------------------#
518 function _sigexit
519 {
520 # print "Cleaning up, please wait."
521   if (($DEBUG)) && ((!(($NOPAGER)) ))
522   then
523     read answer?"Delete temp files? [Y/n]"
524     if [[ ${answer} = n ]]
525     then
526       print "O.K.  Don't forget to delete /tmp/sysinfo.$$.*"
527       print "exit value = ${exit_code}" 
528     else
529       print "O.K.  I'm deleting temp files /tmp/sysinfo.$$.*"
530       rm -f /tmp/sysinfo.$$.* > /dev/null 2>&1
531       print "exit_code = ${exit_code}" 
532     fi
533   else
534     rm -f /tmp/sysinfo.$$.* > /dev/null 2>&1
535   fi
536   exit ${exit_code}
537 }
538 trap _sigexit  EXIT KILL HUP QUIT INT
539
540
541 function usage
542 {
543 cat << EOF | $PAGER
544
545 ${script} ${version} by Scott Truesdale
546
547 Usage:  ${script} [-aADfikKlLmMnpsSv] [-b|-H|-N]
548         ${script} [-h]
549
550        -a displays all of the following options.
551        -A displays file access security.
552        -D checks system diagnostic information.
553        -f checks filesystems for free space.
554        -h displays detailed help message.
555        -i displays io configuration.
556        -k displays brief kernel parameters.
557        -K displays verbose kernel parameters.
558        -l displays logical volume data.
559        -L displays system logfile info.
560        -m displays logical to physical disk mapping.
561        -M displays physical to logical disk mapping.
562        -n displays network interface data.
563        -p displays physical disk data.
564        -P checks for R/3 instances.
565        -s displays the system and root disk data.
566        -S displays software listing (swlist).
567        -v displays volume group data.
568
569        -b send output to a logfile.
570        -H send output to a logfile in HTML format.
571        -N turn off paging in screen mode.
572
573 Note: disk capacity data is displayed only when using -a or -lpv.
574
575 EOF
576 }                # end of usage
577
578 function print_help
579 {
580 export MANPATH=/usr/contrib/man:${where}:$MANPATH
581 # to debug help -d must come before -h
582 Debug "print_help"
583 Debug "  where=${where}"
584 Debug "  MANPATH=${MANPATH}"
585 if [[ -f ${where}/man1m/sysinfo.1m ]] || \
586    [[ -f /usr/contrib/man/man1m/sysinfo.1m ]]
587 then
588   man sysinfo
589   exit_code=0
590 else
591   print "Cannot find man page for ${script}!"
592   print "Expected to find it in /usr/contrib/man/man1m/"
593   exit_code=${ERROR}
594 fi
595 }
596
597
598 #===================================================================
599 # get_args
600 #      gets command line arguments passed in at run time
601 #===================================================================
602 function get_args
603 {
604 if (($# == 0))
605 then
606 #print "\n$Must specify one or more of the following:$\n"
607  usage
608  exit ${ERROR}
609 fi
610 while getopts :abdfhiklmnpsvADHKLMNPS arguments
611 do
612   case $arguments in
613     a) LITE_KERNEL=1
614        LOGFILES=1
615        FILEACCESS=1
616        DIAGNOSTICS=1  
617        SYSTEM=1
618        NETWORK=1
619        IOSCAN=1
620        LVMSCAN=1
621        PHYSICAL=1
622        VOLUMES=1
623        LOGICAL=1
624        FILESYSTEM=1
625        SWLIST=1
626        PMAP=1
627        LMAP=1;;
628     A) FILEACCESS=1;;
629     b) BATCH=1 
630
631          LOGDIR=${SYSINFO_LOGDIR:-"/tmp"}
632          LOGFILE="${LOGDIR}/sysinfo_${sysname}_`date '+%Y%m%d'`"
633          Debug "Removing $LOGFILE"
634          rm -f $LOGFILE > /dev/null 2>&1
635
636        ;;
637     d) DEBUG=1
638          DebugOn;;
639     D) DIAGNOSTICS=1;;
640     f) FILESYSTEM=1;;
641     h) print_help
642          exit ${exit_code};;
643     H) HTML=1
644        BATCH=1
645        LOGFILES=1
646        LITE_KERNEL=1
647        FILEACCESS=1
648        DIAGNOSTICS=1  
649        SYSTEM=1
650        NETWORK=1
651        PHYSICAL=1
652        VOLUMES=1
653        IOSCAN=1
654        LVMSCAN=1
655        LOGICAL=1
656        FILESYSTEM=1
657        SWLIST=1
658        PMAP=1
659        LMAP=1
660        LOGDIR=${SYSINFO_LOGDIR:-"/tmp"}
661        LOGFILE="${LOGDIR}/sysinfo_${sysname}_`date '+%Y%m%d'`.html"
662        if [[ -f ${LOGFILE} ]]
663        then
664          rm -f $LOGFILE >> /dev/null 2>&1
665          Debug "Removing $LOGFILE"
666        fi
667        LOGFILE_INDEX_REL="`basename ${LOGFILE} .html`.index.html"
668        LOGFILE_INDEX="`dirname ${LOGFILE}`/${LOGFILE_INDEX_REL}"
669        if [[ -f ${LOGFILE_INDEX} ]]
670        then
671          rm -f ${LOGFILE_INDEX} >> /dev/null 2>&1
672          Debug "Removing ${LOGFILE_INDEX}"
673        fi
674        LOGFILE_MAIN_REL="`basename ${LOGFILE} .html`.main.html"
675        LOGFILE_MAIN="`dirname ${LOGFILE}`/${LOGFILE_MAIN_REL}"
676        if [[ -f ${LOGFILE_MAIN} ]]
677        then
678          rm -f ${LOGFILE_MAIN} >> /dev/null 2>&1
679          Debug "Removing ${LOGFILE_MAIN}"
680        fi;;
681     i) IOSCAN=1;;
682     k) LITE_KERNEL=1;;
683     K) FULL_KERNEL=1;;
684     l) LOGICAL=1 
685        LVMSCAN=1;;
686     L) LOGFILES=1;;
687     m) LMAP=1;;
688     M) PHYSICAL=1
689        SYSTEM=1
690        PMAP=1;;
691     n) NETWORK=1;;
692     p) PHYSICAL=1
693        SYSTEM=1;;
694     P) PASS=1;;
695     s) SYSTEM=1;;
696     S) SWLIST=1;;
697     v) VOLUMES=1
698        LVMSCAN=1;;
699     N) NOPAGER=1;;
700     ?) print "\nI don't understand that option\n" 
701        usage
702        exit ${ERROR};;
703   esac
704   if (($PHYSICAL)) && (($VOLUMES)) && (($LOGICAL))
705   then
706     CAPACITY=1
707   fi
708   if (($LITE_KERNEL)) && (($FULL_KERNEL))
709   then
710     LITE_KERNEL=0
711   fi
712   if (($BATCH)) && (($DEBUG))
713   then
714     NOPAGER=1
715   fi
716 done
717 Debug "FLAGS: System=$SYSTEM Batch=$BATCH FullKernel=$FULL_KERNEL"
718 Debug "FLAGS: LiteKernel=$LITE_KERNEL Network=$NETWORK"
719 Debug "FLAGS: Volumes=$VOLUMES Capacity=$CAPACITY Logical=$LOGICAL"
720 Debug "FLAGS: Physical=$PHYSICAL LMapping=$LMAP PMapping=$PMAP"
721 Debug "FLAGS: Filesystem=$FILESYSTEM NoPager=$NOPAGER Html=$HTML"
722 Debug "FLAGS: Ioscan=$IOSCAN lvm_scan=$LVMSCAN Sam_scan=$SAMSCAN"
723 Debug "FLAGS: Swlist=$SWLIST Diagnostics=$DIAGNOSTICS"
724 Debug "FLAGS: PASS=$PASS"
725 if (($BATCH))
726 then
727   print "\nOutput going to ${LOGFILE}"
728 fi
729 }                # end of get_args
730
731
732 #===================================================================
733 # f_display_file
734 #      this function displays a file to the screen. it takes one parm, 
735 #      the file to display. It uses the defined PAGER or more if that
736 #      variable is not defined.
737 #===================================================================
738 function f_display_file
739 {
740   if [[ -s $1 ]]
741   then
742     if (($BATCH))
743     then
744       cat $1 >> $LOGFILE
745       if (($HTML))
746       then
747         grep -v "#Top" $1 | grep -v "TOP</A" >> $LOGFILE_MAIN
748       fi
749     elif (($NOPAGER))
750     then
751       cat $1
752     else                        # not batch so use PAGER
753       $PAGER $1
754     fi
755   fi
756 }                # end of f_display_file
757
758
759 ###############################################################################
760 # Function:    check_for_sap
761 # Description: Check for any instances of R/3 by running r3agent -all.
762 #              The output is scanned for the required info.
763 #
764 # The r3agentSYSTEM output is as follows:
765 #  01 "31G" "QAS" "sapgui sapd370 nr=01 name=QAS"
766 #
767 # The r3agentCONFIGURATION output is as follows:
768 #  01 "DVEBMGS01" "QAS" "sapd370" ""
769
770 function check_for_sap
771 {
772   print "Checking for SAP R/3 instances."
773   DB_on_this_sys=0
774   if (($HTML))
775   then
776     print "</PRE>"                  >> /tmp/sysinfo.$$.sap
777     print "<A name='SAP'></A>"      >> /tmp/sysinfo.$$.sap
778     print "<H2>"                    >> /tmp/sysinfo.$$.sap
779     print "<P ALIGN=RIGHT><A HREF='#Top'>" >> /tmp/sysinfo.$$.sap
780     print "TOP</A></P>"                    >> /tmp/sysinfo.$$.sap
781     print "<FONT COLOR=red>" >> /tmp/sysinfo.$$.sap
782     print "SAP R/3 Info</FONT></H2>"  >> /tmp/sysinfo.$$.sap
783     print "<PRE><font size = '4'>"  >> /tmp/sysinfo.$$.sap
784   else
785     print "" >> /tmp/sysinfo.$$.sap
786     print "SAP R/3 Information" >> /tmp/sysinfo.$$.sap
787     print "===================" >> /tmp/sysinfo.$$.sap
788     print "" >> /tmp/sysinfo.$$.sap
789   fi
790   if [ -f ${r3_prog} ]
791   then
792     ${r3_prog} -all
793     num_instances=$( cat ./r3agentSYSTEM | wc -l)
794     if ((num_instances == 0))
795     then
796       print "No R/3 instances found."
797       print "No R/3 instances found." >> /tmp/sysinfo.$$.sap
798       rm ./r3agent[A-Z]* > /dev/null 2>&1
799       break
800     else
801       print "Found ${num_instances} instances."
802       cat ./r3agentCONFIGURATION | 
803       while read inst_id INSTANCE_NAME SAPSYSTEMNAME SAPDBHOST p5 p6 p7
804       do
805         INSTANCE_NAME=$(echo ${INSTANCE_NAME} | sed -e 's/\"*//g')
806         SID=$(echo ${SAPSYSTEMNAME} | sed -e 's/\"*//g')
807         SAPDBHOST=$(echo ${SAPDBHOST} | sed -e 's/\"*//g')
808         SAP_ADM="`echo $SID | $TRUL`adm"
809         startsap=$(su - ${SAP_ADM}  -c  "alias startsap" 2>&1 | tail -1)
810         sapstart=$(ps -ef | grep sapstart | grep -v grep | awk '{print $9}')
811         #PROFILE_DIR=$(grep "^PROFILE_DIR" ${startsap} | awk -F\" '{print $2}')
812         PROFILE_DIR=/usr/sap/${SID}/SYS/profile
813         EXE_DIR=/usr/sap/${SID}/SYS/exe/run
814         startprofile=$(grep "^START_PROFILE" ${startsap} |awk -F\" '{print $2}')
815         #SAPDBHOST=$(awk -F= '/SAPDBHOST/ {print $2}' $PROFILE_DIR/DEFAULT.PFL)
816         ${EXE_DIR}/disp+work -V > /tmp/sysinfo.$$.dispwork 2>&1
817
818         Debug "Saving dispwork -V output file"
819         cp /tmp/sysinfo.$$.dispwork ${r3_dir}/dispwork > /dev/null 2>&1
820
821         r3kernel=$(grep "kernel release" /tmp/sysinfo.$$.dispwork | \
822                     awk '{print $3}')
823         r3patch=$(grep "patch level" /tmp/sysinfo.$$.dispwork | \
824                     head -1 | awk '{print $3}')
825         r3db=$(grep "database kernel" /tmp/sysinfo.$$.dispwork | \
826                     awk '{print $4}')
827         r3dbver=$(grep "database kernel" /tmp/sysinfo.$$.dispwork | \
828                     awk '{print $5}')
829         if [[ -f ${PROFILE_DIR}/${startprofile} ]]
830         then
831           Debug "Saving profile ${PROFILE_DIR}/${startprofile}"
832           cp ${PROFILE_DIR}/${startprofile} ${r3_dir} > /dev/null 2>&1
833         fi
834         if [[ $SAPDBHOST = $sysname ]]
835         then
836           DB_on_this_sys=1
837           startdb=${EXE_DIR}/startsb
838           ORASID="ora`echo $SID | $TRUL`"
839           ORACLE_HOME=/oracle/${SID}
840           db_profile=${ORACLE_HOME}/dbs/init${SID}.ora
841           INITORA=$ORACLE_HOME/dbs/init${SID}.ora
842           if [[ -f ${db_profile} ]]
843           then
844             Debug "Saving profile ${db_profile}"
845             cp ${db_profile} ${r3_dir} > /dev/null 2>&1
846           fi
847         fi
848         print "  Instance ID     = $inst_id"         >> /tmp/sysinfo.$$.sap
849         print "  Instance Name   = ${INSTANCE_NAME}" >> /tmp/sysinfo.$$.sap
850         print "  SAP System Name = ${SID}"           >> /tmp/sysinfo.$$.sap
851         print "  R/3 Kernel Vers = ${r3kernel}"      >> /tmp/sysinfo.$$.sap
852         print "  R/3 Patch Level = ${r3patch}"       >> /tmp/sysinfo.$$.sap
853         print "  R/3 DB Vendor   = ${r3db}"          >> /tmp/sysinfo.$$.sap
854         print "  R/3 DB Version  = ${r3dbver}"       >> /tmp/sysinfo.$$.sap
855         print "  SAP adm user    = ${SAP_ADM}"       >> /tmp/sysinfo.$$.sap
856         print "  startsap        = ${startsap}"      >> /tmp/sysinfo.$$.sap
857         print "  sapstart        = ${sapstart}"      >> /tmp/sysinfo.$$.sap
858         print "  Profile Dir     = ${PROFILE_DIR}"   >> /tmp/sysinfo.$$.sap
859         print "  startprofile    = ${startprofile}"  >> /tmp/sysinfo.$$.sap
860         print "  SAPDBHOST       = ${SAPDBHOST}"     >> /tmp/sysinfo.$$.sap
861         if (($DB_on_this_sys))
862         then
863           print "  DB_on_this_sys  = true"           >> /tmp/sysinfo.$$.sap
864           print "    ORASID        = ${ORASID}"      >> /tmp/sysinfo.$$.sap
865           print "    ORACLE_HOME   = ${ORACLE_HOME}" >> /tmp/sysinfo.$$.sap
866           print "    INITORA       = ${INITORA}"     >> /tmp/sysinfo.$$.sap
867         else
868           print "  DB_on_this_sys  = false"          >> /tmp/sysinfo.$$.sap
869         fi
870         print "" >> /tmp/sysinfo.$$.sap
871       done
872     fi
873   else
874     print "  r3agent not found!"
875     print "  Scanning for dw.sap processes."
876     allinst=$(ps -ef | grep dw.sap | grep -v grep | awk '{print $(NF -1)}' | sort | uniq)
877     if [[ -z $allinst ]]
878     then
879       num_instances=0
880     else
881       num_instances=$(echo $allinst | wc -w)
882     fi
883     if ((num_instances == 0))
884     then
885       print "No R/3 instances found."
886       print "No R/3 instances found." >> /tmp/sysinfo.$$.sap
887       break
888     else
889       print "Found ${num_instances} instances."
890       for inst in ${allinst}
891       do
892         numchar=$(echo $inst | wc -c)
893         (( numchar = numchar - 1 ))
894         (( numchar1 = numchar - 1 ))
895         SID=$(echo $inst | cut -b7-9)
896         inst_id=$(echo $inst | cut -b${numchar1}-${numchar})
897         INSTANCE_NAME=$(echo $inst | cut -b11-${numchar})
898         SAP_ADM="`echo $SID | $TRUL`adm"
899         PROFILE_DIR=/usr/sap/${SID}/SYS/profile
900         startsap=$(su - ${SAP_ADM}  -c  "alias startsap" 2>&1 | tail -1)
901         #sapstart=$(ps -ef | grep sapstart | grep $SID |grep -v grep | awk '{print $9}')
902         sapstart=$(ls -L ${PROFILE_DIR}/START_${INSTANCE_NAME})
903         #echo $sapstart
904         startprofile=$(grep "^START_PROFILE" ${sapstart} |awk -F\" '{print $2}')
905         EXE_DIR=/usr/sap/${SID}/SYS/exe/run
906         SAPDBHOST=$(awk -F= '/SAPDBHOST/ {print $2}' $PROFILE_DIR/DEFAULT.PFL)
907         SAPDBHOST=$(echo $SAPDBHOST | sed -e 's/\ *//g')
908         if [[ $SAPDBHOST = $sysname ]]
909         then
910           DB_on_this_sys=1
911           startdb=${EXE_DIR}/startsb
912           ORASID="ora`echo $SID | $TRUL`"
913           ORACLE_HOME=/oracle/${SID}
914           INITORA=$ORACLE_HOME/dbs/init${SID}.ora
915           if [[ -f ${db_profile} ]]
916           then
917             Debug "Saving profile ${db_profile}"
918             cp ${db_profile} ${r3_dir} > /dev/null 2>&1
919           fi
920         fi
921         ${EXE_DIR}/disp+work -V > /tmp/sysinfo.$$.dispwork 2>&1
922
923         Debug "Saving dispwork -V output file"
924         cp /tmp/sysinfo.$$.dispwork ${r3_dir}/dispwork > /dev/null 2>&1
925
926         r3kernel=$(grep "kernel release" /tmp/sysinfo.$$.dispwork | \
927                     awk '{print $3}')
928         r3patch=$(grep "patch level" /tmp/sysinfo.$$.dispwork | \
929                     head -1 | awk '{print $3}')
930         r3db=$(grep "database kernel" /tmp/sysinfo.$$.dispwork | \
931                     awk '{print $4}')
932         r3dbver=$(grep "database kernel" /tmp/sysinfo.$$.dispwork | \
933                     awk '{print $5}')
934
935         print "  Instance ID     = $inst_id"         >> /tmp/sysinfo.$$.sap
936         print "  Instance Name   = ${INSTANCE_NAME}" >> /tmp/sysinfo.$$.sap
937         print "  SAP System Name = ${SID}" >> /tmp/sysinfo.$$.sap
938         print "  R/3 Kernel Vers = ${r3kernel}"      >> /tmp/sysinfo.$$.sap
939         print "  R/3 Patch Level = ${r3patch}"       >> /tmp/sysinfo.$$.sap
940         print "  R/3 DB Vendor   = ${r3db}"          >> /tmp/sysinfo.$$.sap
941         print "  R/3 DB Version  = ${r3dbver}"       >> /tmp/sysinfo.$$.sap
942         print "  SAP adm user    = ${SAP_ADM}"       >> /tmp/sysinfo.$$.sap
943         print "  startsap        = ${startsap}"      >> /tmp/sysinfo.$$.sap
944         print "  sapstart        = ${sapstart}"      >> /tmp/sysinfo.$$.sap
945         print "  Profile Dir     = ${PROFILE_DIR}"   >> /tmp/sysinfo.$$.sap
946         print "  startprofile    = ${startprofile}"  >> /tmp/sysinfo.$$.sap
947         print "  SAPDBHOST       = ${SAPDBHOST}"     >> /tmp/sysinfo.$$.sap
948         if (($DB_on_this_sys))
949         then
950           print "  DB_on_this_sys  = true" >> /tmp/sysinfo.$$.sap
951           print "    ORASID        = ${ORASID}" >> /tmp/sysinfo.$$.sap
952           print "    ORACLE_HOME   = ${ORACLE_HOME}" >> /tmp/sysinfo.$$.sap
953           print "    INITORA       = ${INITORA}" >> /tmp/sysinfo.$$.sap
954         else
955           print "  DB_on_this_sys  = false" >> /tmp/sysinfo.$$.sap
956         fi
957         print "" >> /tmp/sysinfo.$$.sap
958       done
959     fi
960   fi
961
962 }
963
964 ###############################################################################
965 # Function:    chk_ignite()
966 # Description: Check if IgniteUX is installed. If so, check for the last
967 #              completed make_recovery. Check if make_recovery -C has been
968 #              run. If so, run check_recovery and display results.
969 #
970 # Arguments:   none
971 # Returns:     none
972
973 function chk_ignite
974 {
975   Debug "  Starting chk_ignite"
976   if [[ ${osmajor} <  10 ]]
977   then
978     print "IgniteUX is not supported on less that HP-UX 10.x"
979     Debug "  Unsupported HP-UX version $osmajor"
980     break
981   fi
982   print "Checking for IgniteUX."
983   if [ -d /opt/ignite ]
984   then
985     if [ -f /opt/ignite/Version ]
986     then
987       ignite_ver=$(cat /opt/ignite/Version)
988       print "IgniteUX is installed. Version = $ignite_ver" >> \
989                    /tmp/sysinfo.$$.ignite
990     else
991       print "IgniteUX is installed. Version = N/A." \
992                 >> /tmp/sysinfo.$$.ignite
993     fi
994     if [ -f /var/opt/ignite/logs/makerec.log1 ]
995     then
996       last_make_recovery=$(grep Completed /var/opt/ignite/logs/makerec.log1)
997       if [ -z $last_make_recovery ]
998       then
999         print "WARNING (${sysname}): IGNITE make_recovery not run." >> \
1000                  /tmp/sysinfo.$$.errwarn
1001       else
1002         print "Most recent make_recovery  = ${last_make_recovery}" >> \
1003                  /tmp/sysinfo.$$.ignite
1004       fi
1005     else
1006       print "WARNING (${sysname}): IGNITE make_recovery not run or logfile deleted." \
1007               >> /tmp/sysinfo.$$.errwarn
1008     fi
1009     if [ -f /var/opt/ignite/recovery/makerec.last ]
1010     then
1011       check_recovery #> /dev/null 2>&1
1012     else
1013       print "WARNING (${sysname}): IGNITE check_recovery log not found"  \
1014               >> /tmp/sysinfo.$$.errwarn
1015     fi
1016   else
1017     print "WARNING (${sysname}): IgniteUX is NOT installed." \
1018             >> /tmp/sysinfo.$$.errwarn
1019   fi
1020   f_display_file /tmp/sysinfo.$$.ignite
1021 }
1022 ###############################################################################
1023 # Function:    chk_diags()
1024 # Description: Check the system's diagnostic software configuration.  Output
1025 #              the predictive setting if its installed. This is important info.
1026 #
1027 # Arguments:   none
1028 # Returns:     none
1029
1030 chk_diags()
1031 {
1032   Debug "  Starting Chk_Diags. OSMAJOR = $osmajor"
1033
1034   if (($HTML))
1035   then
1036     print "</PRE>"  >> /tmp/sysinfo.$$.diagnostics.info
1037     print "<A NAME='DIAGNOSTICS'></A>"  >> \
1038                /tmp/sysinfo.$$.diagnostics.info
1039     print "<H2>" >> \
1040                /tmp/sysinfo.$$.diagnostics.info
1041     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> \
1042                /tmp/sysinfo.$$.diagnostics.info
1043     print "<FONT COLOR=red>"                >> \
1044                /tmp/sysinfo.$$.diagnostics.info
1045     print "System Diagnostics Settings</H2>" >> \
1046                /tmp/sysinfo.$$.diagnostics.info
1047     print "</FONT><PRE><font size = '4'>"   >> \
1048                /tmp/sysinfo.$$.diagnostics.info
1049   else
1050     print "SYSTEM DIAGNOSTICS SETTINGS" >> \
1051                /tmp/sysinfo.$$.diagnostics.info
1052     print "==========================" >> \
1053                /tmp/sysinfo.$$.diagnostics.info
1054   fi
1055
1056   print -n "checking system diagnostics "
1057
1058   print "" >> /tmp/sysinfo.$$.diagnostics.info
1059   case $osmajor in
1060     10 | 11 )
1061 #
1062 # Look for the OnlineDiag product file. If it exists, then the product is
1063 # installed on the system. You can use the product's INDEX file to get the
1064 # product version (this can be important info).
1065 #
1066       print ".\c"
1067       prodfile=$(ls -d /var/adm/sw/products/OnlineDiag* 2>&1)
1068       Debug "Found OnlineDiag dir - ${prodfile}"
1069       if [ -d "$prodfile" ]
1070       then
1071         print -n "Online Diagnostics are Installed: " \
1072                   >> /tmp/sysinfo.$$.diagnostics.info
1073         print "Version: $(grep ^revision $prodfile/pfiles/INDEX \
1074             | awk '{print $NF}')\t\c" >> /tmp/sysinfo.$$.diagnostics.info
1075         print "Status: \c" >> /tmp/sysinfo.$$.diagnostics.info
1076 #
1077 # Now use the PS command to see if diagnostics are running.
1078 #
1079        ps -ef | grep -q diagmon
1080        if [ $? -eq 0 ]
1081        then
1082          print "Running" >> /tmp/sysinfo.$$.diagnostics.info
1083        else
1084          print "Down" >> /tmp/sysinfo.$$.diagnostics.info
1085        fi
1086        print "" >> /tmp/sysinfo.$$.diagnostics.info
1087 #
1088 # If the diagnostics software is properly installed then there should be
1089 # programs in the LIF area named ODE, MAPPER, and MAPFILE. If these values
1090 # are not present, then diags will not run from console mode.
1091 #
1092 # By checking all boot disks (obtained from lvlnboot -v), we also check
1093 # any mirrored volumes. This is good because mirrored root volumes are
1094 # often missed.
1095 #
1096        typeset -i liferrors
1097        bootdsks=$(lvlnboot -v 2>/dev/null | grep "Boot Disk" | awk '{print $1}')
1098
1099        print "Checking LIF Information (ODE, MAPPER and, MAPFILE)" >> \
1100               /tmp/sysinfo.$$.diagnostics.info
1101        print ".\c"
1102 #
1103 # Now loop for each boot disk found by lvlnboot -v. This will check mirrors
1104 # as well as primary disks. All boot disks should have diags installed.
1105 #
1106        for bdisk in $bootdsks
1107        do
1108          liferrors=0
1109          lifls -l $bdisk >> /tmp/sysinfo.$$.diagnostics.lifinfo
1110          for lfdiag in ODE MAPPER MAPFILE
1111          do
1112            grep -q $lfdiag /tmp/sysinfo.$$.diagnostics.lifinfo
1113            if [ $? -ne 0 ]
1114            then
1115              print "WARNING (${sysname}): Missing $lfdiag on ${bdisk}." \
1116                   >> /tmp/sysinfo.$$.errwarn
1117              liferrors=liferrors+1
1118            fi
1119          done
1120 #
1121 # If the liferrors variable is greater than zero then this disk was missing at
1122 # least one of the required LIF files. If its equal to zero, then this disk
1123 # has all the required info.
1124 #
1125          if [ $liferrors -eq 0 ]
1126          then
1127            print "$bdisk\tOK" >> /tmp/sysinfo.$$.diagnostics.info
1128          fi
1129         done
1130       else
1131       print "WARNING (${sysname}): Online Diagnostics are NOT Installed." >> \
1132             /tmp/sysinfo.$$.errwarn
1133       print "Online Diagnostics are NOT Installed." >> \
1134             /tmp/sysinfo.$$.diagnostics.info
1135       fi
1136 #
1137 # Now check the system product database to see if Predictive is installed. 
1138 # If it is, then output its version info, and check to see if its running 
1139 # (again using the ps command).
1140 #
1141       print ".\c"
1142       print " " >> /tmp/sysinfo.$$.diagnostics.info
1143       prodfile=$(ls -d /var/adm/sw/products/Predictive* 2>&1)
1144       Debug "Found Predictive dir - ${prodfile}"
1145       if [ -d "$prodfile" ]
1146       then
1147         print -n "Predictive is Installed: Version:" \
1148              >> /tmp/sysinfo.$$.diagnostics.info
1149         print " $(grep ^revision $prodfile/pfiles/INDEX | awk \
1150             '{print $NF}')\t\c" >> /tmp/sysinfo.$$.diagnostics.info
1151         print "Status: \c" >> /tmp/sysinfo.$$.diagnostics.info
1152         ps -ef | grep -q psmond
1153         if [ $? -eq 0 ]
1154         then
1155           print "Running" >> /tmp/sysinfo.$$.diagnostics.info
1156         else
1157           print "Down" >> /tmp/sysinfo.$$.diagnostics.info
1158         fi
1159 #
1160 # Predictive is installed. Run PSCONFIG to output the configuration info and
1161 # the recent log history. This is good documentation of the system, and shows
1162 # whether the system has been reporting problems to the response center.
1163 #
1164         print ".\c"
1165         print "" >> /tmp/sysinfo.$$.diagnostics.info
1166         print "Predictive Configuration Information" >> \
1167                      /tmp/sysinfo.$$.diagnostics.info 
1168         if [ -x /opt/pred/bin/PSCONFIG ]
1169         then
1170           print ".\c"
1171           /opt/pred/bin/PSCONFIG print configuration >> \
1172                      /tmp/sysinfo.$$.diagnostics.info 2>/dev/null
1173           print ".\c"
1174           /opt/pred/bin/PSCONFIG print action >> \
1175                      /tmp/sysinfo.$$.diagnostics.info 2>/dev/null
1176         else
1177           print "ARNING (${sysname}): PSCONFIG is not executable" >> \
1178                         /tmp/sysinfo.$$.errwarn
1179         fi
1180       else
1181         print "Predictive is NOT Installed." >> \
1182                     /tmp/sysinfo.$$.diagnostics.info
1183         print "WARNING (${sysname}): Predictive is NOT Installed." >> \
1184                     /tmp/sysinfo.$$.errwarn
1185       fi
1186     ;;
1187 #
1188 # I did not implement any code which would work with V9.x or earlier. At this
1189 # point, most customers should be at V10.x by now. V9.x is off support life.
1190 #
1191     8 | 9 )
1192       print "This module was created for V10.x and higher. Sorry."
1193     ;;
1194   esac
1195
1196   print ""
1197   print "" >> /tmp/sysinfo.$$.diagnostics.info
1198
1199   f_display_file /tmp/sysinfo.$$.diagnostics.info
1200
1201   return $return_code
1202 }
1203
1204 ###############################################################################
1205 # Function:    chk_sysaccess()
1206 # Description: Routine used to check some of the security characteristics of
1207 #              the system. This includes checking the permissions of the
1208 #              /etc/passwd, and /etc/group files as well as checking for
1209 #              .rhosts and other files.
1210 # Arguments:   none
1211 # Returns:     none
1212
1213 chk_sysaccess() {
1214   Debug "  Starting Chk_SysAccess. OSMAJOR = $osmajor"
1215
1216   if (($HTML))
1217   then
1218     print "</PRE>"  >> /tmp/sysinfo.$$.sysaccess.info
1219     print "<A NAME='SYSACCESS'></A>" >> /tmp/sysinfo.$$.sysaccess.info
1220     print "<H2>"    >> /tmp/sysinfo.$$.sysaccess.info
1221     print "<P ALIGN=RIGHT><A HREF='#Top'>" >> /tmp/sysinfo.$$.sysaccess.info
1222     print "TOP</A></P>" >> /tmp/sysinfo.$$.sysaccess.info
1223     print "<FONT COLOR=red>" >> /tmp/sysinfo.$$.sysaccess.info
1224     print "System Security Audit</H2>" >> /tmp/sysinfo.$$.sysaccess.info
1225     print "</FONT><PRE><font size = '4'>" >> /tmp/sysinfo.$$.sysaccess.info
1226   else
1227     print "SYSTEM SECURITY AUDIT" >> /tmp/sysinfo.$$.sysaccess.info
1228     print "==========================" >> /tmp/sysinfo.$$.sysaccess.info
1229   fi
1230
1231   last -R > /tmp/sysinfo.$$.last 
1232   print -n "checking system security "
1233   print "" >> /tmp/sysinfo.$$.sysaccess.info
1234
1235   print "File Permissions. Files which should be World and Group Read-Only." \
1236            >>  /tmp/sysinfo.$$.sysaccess.info
1237
1238   for lfile in $WORLDREADFILES
1239   do
1240     Debug "   chk_SysAccess. Checking $lfile."
1241     if [[ ! -a "$lfile" ]]
1242     then
1243       print "ERROR ($sysname): Important file $lfile does not exist." >> \
1244               /tmp/sysinfo.$$.errwarn
1245       return_code=$ERROR
1246     else
1247 #
1248 # Get the important file's directory information.
1249 #
1250       llinfo=$(ll -d $lfile)
1251 #
1252 # Now check the file's permissions
1253 #
1254       echo "$llinfo" | cut -c5-10 | egrep -q "w"
1255       if [ $? -eq 0 ]
1256       then
1257         print "WARNING ($sysname): Important file $lfile has Group or World WRITE access.  " >> /tmp/sysinfo.$$.errwarn
1258         return_code=$WARN
1259       fi
1260     echo "$llinfo" >> /tmp/sysinfo.$$.sysaccess.info
1261     fi
1262   done
1263 #
1264 # Now check the system for files/directories which should be accessible to
1265 # root only. This code will flag files which have any access other than the
1266 # owner.
1267 #
1268   print "" >> /tmp/sysinfo.$$.sysaccess.info
1269   print "File Permissions. Files which should be Accessible to Root only." >> \
1270              /tmp/sysinfo.$$.sysaccess.info
1271
1272   for lfile in $NOREADFILES
1273   do
1274     Debug "   chk_SysAccess. Checking $lfile."
1275     if [[ ! -a "$lfile" ]]
1276     then
1277       print "WARNING ($sysname): Important file $lfile does not exist." >> \
1278                /tmp/sysinfo.$$.errwarn
1279       return_code=$WARN
1280     else
1281 #
1282 # Get the Important file's directory information.
1283 #
1284       llinfo=$(ll -d $lfile)
1285 #
1286 # Now check the file's permissions
1287 #
1288       echo "$llinfo" | cut -c5-10 | egrep -q "r|w|x"
1289       if [ $? -eq 0 ]
1290       then
1291         print "WARNING ($sysname): Important file $lfile has Group or World access." \
1292                 >> /tmp/sysinfo.$$.errwarn
1293         return_code=$WARN
1294       fi
1295       echo "$llinfo" >> /tmp/sysinfo.$$.sysaccess.info
1296     fi
1297   done
1298
1299   print "" >> /tmp/sysinfo.$$.sysaccess.info
1300   print "Check for Important Audit Files:" >> /tmp/sysinfo.$$.sysaccess.info
1301 #
1302 # Now check for the wtmp and btmp files. These are important to login history.
1303 # make sure they exist, if not, then give a warning. then check their security.
1304 # The wtmp file tracks login history. The btmp file tracks invalid logons.
1305 #
1306 # Also check the sulog file. This file tracks the history of SU'ing to root.
1307 #
1308   case $osmajor in
1309     8 | 9 )
1310       WTMP="/etc/wtmp"
1311       BTMP="/etc/btmp"
1312       SULOG="/usr/adm/sulog"
1313     ;;
1314
1315     * )
1316       WTMP="/var/adm/wtmp"
1317       BTMP="/var/adm/btmp"
1318       SULOG="/var/adm/sulog"
1319     ;;
1320   esac
1321 #
1322 # Check the wtmp file
1323 #
1324   if [[ ! -a "$WTMP" ]]
1325   then
1326     print "WARNING ($sysname): Audit File $WTMP does not exist." >> \
1327                 /tmp/sysinfo.$$.errwarn
1328     print "If you create $WTMP you can track logon history." >> \
1329                 /tmp/sysinfo.$$.errwarn
1330     print " " >> /tmp/sysinfo.$$.errwarn
1331   else
1332     llinfo=$(ll -d $WTMP)
1333
1334     echo "$llinfo" | cut -c8-10 | egrep -q "w"
1335     if [ $? -eq 0 ]
1336     then
1337       print -n "WARNING ($sysname): Audit File $WTMP has Group or " >> \
1338                   /tmp/sysinfo.$$.errwarn
1339       print "World WRITE access." >> /tmp/sysinfo.$$.errwarn
1340       print "   $WTMP should have at most World read access." >> \
1341                   /tmp/sysinfo.$$.errwarn
1342       print " " >> /tmp/sysinfo.$$.errwarn
1343     fi
1344     echo "$llinfo" >> /tmp/sysinfo.$$.sysaccess.info
1345   fi
1346 #
1347 # Now check the btmp file.
1348 #
1349   if [[ ! -a "$BTMP" ]]
1350   then
1351     print "WARNING ($sysname): Audit File $BTMP does not exist." >> \
1352                /tmp/sysinfo.$$.errwarn
1353     print "If you create $BTMP you can track invalid logon history." >> \
1354                /tmp/sysinfo.$$.sysaccess.warn
1355     print " " >> /tmp/sysinfo.$$.sysaccess.warn
1356   else
1357     llinfo=$(ll -d $BTMP)
1358
1359     echo "$llinfo" | cut -c5-10 | egrep -q "w"
1360     if [ $? -eq 0 ]
1361     then
1362       print -n "WARNING ($sysname): Audit File $BTMP has Group or ">> \
1363                   /tmp/sysinfo.$$.errwarn
1364       print "World WRITE access." >> /tmp/sysinfo.$$.errwarn
1365       print "$BTMP should have at most Group or World read access." >> \
1366                   /tmp/sysinfo.$$.errwarn
1367       print " " >> /tmp/sysinfo.$$.errwarn
1368     fi
1369
1370     echo "$llinfo" >> /tmp/sysinfo.$$.sysaccess.info
1371   fi
1372 #
1373 # Check the sulog file now.
1374 #
1375   if [[ ! -a "$SULOG" ]]
1376   then
1377     print "WARNING ($sysname): Audit File $SULOG does not exist." >> \
1378         /tmp/sysinfo.$$.errwarn
1379     print "If you create $SULOG you can track su logon history." >> \
1380          /tmp/sysinfo.$$.sysaccess.warn
1381     print " " >> /tmp/sysinfo.$$.sysaccess.warn
1382   else
1383     llinfo=$(ll -d $SULOG)
1384
1385     echo "$llinfo" | cut -c5-10 | egrep -q "w"
1386     if [ $? -eq 0 ]
1387     then
1388       print -n "WARNING ($sysname): Audit File $SULOG has Group or " >> \
1389                    /tmp/sysinfo.$$.errwarn
1390       print "World WRITE access." >> /tmp/sysinfo.$$.sysaccess.warn
1391       print "$SULOG should have at most Group or World read access." >> \
1392                   /tmp/sysinfo.$$.sysaccess.warn
1393       print " " >> /tmp/sysinfo.$$.sysaccess.warn
1394     fi
1395
1396     echo "$llinfo" >> /tmp/sysinfo.$$.sysaccess.info
1397     print " " >> /tmp/sysinfo.$$.sysaccess.info
1398     print "Five Most Recent SUlog entries:" >> /tmp/sysinfo.$$.sysaccess.info
1399     tail -5 $SULOG >> /tmp/sysinfo.$$.sysaccess.info
1400   fi
1401 #
1402 # Check the validity of the /etc/passwd and /etc/group files by running
1403 # the pwck and grpck commands. This will help identify illegal password and
1404 # group entries. Also, check the /etc/passwd file for entries missing
1405 # passwords.
1406 #
1407   if [[ -x "/etc/pwck" ]]
1408   then
1409     print " " >> /tmp/sysinfo.$$.sysaccess.info
1410     print "Running Passwd Check Script:" >> /tmp/sysinfo.$$.sysaccess.info
1411     /etc/pwck >> /tmp/sysinfo.$$.sysaccess.info 2>&1
1412   fi
1413 #
1414 # Check the password file for entries w/o a password.
1415 #
1416   awk -F: -v sysname=$sysname ' $2 == "" { printf("\nERROR. (%s).  NULL Password found in /etc/passwd\nPassword Record = %s\n\n",sysname,$0)}' /etc/passwd >> \
1417              /tmp/sysinfo.$$.errwarn 2>&1
1418
1419   if [[ -x "/etc/grpck" ]]
1420   then
1421     print " " >> /tmp/sysinfo.$$.sysaccess.info
1422     print "Running Group Check Script:" >> /tmp/sysinfo.$$.sysaccess.info
1423     /etc/grpck >> /tmp/sysinfo.$$.sysaccess.info 2>&1
1424
1425   fi
1426 #
1427 # Now check for an .rhost file definition for root.
1428 # If this file exists, then print a message since this is a potential security
1429 # issue.
1430 #
1431   if [[ -a "/.rhosts" ]]
1432   then
1433     print "WARNING ($sysname): Root has a /.rhosts file." >> \
1434                /tmp/sysinfo.$$.errwarn
1435     print "This file allows users from other systems to logon as root w/o a password." >> /tmp/sysinfo.$$.errwarn
1436     print " " >> /tmp/sysinfo.$$.errwarn
1437
1438     llinfo=$(ll -d /.rhosts)
1439
1440     echo "$llinfo" | cut -c5-10 | egrep -q "r|w|x"
1441     if [ $? -eq 0 ]
1442     then
1443       print "WARNING ($sysname): The /.rhosts file has Group or World access." \
1444              >> /tmp/sysinfo.$$.errwarn
1445       print "If this existence if this file is required then ONLY root should have access." >> /tmp/sysinfo.$$.errwarn
1446       print " " >> /tmp/sysinfo.$$.errwarn
1447     fi
1448
1449     echo "$llinfo" >> /tmp/sysinfo.$$.sysaccess.warn
1450     print "" >> /tmp/sysinfo.$$.sysaccess.warn
1451     print "Contents of /.rhosts file:" >> /tmp/sysinfo.$$.sysaccess.warn
1452     cat /.rhosts >> /tmp/sysinfo.$$.sysaccess.warn
1453   fi
1454 #
1455 # Now check the system for modem definitions. This first pass will not include
1456 # uucp items. I'm checking for ttyd* files in the /dev directory, then I'll
1457 # campare any matches to the /etc/inittab file. This will allow me to
1458 # look for getty processes.
1459 #
1460   print " " >> /tmp/sysinfo.$$.sysaccess.info
1461   print "Dialin/Modem Definitions:" >> /tmp/sysinfo.$$.sysaccess.info
1462   print " " >> /tmp/sysinfo.$$.sysaccess.info
1463
1464   MLIST=$(ls /dev/ttyd*  2>&1)
1465
1466   Debug "  chk_SysAccess. MLIST = $MLIST"
1467   for modtty in $MLIST
1468   do
1469     modttyb=$(basename $modtty)
1470     Debug "  chk_SysAccess. Checking = $modtty"
1471 #
1472 # Check the /etc/inittab file for the terminal entry. Exclude lines which
1473 # begin with a '#'. Include lines which contain 'getty'
1474 #
1475     gettyinfo=$( grep -v '^#' /etc/inittab | grep 'getty' | grep -i $modttyb )
1476     gettystate=$( echo $gettyinfo | awk -F: '{print $3}' )
1477
1478     Debug "  chk_SysAccess. Getty Info/State = $gettyinfo $gettystate"
1479     case $gettystate in
1480       respawn )
1481         Debug " chkSysAccess. Respawn in getty"
1482         ps -ef | grep getty | grep -q $modttyb
1483         if [ $? -eq 0 ]
1484         then
1485           Debug "Found Getty for $modttyb"
1486           print "Modem: $modttyb (waiting for a connection)" >> \
1487              /tmp/sysinfo.$$.sysaccess.info
1488         else
1489           Debug "No Getty Found for $modttyb"
1490           if ps -t $modttyb | tail +2 | wc -l
1491           then
1492             Debug "No Processes Found for $modttyb"
1493             print "Modem: $modttyb (getty missing?)" >> \
1494                     /tmp/sysinfo.$$.sysaccess.info
1495             print "WARNING ($sysname): $modttyb does not have a getty or a login process" >> /tmp/sysinfo.$$.errwarn
1496           else
1497             Debug "Modem in Use"
1498             print "Modem: $modttyb (currently in use)" >> \
1499                      /tmp/sysinfo.$$.sysaccess.info
1500           fi
1501         fi
1502
1503         echo $gettyinfo | awk -F: '{printf("Inittab Info: %s\n",$4)}' >> \
1504               /tmp/sysinfo.$$.sysaccess.info
1505         print " " >> /tmp/sysinfo.$$.sysaccess.info
1506         print "Five most recent Logons for $modttyb" >> \
1507                  /tmp/sysinfo.$$.sysaccess.info
1508         #last -R > /tmp/sysinfo.$$.last
1509         grep -i $modttyb /tmp/sysinfo.$$.last | tail -5 >> /tmp/sysinfo.$$.sysaccess.info
1510         print " " >> /tmp/sysinfo.$$.sysaccess.info
1511       ;;
1512
1513       off )
1514         print "Modem: $modttyb (disabled in /etc/inittab)" >> \
1515                     /tmp/sysinfo.$$.sysaccess.info
1516       ;;
1517
1518       * )
1519       ;;
1520     esac
1521   done
1522   print " "
1523
1524   print " " >> /tmp/sysinfo.$$.sysaccess.info
1525
1526   f_display_file /tmp/sysinfo.$$.sysaccess.info
1527   f_display_file /tmp/sysinfo.$$.sysaccess.warn
1528
1529   return $return_code
1530 }
1531
1532
1533 ###############################################################################
1534 # Function:    chk_logfiles()
1535 # Description: Routine used to check the system logfiles. We want to make sure
1536 #              that the logfiles exist, and are not greater than 2 Mbytes.
1537 # Arguments:   none
1538 # Returns:     none
1539
1540 chk_logfiles() {
1541   Debug "  Starting Chk_Logfiles. OSMAJOR = $osmajor"
1542
1543   case $osmajor in
1544     8 | 9 )
1545       FLIST="$LOGFILELISTV9"
1546     ;;
1547
1548     * )
1549       FLIST="$LOGFILELISTV10"
1550     ;;
1551   esac
1552
1553   Debug " chk_logfiles. FLIST=$FLIST"
1554   if (($HTML))
1555   then
1556     print "</PRE>"  >> /tmp/sysinfo.$$.logfile.info
1557     print "<A NAME='LOGFILES'></A>" >> /tmp/sysinfo.$$.logfile.info
1558     print "<H2>"    >> /tmp/sysinfo.$$.logfile.info
1559     print "<P ALIGN=RIGHT><A HREF='#Top'>" >> /tmp/sysinfo.$$.logfile.info
1560     print "TOP</A></P>" >> /tmp/sysinfo.$$.logfile.info
1561     print "<FONT COLOR=red>" >> /tmp/sysinfo.$$.logfile.info
1562     print "System Logfile Information</H2>" >> /tmp/sysinfo.$$.logfile.info
1563     print "</FONT><PRE><font size = '4'>"  >> /tmp/sysinfo.$$.logfile.info
1564   else
1565     print "SYSTEM LOGFILE INFORMATION" >> /tmp/sysinfo.$$.logfile.info
1566     print "==========================" >> /tmp/sysinfo.$$.logfile.info
1567   fi
1568   print -n "checking system logfiles"
1569   print "" >> /tmp/sysinfo.$$.logfile.info
1570   print "Checking System Logfiles. Validating file sizes and Permissions." >> \
1571               /tmp/sysinfo.$$.logfile.info
1572
1573   for lfile in $FLIST
1574   do
1575     Debug "   chk_logfiles. Checking $lfile."
1576     if [[ ! -a "$lfile" ]]
1577     then
1578       print "ERROR ($sysname): Logfile $lfile does not exist." >> \
1579          /tmp/sysinfo.$$.errwarn
1580       return_code=$ERROR
1581     else
1582 #
1583 # Get the logfile's directory information. Then check its size.
1584 #
1585       llinfo=$(ll -d $lfile)
1586
1587       psize=$( echo $llinfo | awk '{print $5}' )
1588       if (( $psize >= 2097152 ))
1589       then
1590         print "WARNING ($sysname): Logfile $lfile is greater than 2 Mbytes." \
1591           >> /tmp/sysinfo.$$.errwarn
1592         return_code=$WARN
1593       fi
1594 #
1595 # Now check the file's permissions
1596 #
1597       echo "$llinfo" | cut -c5-10 | egrep -q "w"
1598       if [ $? -eq 0 ]
1599       then
1600         print "WARNING ($sysname): Logfile $lfile has Group or World WRITE access.  " >> /tmp/sysinfo.$$.errwarn
1601         return_code=$WARN
1602       fi
1603       echo "$llinfo" >> /tmp/sysinfo.$$.logfile.info
1604     fi
1605   done
1606
1607   print " " >> /tmp/sysinfo.$$.logfile.info
1608 #
1609 # Now check the system's crash directory for crash files. If these files exist
1610 # there could be space problems later.
1611 #
1612   case $osmajor in
1613     10 | 11 )
1614       if [[ -a "/etc/rc.config.d/savecrash" ]]
1615       then
1616         . /etc/rc.config.d/savecrash
1617         if [ ! -z "$CRASHDIR" ]
1618         then
1619           LOGCRASH=$CRASHDIR
1620         else
1621           LOGCRASH="/var/adm/crash"
1622         fi
1623       else
1624         LOGCRASH="/var/adm/crash"
1625       fi
1626
1627       CRASHFILES=$(ll $LOGCRASH | tail +2)
1628       if [ -z "$CRASHFILES" ]
1629       then
1630         print "There are NO Crash Dumps in $LOGCRASH." >> \
1631                    /tmp/sysinfo.$$.logfile.info
1632       else
1633         print " " >> /tmp/sysinfo.$$.logfile.warn
1634         print "WARNING ($sysname): There are files in the Crash Dump directory $LOGCRASH." >> /tmp/sysinfo.$$.errwarn
1635         echo "$CRASHFILES" >> /tmp/sysinfo.$$.errwarn
1636       fi
1637     ;;
1638
1639   * )
1640     ;;
1641   esac
1642 #
1643 # Now output the contents of the DMESG command. This can provide useful
1644 # info regarding recent events on the system.
1645 #
1646   print " " >> /tmp/sysinfo.$$.logfile.info
1647   print "Ouput of System DMESG Info:" >> /tmp/sysinfo.$$.logfile.info
1648   print "___________________________" >> /tmp/sysinfo.$$.logfile.info
1649
1650   dmesg >> /tmp/sysinfo.$$.logfile.info 2>&1
1651
1652   print " " >> /tmp/sysinfo.$$.logfile.info
1653   print "End of DMESG Output" >> /tmp/sysinfo.$$.logfile.info
1654   print "___________________________" >> /tmp/sysinfo.$$.logfile.info
1655   print " " >> /tmp/sysinfo.$$.logfile.info
1656 #
1657 # Now check the Sendmail Queue for a large number of entries, or entries
1658 # which are older than two days. Finding entries in the queue could represent
1659 # a problem.
1660 #
1661   print " " >> /tmp/sysinfo.$$.logfile.info
1662   print "Checking Sendmail Queue: \c" >> /tmp/sysinfo.$$.logfile.info
1663 #
1664 # Before changing to the Sendmail Queue directory, save our current directory
1665 # value so we can change back to it when we're finished.
1666 #
1667   OLDPWD=$(pwd)
1668   case $osmajor in
1669     8 | 9 )
1670       mailqdir=/usr/spool/mqueue
1671       mailpodir=/usr/mail
1672     ;;
1673
1674     * )
1675       mailqdir=/var/spool/mqueue
1676       mailpodir=/var/mail
1677     ;;
1678   esac
1679 #
1680 # Go to the Sendmail Queue directory and scan it for entries. Iff some are
1681 # found then check to see if any are older than 2 days.
1682 #
1683   cd $mailqdir
1684   llinfo=$(ll 2>&1 | tail +2)
1685
1686   if [[ -z "$llinfo" ]]
1687   then
1688     print "Sendmail Queue is Empty." >> /tmp/sysinfo.$$.logfile.info
1689   else
1690     print "Sendmail Queue has $(ls | wc -w | awk '{print $1}') entries." >> \
1691             /tmp/sysinfo.$$.logfile.info
1692     ll 2>&1 | tail +2 >> /tmp/sysinfo.$$.logfile.info
1693 #
1694 # Use the find command to list entries older than 2 days
1695 #
1696     findinfo=$(find . -mtime +2 -exec ll -d {} \;)
1697     if [[ ! -z "$findinfo" ]]
1698     then
1699       print " " >> /tmp/sysinfo.$$.logfile.warn
1700       print "Sendmail Queue has Entries Older than 2 days." >> \
1701                 /tmp/sysinfo.$$.logfile.warn
1702       find . -mtime +2 -exec ll -d {} \; >> /tmp/sysinfo.$$.logfile.warn
1703       print " " >> /tmp/sysinfo.$$.logfile.warn
1704     fi
1705   fi
1706 #
1707 # Now change to the Sendmail Post Office directory. This is the directory
1708 # where mail is normally stored on the system. Check for entries which are
1709 # large and very old.
1710 #
1711   cd $mailpodir
1712   print " " >> /tmp/sysinfo.$$.logfile.info
1713   print "Checking the Mail Post Office Directory: \c" >> \
1714               /tmp/sysinfo.$$.logfile.info
1715
1716   llinfo=$(ls 2>&1)
1717   if [[ -z "$llinfo" ]]
1718   then
1719     print "No Entries Found." >> /tmp/sysinfo.$$.logfile.info
1720   else
1721     print "Found $(echo $llinfo | wc -w) Entries." >> \
1722                /tmp/sysinfo.$$.logfile.info
1723     ll 2>&1 >> /tmp/sysinfo.$$.logfile.info
1724 #
1725 # Now that we have found entries in the directory, check to see if they are
1726 # larger than 2 Mbytes.
1727 #
1728     find . -size +4096 -exec ll -d {} \; > /tmp/sysinfo.$$.logfile.tmp 2>&1
1729     if [[ -s "/tmp/sysinfo.$$.logfile.tmp" ]]
1730     then
1731       print " " >> /tmp/sysinfo.$$.logfile.warn
1732       print "WARNING ($sysname): Post Office Directory has Files Larger than 2 Mbytes." >> /tmp/sysinfo.$$.errwarn
1733       cat /tmp/sysinfo.$$.logfile.tmp >> /tmp/sysinfo.$$.errwarn
1734       print " " >> /tmp/sysinfo.$$.errwarn
1735     fi
1736 #
1737 # Now check for entries which have not been access in 90 days. These files
1738 # may be considered obsolete.
1739 #
1740     find . -mtime +90 -exec ll -d {} \; > /tmp/sysinfo.$$.logfile.tmp 2>&1
1741     if [[ -s "/tmp/sysinfo.$$.logfile.tmp" ]]
1742     then
1743       print " " >> /tmp/sysinfo.$$.logfile.warn
1744       print "WARNING ($sysname): Post Office Directory has Files Older than 90 days." >> /tmp/sysinfo.$$.errwarn
1745       cat /tmp/sysinfo.$$.logfile.tmp >> /tmp/sysinfo.$$.errwarn
1746       print " " >> /tmp/sysinfo.$$.errwarn
1747     fi
1748   fi
1749 #
1750 # Change back to our original directory
1751 #
1752   cd $OLDPWD
1753
1754   print " " >> /tmp/sysinfo.$$.logfile.info
1755   print " "
1756
1757   f_display_file /tmp/sysinfo.$$.logfile.info
1758   f_display_file /tmp/sysinfo.$$.logfile.warn
1759
1760   return $return_code
1761 }
1762
1763
1764
1765 ################################################################################
1766 # Function:    LookupName()
1767 # Description: Lookup the full name for a specified hostname.  Uses nslookup.
1768 # Arguments:   <hostname, domainname or address>
1769 # Output:      fully qualified hostname
1770 # Returns:     0: successfully determined name
1771 #              1: unable to find name (using /etc/hosts)
1772 #              2: unable to find name (using name server)
1773
1774 LookupName() {
1775
1776 #   if [ $# -ne 1 ]
1777 #   then
1778 #       Panic "${0}: expect <hostname|address> argument"
1779 #   fi
1780
1781     #nslookup "$1" > $_TMP 2>&1
1782     # Return 0 if name found, 1 if not found and using /etc/hosts,
1783     # 2 if not found and using some sort of name server.
1784     #
1785     nslookup "$1" 2>&1 | 
1786     awk '
1787          BEGIN              { ret_val=2 }
1788          $0 ~ "/etc/hosts"  { ret_val=1 }
1789          $1 == "Name:"      { print $2; ret_val=0 }
1790          END                { exit (ret_val) }
1791         ' $_TMP
1792     return_value=$?
1793     case $return_value in
1794       0)  return_string="found using nslookup";;
1795       1)  return_string="found in /etc/hosts/";;
1796       2)  return_string="not found";;
1797     esac
1798     Debug "  return from LookupName = $return_value ($return_string)"
1799     return $return_value
1800
1801 }
1802
1803 ################################################################################
1804 # GetCurrentDNS()
1805 GetCurrentDNS() {
1806
1807 ### Changed 6/16/99 J.Semroc - allows for possibility of multiple nameservers,
1808 ###                            domain search directive, and possibility that
1809 ###                            no domain is specified
1810 ### <ST> 07/12/99 - added -s option to cut in case nslookup does not return
1811 ###          fully qualified name.  
1812 ###          added ^ to nameserver to ignore commented entries
1813
1814     if [ -f $RESOLV_CONF ]
1815     then
1816       CURRENT_DOMAIN=$(nslookup ${sysname} | grep "^Name: " | \
1817             awk -F: '{print $2}'| cut -s -d. -f2- )
1818       if [[ -z ${CURRENT_DOMAIN} ]]
1819       then
1820         Debug "Could not find domain using nslookup - checking resolv.conf"
1821 # Extract the domain from resolv.conf
1822         set -- $(awk '
1823           $1 == "domain"     { DOMAIN=$2 }
1824           $1 == "nameserver" { ADDRESS=$2 ; exit }
1825           END { printf "%s %s\n", DOMAIN, ADDRESS }' $RESOLV_CONF)
1826         CURRENT_DOMAIN="$1"
1827       else
1828         Debug "Found domain using nslookup"
1829       fi
1830
1831 ### Extract the  address and name of nameserver from resolv.conf
1832 ###     if [ $# -eq 2 ]
1833 ###     then
1834 ###         # See if we can get a name for the nameserver
1835 ###         CURRENT_DOMAIN="$1"
1836 ###         CURRENT_DNS_SERVER_IP="$2"
1837 ###         CURRENT_DNS_SERVER=$(LookupName $CURRENT_DNS_SERVER_IP)
1838 ###         if [ -z "$CURRENT_DNS_SERVER" ]
1839 ###         then
1840 ###             CURRENT_DNS_SERVER=unknown
1841 ###         fi
1842 ###     else
1843 ###         unset CURRENT_DOMAIN CURRENT_DNS_SERVER_IP CURRENT_DNS_SERVER
1844 ###    fi
1845
1846       CURRENT_DNS_SERVER_IP=$(for server in `grep ^nameserver \
1847               ${RESOLV_CONF} | awk '{print $2}'`
1848                do
1849                   print -n $server"  "
1850                done | awk '{ print $1}')
1851       CURRENT_DNS_SERVER=$(LookupName `echo ${CURRENT_DNS_SERVER_IP} \
1852               | awk '{ print $1}' `)
1853     fi
1854
1855 }
1856
1857 #===================================================================
1858 # weed_targets
1859 #
1860 # Scan the output from ioscan and filter out all SCSI "target"
1861 # lines.  Also filter out entries with a low_level driver of "root"
1862 #===================================================================
1863 weed_targets()
1864 {
1865     awk -F: '
1866         {
1867             class  = $9;
1868             low_level_driver = $10
1869             if (class != "target" && low_level_driver != "root")
1870                 print $0
1871         }' -
1872 }
1873
1874
1875 #==================================================================
1876 # This routine invokes ioscan with any passed in arguments and
1877 # generates the above mentioned colon separated output. Note that
1878 # all lines begin and end with colons. This makes for easy parsing
1879 # of the output to match specific fields via grep.
1880 #===================================================================
1881 formatter()
1882 {
1883     awk -F: '
1884         {
1885 #=====================================================================
1886 # Not all of the fields of ioscan output are used by SAM.
1887 # They are all listed here for documentation purposes.
1888 #=====================================================================
1889 #       bus_type               = $1
1890         cdio                   = $2
1891 #       is_block               = $3
1892 #       is_char                = $4
1893 #       is_pseduo              = $5
1894 #       block_major_number     = $6
1895 #       character_major_number = $7
1896 #       minor_number           = $8
1897         class                  = $9
1898 #       low_level_driver       = $10
1899         full_hw                = $11
1900         identify_bytes         = $12
1901 #       device instance        = $13
1902 #       module_path            = $14
1903         driver                 = $15
1904         sw_status              = $16
1905 #       hardware_type          = $17
1906         ident                  = $18
1907         instance               = $19
1908         num_hw   = split(full_hw, hw_path, ".");
1909         address = "";
1910         unit    = "";
1911 #============================================================
1912 #
1913 # Identifying bytes for PA Modules contain this information:
1914 #
1915 #  Byte
1916 #  Address   Name            Description
1917 #  --------- --------------- --------------------------------------
1918 #  0-1       IODC_HVERSION   Hardware version number
1919 #  2         IODC_SPA        Soft physical address capability
1920 #  3         IODC_TYPE       Type of module
1921 #  4-7       IODC_SVERSION   Software version number
1922 #  8         IODC_REV        IODC revision
1923 #  9         IODV_DEP        HVERSION dependent
1924 #  10-11     RESERVED
1925 #  12-13     IODC_CHECK      Checksum
1926 #  14-15     IODC_LENGTH     Length of entry point table
1927 #
1928 #============================================================
1929
1930         split(identify_bytes, id_flds, " ");
1931         hversion= (((((id_flds[1]*256)+id_flds[2])*256)+id_flds[3])*256)+id_flds[4];
1932         sversion= (((((id_flds[5]*256)+id_flds[6])*256)+id_flds[7])*256)+id_flds[8];
1933         if ( id_flds[9] != "" ) {
1934                 device_id = id_flds[9] " " id_flds[10] " " id_flds[11] " " id_flds[12] " " id_flds[13] " " id_flds[14] " " id_flds[15] " " id_flds[16];
1935         }
1936         else {
1937                 device_id = "";
1938         }
1939         #
1940         # Specifically for multi path environments (FiberChannel),
1941         # save the driver and last 8 bytes of the identify_bytes
1942         # of this device ("ext_bus" class; parent of actual devices)
1943         # tacking on to actual devices later.
1944         #
1945         if ( class == "ext_bus") {
1946            if ( ( identify_bytes != "") && (( driver == "fcpmux") || ( driver == "fcpdev"))) {
1947                 parent_driver = driver;
1948                 parent_id = device_id;
1949            }
1950            else {
1951                 parent_driver=""
1952                 parent_id=""
1953            }
1954         }
1955
1956         #
1957         # Set driver to "?" if not known
1958         #
1959         if ((substr(driver, 1, 1) == "?") || (driver == "pdn0") ||
1960             (driver == ""))
1961         {
1962             #
1963             # SPECIAL CASES FOR NON-AUTOCONFIGURABLE DEVICES
1964             # Check the hardware identifier field, if it matches
1965             # a non-autoconfigurable device and there is no driver
1966             # bound to the device, fill in the driver field with the
1967             # appropriate driver name flag to true
1968             #
1969 #
1970 # Change this to use the device description.
1971 #
1972             if (ident == "0x2080") {
1973                 driver = "pdn0";
1974             }
1975 #
1976 # Change this to use the device description.
1977 #
1978             else if (ident == "0x2f80") {
1979                 driver = "pdn0";
1980             }
1981
1982             else if ((substr(driver, 1, 1) == "?") || (driver == "")) {
1983                 driver = "?";
1984             }
1985
1986             not_configured = 1;
1987         } else
1988             not_configured = 0;
1989
1990         if (sw_status != "CLAIMED")
1991                 not_configured = 1;
1992
1993         if ((driver == "tape1") || (driver == "tape2")      ||
1994             (driver == "lpr0")  || (driver == "lpr1")       ||
1995             (driver == "disc3") || (driver == "sflop")      ||
1996             (driver == "schgr") || (driver == "autox0")     ||
1997             (driver == "cs80")  || (driver == "sdisk")      ||
1998             (driver == "stape") || (driver == "disc4")) {
1999           address = hw_path[num_hw-1];
2000           unit    = hw_path[num_hw];
2001         }
2002         else if ((driver == "disc1") || (driver == "disc2") ||
2003                  (driver == "instr0")|| (driver == "pflop")) {
2004           address = hw_path[num_hw];
2005         }
2006
2007
2008 #       printf(":%s:%s:%s:%s:%s:%s:%d:%s:0x%x;0x%x:%s:%s:%s:%s:\n",
2009 #           cdio, driver, instance, full_hw, address, unit,
2010 #           not_configured, sw_status, sversion, hversion, ident,
2011 #           device_id, parent_driver, parent_id );
2012         printf("%22s %12s  %s\n", full_hw, driver, ident );
2013     }' -
2014 } # end of formatter
2015
2016 #===========================================================
2017 # lvm_scan
2018 #===========================================================
2019 function lvm_scan
2020 {
2021   # first get all volume groups, logical volumes & physical volumes
2022   vgdisplay -v 2>&1 | \
2023   awk '
2024     BEGIN             { vgprinted = ""; onpvg = ""; numpvgs = 0
2025                       }
2026     /^VG Name/        {
2027                           vg = substr($3, 6, length($3) - 5);
2028                           vgprinted = ""; onpvg = ""; numpvgs = 0;
2029                           freepe_count = 0; next;
2030                       }
2031     /VG Write Access/ {
2032                            vgwrite = $4;
2033                            next;
2034                       }
2035     /VG Status/       {
2036                          vgstatus = "";
2037                          for(i=3;i<=NF;i++)
2038                             vgstatus = vgstatus $i;
2039                          vgstatus = vgstatus "," vgwrite "@";
2040                            next;
2041                      }
2042     $2 == "Server"   {
2043                          vgstatus = vgstatus $1;
2044                            next;
2045                      }
2046     $2 == "Client"   {
2047                          vgstatus = vgstatus ",";
2048                          vgstatus = vgstatus $1;
2049                            next;
2050                      }
2051     /Max LV/         { maxlv = $3; next;  }
2052     /Max PV/         { maxpv = $3; next;  }
2053     /Cur LV/         { numlvs = $3; next; }
2054     /Cur PV/         { numpvs = $3; next; }
2055     /PE Size/        { pesize = $4; next; }
2056     /Max PE per PV/  { maxpe = $5; next;  }
2057     /Total PVG/      { numpvgs = $3; next; }
2058     /LV Name/        {
2059                        if (vgprinted == "")
2060                        {
2061                          printf("VG:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s::::::\n",
2062                                  vg, vgstatus, maxlv, maxpv, numlvs,
2063                                  numpvs, numpvgs, pesize, maxpe,
2064                                  totalpe * pesize, freepe * pesize);
2065                          vgprinted = "y";
2066                        }
2067                        printf("LV:%s:::::::%s::::%s:::::\n",
2068                                vg, pesize, $3);
2069                        next;
2070                      }
2071     /Alternate Link$/ {
2072                        if (onpvg == "")
2073                        {
2074                          if (vgprinted == "")
2075                          {
2076                            printf("VG:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s::::::\n",
2077                                    vg, vgstatus, maxlv, maxpv, numlvs,
2078                                    numpvs, numpvgs, pesize, maxpe,
2079                                    totalpe * pesize, freepe * pesize);
2080                            vgprinted = "y";
2081                           }
2082                           printf("ALT:%s::::::::::::%s:%s:::\n", vg, pv, $3);
2083                         }
2084                         next;
2085                       }
2086     /PV Name/         {
2087                         pv = $3;
2088                         if (onpvg == "")
2089                         {
2090                           if (vgprinted == "")
2091                           {
2092                            printf("VG:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s::::::\n",
2093                                    vg, vgstatus, maxlv, maxpv, numlvs,
2094                                    numpvs, numpvgs, pesize, maxpe,
2095                                    totalpe * pesize, freepe * pesize);
2096                            vgprinted = "y";
2097                           }
2098                         }
2099                         else
2100                         {
2101                           printf("PV:%s::::::::::::%s::::%s\n",vg, pv, pvg);
2102                           pvg = "";
2103                         }
2104                         next;
2105                       }
2106     /Free PE/         {
2107                         freepe = $3;
2108                         if (freepe_count > 0)
2109                         {
2110                           printf("PV:%s::::::::::::%s::%s:%s:\n", 
2111                                   vg, pv, totalpe, freepe);
2112                         }
2113                         freepe_count ++;
2114                         next;
2115                       }
2116
2117   ' >>   /tmp/sysinfo.vg.tmp
2118   mv  /tmp/sysinfo.vg.tmp  $vg_list_file
2119 #
2120 # now get list of all logical volumes
2121 #
2122   awk ' BEGIN           { FS = ":" }
2123       { type = $1; vgstatus = $2;  pesize = $8;
2124         if (type == "LV") 
2125         {
2126           printf ("%s\n",$13)
2127         }
2128       }
2129   ' $vg_list_file  >> /tmp/sysinfo.lvol.list.tmp
2130   sort  /tmp/sysinfo.lvol.list.tmp > $lvol_list_file
2131   rm -f /tmp/sysinfo.lvol.list.tmp
2132 #
2133 # now get details on each logical volume
2134 #
2135   lvol_list=$(cat $lvol_list_file)
2136   for lvol in $lvol_list
2137   do
2138   
2139     lvdisplay $lvol 2>&1 | \
2140     awk '
2141         BEGIN                  { mwc = 0;
2142                                  nummir = 0;
2143                                  mircon = 0;
2144                                  bbr = 0;
2145                                  conalloc = 0 ;
2146                                  numstripes = 0;
2147                                  stripesize = 0 }
2148         /LV Name/              { lvname= $3; next }
2149         /LV Permission/        { perm = $3; next }
2150         /Mirror copies/        { nummir = $3; next }
2151         /Consistency Recovery/ { mwc = $3; next }
2152         /Schedule/             { sched = $2; next }
2153         /LV Size/              { size = $4; next }
2154         /Current LE/           { les = $3; next }
2155         /Bad block/            { if ($3 == "on") bbr = 1; badblock = $3;
2156                                  if (badblock == "NONE")
2157                                    badblock = "NO";
2158                                  next }
2159         /Allocation/           { alloc=$2;
2160                                 if (alloc == "non-strict")
2161                                    alloc = "ns";
2162                                 if (alloc == "non-strict/contiguous")
2163                                    alloc = "ns-c";
2164                                 if (alloc == "strict")
2165                                    alloc = "s";
2166                                 if (alloc == "strict/contiguous")
2167                                    alloc = "s-c";
2168                                 if (alloc == "PVG-strict")
2169                                    alloc = "PVG";
2170                                 if (alloc == "PVG-strict/contiguous")
2171                                    alloc = "PVG-c";
2172                                 if (alloc == "PVG-strict/distributed")
2173                                    alloc = "PVG-d";
2174                                 if (alloc == "PVG-strict/partially-distributed")
2175                                     alloc = "PVG-p";
2176                                   next;
2177                                }
2178         /LV Status/            { state = $3; 
2179                                  if (state == "available/stale")
2180                                      state = "stale";
2181                                  if (state == "available/syncd")
2182                                      state = "syncd";
2183                                  if (state == "available")
2184                                      state = "avail";
2185                                  if (state == "unavailable")
2186                                      state = "unavl";
2187                                 next }
2188         /Stripes/              { numstripes = $2; next }
2189         /Stripe Size/          { stripesize = $4; next }
2190
2191                                {next}
2192         END                    {
2193                                    if ( size == 0 )
2194                                    {
2195                                        pesize = size;
2196                                    }
2197                                    else
2198                                    {
2199                                        pesize = size / les;
2200                                    }
2201
2202                             printf("%-32s %5s %3s %4s %4s %6s %6s  %-5s %-5s\n", 
2203                                 lvname, size, numstripes,
2204                                 stripesize, nummir, mwc, state, badblock,alloc)
2205                                }
2206     ' >> /tmp/sysinfo.lvol.data.tmp
2207   done
2208   mv /tmp/sysinfo.lvol.data.tmp  $lvol_out_file
2209   rm -f /tmp/sysinfo.lvol.data.tmp
2210 #
2211 # now get list of all physical volumes
2212 #
2213   awk ' BEGIN           { FS = ":" }
2214       { type = $1; vgstatus = $2;  pesize = $8;
2215         if (type == "PV") 
2216         {
2217           printf ("%s\n",$14)
2218         }
2219       }
2220   ' $vg_list_file >> /tmp/sysinfo.pvol.list.tmp
2221   sort  /tmp/sysinfo.pvol.list.tmp > $pvol_list_file
2222   rm -f /tmp/sysinfo.pvol.list.tmp
2223 #
2224 # now get details on each physical volume
2225 #
2226   pvol_list=$(cat $pvol_list_file)
2227   for pvol in $pvol_list
2228   do
2229     pvdisplay -v $pvol 2>&1 | \
2230     awk '
2231         BEGIN               {found=0}
2232
2233         /PE Size/           {pesize = $4; next}
2234         /LV Name/           {found=1; next}
2235         /Physical extents/  {exit 0}
2236
2237         #
2238         # Print "LV_Name Logical_MB_of_LV Physical_MB_of_LV"
2239         #
2240         {
2241             if (found && NF == 3)
2242                 printf("%s:%d:%d\n", $1, $2 * pesize, $3 * pesize)
2243         }
2244     ' -  >> $pvol_out_file
2245      
2246   done
2247 }  # end of lvm_scan
2248
2249 #===========================================================
2250 function launch_lvm_scan
2251 #===========================================================
2252 {
2253   Debug "Building $lvm_scan_command_file"
2254
2255   rm -f $lvm_scan_done 
2256
2257   Debug "$vg_out_file, $vg_list_file, $lvol_out_file"
2258   Debug "$lvol_list_file, $pvol_list_file $pvol_out_file"
2259   Debug "$lvm_scan_done"
2260
2261   cat <<==end_of_command==   > $lvm_scan_command_file
2262
2263     # now call the lvm_scan function (exported from parent)
2264     lvm_scan
2265     date > \$lvm_scan_done
2266
2267 ==end_of_command==
2268
2269   chmod +x $lvm_scan_command_file
2270   Debug "  launching $lvm_scan_command_file"
2271   $lvm_scan_command_file &
2272   Debug "  parent PID = $$, child PID = $!"
2273
2274 }  # end of launch_lvm_scan
2275
2276 #===========================================================
2277 # launch_kernel_scan
2278 #===========================================================
2279 function launch_kernel_scan
2280 {
2281   Debug " Starting launch_kernel_scan.....building $kernel_scan_command_file"
2282
2283   # change filenames to send output to parent's PID
2284   rm -f $kernel_scan_done 
2285
2286   Debug "$kernel_kinfo $kernel_out_file"
2287   Debug "$kernel_scan_done"
2288
2289   cat <<==end_of_command==   > $kernel_scan_command_file
2290
2291     # now call the sam_scan function (exported from parent)
2292     kernel_scan
2293     date > \$kernel_scan_done
2294
2295 ==end_of_command==
2296
2297   chmod +x $kernel_scan_command_file
2298   Debug "  launching $kernel_scan_command_file"
2299   $kernel_scan_command_file &
2300   Debug "  parent PID = $$, child PID = $!"
2301
2302
2303 }  # end of launch_kernel_scan
2304
2305 #===========================================================
2306 # launch_io_scan
2307 #===========================================================
2308 function launch_io_scan
2309 {
2310   Debug " Starting launch_io_scan.....building $io_scan_command_file"
2311
2312   # change filenames to send output to parent's PID
2313   rm -f $io_scan_done
2314
2315   Debug "$io_scan_done"
2316
2317   if (( ${osmajor} >= 10 ))
2318   then
2319     cat <<==end_of_command==   > $io_scan_command_file
2320
2321     # now call the io_scan function (exported from parent)
2322       io_scan
2323       date > \$io_scan_done
2324 ==end_of_command==
2325
2326     chmod +x $io_scan_command_file
2327     Debug "  launching $io_scan_command_file"
2328     $io_scan_command_file &
2329     Debug "  parent PID = $$, child PID = $!"
2330   else
2331     Debug "  on 9.x - executing ioscan"
2332     print    "H/W Path      LU       Driver" >> ${io_scan_out}
2333     print -- "-----------------------------" >> ${io_scan_out}
2334     ioscan -f | tail +3 | \
2335       awk '{printf ("%-14s %-6s %-20s\n", $3, $2, $4)}' \
2336       >> ${io_scan_out}
2337     date > $io_scan_done
2338   fi
2339
2340 }  # end of launch_io_scan
2341
2342
2343
2344 #===========================================================
2345 # check_if_scan_done
2346 #===========================================================
2347 function check_if_scan_done
2348 {
2349   scan_type=$1
2350   done_file=/tmp/sysinfo.$$.${scan_type}_done
2351   Debug "  starting check_if_scan_done for ${scan_type}."
2352   Debug "  looking for /tmp/sysinfo.$$.${scan_type}_done"
2353   if (($BATCH))
2354   then
2355     print -n "retrieving ${scan_type} data "
2356   fi
2357   if [ ! -f ${done_file} ]     # enter time out loop
2358   then
2359     Debug "  ${scan_type}_done file not ready, entering loop."
2360     FORCE="TRUE"
2361     for fil in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
2362     do
2363 ### Changed 6/15/99 J.Semroc - allow more time for large systems
2364 ###   sleep 5
2365       sleep 60
2366 ### end of Change
2367       Debug "    in loop $fil"
2368       if (($BATCH))
2369       then
2370         print -n "."
2371       fi
2372       if [ -f ${done_file} ]
2373       then
2374         Debug "  ${scan_type} done."
2375         FORCE="FALSE"
2376         break
2377       fi
2378     done
2379     if [ "$FORCE" = "TRUE" ]
2380     then
2381       Debug "  still no file, forcing an interactive ${scan_type}."
2382       ${scan_type}
2383     fi
2384   else
2385     Debug "  found ${scan_type}_done file"
2386     if (($BATCH))
2387     then
2388       print ""
2389     fi
2390   fi
2391 }
2392
2393 #===========================================================
2394 # io_scan
2395 #
2396 # this routine runs ioscan with the appropriate parameters and
2397 # places the output in /var/sam/<sysname>.iout   It also
2398 # provides a semaphore for other asyncronous processes, by removing
2399 # and then creating /var/sam/<sysname>.dion
2400 #
2401 #===========================================================
2402 function io_scan
2403 {
2404
2405 #       bus_type               = $1
2406 #       cdio                   = $2
2407 #       is_block               = $3
2408 #       is_char                = $4
2409 #       is_pseduo              = $5
2410 #       block_major_number     = $6
2411 #       character_major_number = $7
2412 #       minor_number           = $8
2413 #       class                  = $9
2414 #       low_level_driver       = $10
2415 #       full_hw                = $11
2416 #       identify_bytes         = $12
2417 #       device instance        = $13
2418 #       module_path            = $14
2419 #       driver                 = $15
2420 #       sw_status              = $16
2421 #       hardware_type          = $17
2422 #       ident                  = $18
2423 #       instance               = $19
2424
2425 #
2426 #  If an inadaquate description is given from ioscan.  Initiate a diskinfo
2427 #  request to force an open operation and then perform another ioscan for
2428 #  that device.  If the diskinfo operation results in an error containing
2429 #  "Permission Denied" the device may be a tape drive needing a slightly
2430 #  different device file.  At the time of this modification to this script
2431 #  (7/5/94) an HPFL Disc will only give a useful description when there is
2432 #  a mounted file system on the disk.
2433 #
2434 #  Change the Internal Field Separator to ":".  All output fields of
2435 #  ioscan -F are separated by a ":".
2436 #
2437   LANG=$save_lang
2438   LANG=C
2439   rm -f $io_scan_done
2440   ioscan $ioscan_args > $io_scan_tmp
2441   mv $io_scan_out $io_scan_out.old > /dev/null 2>&1
2442   ifs_save=$IFS
2443   IFS=:
2444   cat $io_scan_tmp | \
2445   while read p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19
2446   do
2447       if [ "$p18" = "HP-IB Device" -o "$p18" = "HP-IB Tape" -o \
2448            "$p18" = "SCSI Tape"    -o "$p18" = "HPFL Disc" ]
2449       then
2450           mksf -r -H $p11 /var/sam/sam_tmp >/dev/null 2>&1
2451           diskinfo /var/sam/sam_tmp >/dev/null 2>/var/sam/sam_err
2452           if ( grep Permission /var/sam/sam_err >/dev/null 2>&1 )
2453           then
2454               mksf -r -c -u 0 -H $p11 /var/sam/sam_tmp >/dev/null 2>&1
2455               diskinfo /var/sam/sam_tmp >/dev/null 2>&1
2456           fi
2457           ioscan -H $p11 -F >>$io_scan_out 2>/dev/null
2458           rm -f /var/sam/sam_tmp /var/sam/sam_err
2459       else
2460           echo "$p1:$p2:$p3:$p4:$p5:$p6:$p7:$p8:$p9:$p10:$p11:$p12:$p13:$p14:$p15:$p16:$p17:$p18:$p19" >>$io_scan_out
2461       fi
2462   done
2463   IFS=$ifs_save
2464   date > $io_scan_done
2465   rm $io_scan_tmp
2466
2467 } #end of io_scan
2468
2469 #==================================================================
2470 # sw_scan
2471 #==================================================================
2472 function sw_scan
2473 {
2474   Debug "Beginning SW_SCAN"
2475   if [[ -f /usr/sbin/swlist ]]
2476   then
2477     Debug "  found swlist"
2478     if (($HTML))
2479     then
2480       print "</PRE>"                  >> /tmp/sysinfo.$$.swout
2481       print "<A name='Software'></A>" >> /tmp/sysinfo.$$.swout
2482       print "<H2>"                    >> /tmp/sysinfo.$$.swout
2483       print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> /tmp/sysinfo.$$.swout
2484       print "<FONT COLOR=red>" >> /tmp/sysinfo.$$.swout
2485       print "Software Data</FONT></H2>"  >> /tmp/sysinfo.$$.swout
2486       print "<PRE><font size = '4'>"  >> /tmp/sysinfo.$$.swout
2487     else
2488       print "" >> /tmp/sysinfo.$$.swout
2489       print "SOFTWARE DATA" >> /tmp/sysinfo.$$.swout
2490       print "=============" >> /tmp/sysinfo.$$.swout
2491     fi
2492   if (($BATCH))
2493   then
2494     print  "collecting software data "
2495   fi
2496     print    "Product                Version         Description" >> /tmp/sysinfo.$$.swout
2497     print -- "--------------------------------------------------" >> /tmp/sysinfo.$$.swout
2498     swlist -l product | grep -v "^#" | expand >> /tmp/sysinfo.$$.swout
2499     f_display_file /tmp/sysinfo.$$.swout
2500     #check for non-configured software
2501     print  "checking for incompletely installed software "
2502     swlist -l fileset -a state | grep -e transient -e corrupt \
2503             -e available -e installed | expand >> /tmp/sysinfo.$$.sw_not_conf
2504     if [[ -s /tmp/sysinfo.$$.sw_not_conf ]]
2505     then
2506       print "" >> /tmp/sysinfo.$$.sw_not_header
2507       print "Found incompletely installed filesets" >> \
2508                 /tmp/sysinfo.$$.sw_not_header
2509       print "=====================================" >> \
2510                 /tmp/sysinfo.$$.sw_not_header
2511       print "WARNING (${sysname}): Found incompletely installed software." >> \
2512              /tmp/sysinfo.$$.errwarn
2513       f_display_file /tmp/sysinfo.$$.sw_not_header
2514       f_display_file /tmp/sysinfo.$$.sw_not_conf
2515     fi
2516   else
2517   Debug " could not find swlist."
2518   fi
2519 }
2520
2521 #==================================================================
2522 #f_build_sched_file
2523 #        This function retrieves the os version information and
2524 #        series type. It then sets the kernel pointers.
2525 #===================================================================
2526 function f_build_sched_file
2527 {
2528   Debug "Beginning build_sched_file"
2529 cat <<==end_of_file==   >  ${where}/sched.models
2530 600     1.0     PA7000
2531 635     1.0     PA7000
2532 645     1.0     PA7000
2533 700     1.1     PA7000
2534 705     1.1a    PA7000
2535 715     1.1c    PA7100LC
2536 710     1.1a    PA7000
2537 712     1.1c    PA7100LC
2538 720     1.1a    PA7000
2539 722     1.1c    PA7100LC
2540 725     1.1c    PA7100LC
2541 728     1.1d    PA7200
2542 730     1.1a    PA7000
2543 735     1.1b    PA7100
2544 742     1.1b    PA7100
2545 743     1.1c    PA7100LC
2546 744     1.1e    PA7300
2547 745     1.1b    PA7100
2548 747     1.1b    PA7100
2549 750     1.1a    PA7000
2550 755     1.1b    PA7100
2551 770     1.1d    PA7200
2552 777     1.1d    PA7200
2553 778     1.1e    PA7300
2554 779     1.1e    PA7300
2555 780     2.0     PA8000
2556 781     2.0     PA8000
2557 782     2.0     PA8200
2558 785     2.0     PA8500
2559 800     1.0     PA7000
2560 801     1.1c    PA7100LC
2561 802     2.0     PA8000
2562 803     1.1e    PA7300
2563 804     2.0     PA8000
2564 806     1.1c    PA7100LC
2565 807     1.1a    PA7000
2566 808     1.0     PA7000
2567 809     1.1d    PA7200
2568 810     2.0     PA8000
2569 811     1.1c    PA7100LC
2570 813     1.1e    PA7300
2571 815     1.0     PA7000
2572 816     1.1c    PA7100LC
2573 817     1.1a    PA7000
2574 819     1.1d    PA7200
2575 820     2.0     PA8000
2576 821     1.1d    PA7200
2577 822     1.0     PA7000
2578 825     1.0     PA7000
2579 826     1.1c    PA7100LC
2580 827     1.1a    PA7000
2581 829     1.1d    PA7200
2582 831     1.1d    PA7200
2583 832     1.0     PA7000
2584 834     1.0     PA7000
2585 835     1.0     PA7000
2586 837     1.1a    PA7000
2587 839     1.1d    PA7200
2588 840     1.0     PA7000
2589 841     1.1d    PA7200
2590 842     1.0     PA7000
2591 845     1.0     PA7000
2592 847     1.1a    PA7000
2593 849     1.1d    PA7200
2594 850     1.0     PA7000
2595 851     1.1d    PA7200
2596 852     1.0     PA7000
2597 855     1.0     PA7000
2598 856     1.1c    PA7100LC
2599 857     1.1a    PA7000
2600 859     1.1d    PA7200
2601 860     1.0     PA7000
2602 861     2.0     PA8000
2603 865     1.0     PA7000
2604 867     1.1a    PA7000
2605 869     1.1d    PA7200
2606 870     1.0     PA7000
2607 871     2.0     PA8000
2608 877     1.1a    PA7000
2609 879     2.0     PA8000
2610 887     1.1b    PA7100
2611 889     2.0     PA8000
2612 890     1.0     PA7000
2613 891     1.1b    PA7100
2614 892     1.1b    PA7100
2615 893     2.0     PA8000
2616 897     1.1b    PA7100
2617 898     2.0     PA8200
2618 899     2.0     PA8200
2619 F10     1.1a    PA7000
2620 F20     1.1a    PA7000
2621 H20     1.1a    PA7000
2622 F30     1.1a    PA7000
2623 G30     1.1a    PA7000
2624 H30     1.1a    PA7000
2625 I30     1.1a    PA7000
2626 G40     1.1a    PA7000
2627 H40     1.1a    PA7000
2628 I40     1.1a    PA7000
2629 G50     1.1b    PA7100
2630 H50     1.1b    PA7100
2631 I50     1.1b    PA7100
2632 G60     1.1b    PA7100
2633 H60     1.1b    PA7100
2634 I60     1.1b    PA7100
2635 G70     1.1b    PA7100
2636 H70     1.1b    PA7100
2637 I70     1.1b    PA7100
2638 E25     1.1c    PA7100LC
2639 E35     1.1c    PA7100LC
2640 E45     1.1c    PA7100LC
2641 E55     1.1c    PA7100LC
2642 T500    1.1b    PA7100
2643 T520    1.1b    PA7100
2644 T540    2.0     PA8000
2645 T600    2.0     PA8000
2646 K100    1.1d    PA7200
2647 K200    1.1d    PA7200
2648 K210    1.1d    PA7200
2649 K220    1.1d    PA7200
2650 K230    1.1d    PA7200
2651 K400    1.1d    PA7200
2652 K410    1.1d    PA7200
2653 K420    1.1d    PA7200
2654 DXO     1.1c    PA7100LC
2655 DX0     1.1c    PA7100LC
2656 DX5     1.1c    PA7100LC
2657 D200    1.1c    PA7100LC
2658 D210    1.1c    PA7100LC
2659 D310    1.1c    PA7100LC
2660 D410    1.1d    PA7200
2661 D250    1.1d    PA7200
2662 D350    1.1d    PA7200
2663 J200    1.1d    PA7200
2664 J210    1.1d    PA7200
2665 C100    1.1d    PA7200
2666 J220    2.0     PA8000
2667 J280    2.0     PA8000
2668 J282    2.0     PA8000
2669 S715    1.1e    PA7300
2670 S760    1.1e    PA7300
2671 D650    2.0     PA8000
2672 J410    2.0     PA8000
2673 J400    2.0     PA8000
2674 J210XC  1.1d    PA7200
2675 J2240   2.0     PA8200
2676 J5000   2.0     PA8500
2677 J5600   2.0     PA8600
2678 J6000   2.0     PA8600
2679 J7000   2.0     PA8500
2680 C200+   2.0     PA8200
2681 C240+   2.0     PA8200
2682 C360    2.0     PA8500
2683 C180    2.0     PA8000
2684 C180-XP 2.0     PA8000
2685 C160    2.0     PA8000
2686 C160L   1.1e    PA7300
2687 C140    2.0     PA8000
2688 C130    2.0     PA8000
2689 C120    1.1e    PA7300
2690 C115    1.1e    PA7300
2691 C110    1.1d    PA7200
2692 B160L   1.1e    PA7300
2693 B132L   1.1e    PA7300
2694 B120    1.1e    PA7300
2695 B115    1.1e    PA7300
2696 B1000   2.0     PA8500
2697 B2000   2.0     PA8500
2698 C3000   2.0     PA8500
2699 C3600   2.0     PA8600
2700 S700i   1.1e    PA7300
2701 S744    1.1e    PA7300
2702 D330    1.1e    PA7300
2703 D230    1.1e    PA7300
2704 D320    1.1e    PA7300
2705 D220    1.1e    PA7300
2706 D360    1.1d    PA7200
2707 K360    2.0     PA8000
2708 K370    2.0     PA8200
2709 K460    2.0     PA8000
2710 K460-EG 2.0     PA8000
2711 K460-XP 2.0     PA8000
2712 K260    2.0     PA8000
2713 K260-EG 2.0     PA8000
2714 D260    1.1d    PA7200
2715 D270    2.0     PA8000
2716 D280    2.0     PA8000
2717 D370    2.0     PA8000
2718 D380    2.0     PA8000
2719 D390    2.0     PA8000
2720 R380    2.0     PA8000
2721 R390    2.0     PA8000
2722 K250    2.0     PA8000
2723 K450    2.0     PA8000
2724 K270    2.0     PA8200
2725 K470    2.0     PA8200
2726 K380    2.0     PA8200
2727 K580    2.0     PA8200
2728 V2200   2.0     PA8200
2729 V2250   2.0     PA8200
2730 V2500   2.0     PA8500
2731 V2600   2.0     PA8600
2732 L1000-36  2.0   PA8500
2733 L1000-44  2.0   PA8500
2734 L2000-36  2.0   PA8500
2735 L2000-44  2.0   PA8500
2736 N4000-36  2.0   PA8500
2737 N4000-44  2.0   PA8500
2738 A180    1.1     PA7300LC
2739 A180C   1.1     PA7300LC
2740
2741 ==end_of_file==
2742
2743 chmod 444 ${where}/sched.models
2744 }
2745
2746 #==================================================================
2747 #f_get_sys_type
2748 #        This function retrieves the os version information and
2749 #        series type. It then sets the kernel pointers.
2750 #===================================================================
2751 function f_get_sys_type
2752 {
2753   Debug "Beginning GET SYSTEM TYPE"
2754   osletter=$(uname -r | awk -F. '{print $1}')
2755   osmajor=$(uname -r | awk -F. '{print $2}')
2756   osminor=$(uname -r | awk -F. '{print $3}')
2757   system=$(uname -m | awk -F/ '{print $1}')
2758   series=$(uname -m | awk -F/ '{print $2}')
2759   machine_id=$(uname -i)
2760   license=$(uname -l)
2761   Debug "  `uname -a`"
2762   Debug "  system = $system"
2763   Debug "  series = $series"
2764   Debug "  OS = $osletter.$osmajor.$osminor"
2765   Debug "  machine = $machine_id"
2766   Debug "  license = $license"
2767   if (( `echo $series | cut -b1` == 7 )) && (( $osmajor <= 9 ))
2768   then
2769     print "\nSorry. Not supported on Series 700 running HP-UX 9.x\n"
2770     exit ${ERROR}
2771   fi
2772   if [[ ! -z $(whence model) ]]
2773   then
2774     series=`model`
2775     Debug "  model returned $series"
2776     sched_file=${where}/sched.models
2777     f_build_sched_file
2778     pa_ver="N/A"
2779     pa_chip="N/A"
2780     if [[ -f ${sched_file} ]]
2781     then
2782       check_pa=$(model | awk -F/ '{print $NF}')
2783       pa_ver=$(grep "${check_pa} " $sched_file | awk '{print $2}')
2784       pa_chip=$(grep "${check_pa} " $sched_file | awk '{print $3}')
2785     else
2786       pa_ver=""
2787       pa_chip=""
2788     fi
2789   else
2790     Debug "  model not found, using inline series check"
2791     case $series in
2792       780) series="780/C160";;
2793       801) series="801/DX0";;
2794       811) series="811/DX5";;
2795       806) series="806/E25";;
2796       807) series="807/F10";;
2797       809) series="809/K100";;
2798       816) series="816/E35";;
2799       817) series="817/F20";;
2800       819) series="819/K200";;
2801       821) series="821/D200/D400";;
2802       826) series="826/E45";;
2803       827) series="827/H20";;
2804       829) series="829/K400";;
2805       831) series="831/D200/D400";;
2806       837) series="837/F30";;
2807       839) series="839/K210";;
2808       841) series="841/D210/D410";;
2809       847) series="847/G30/H30";;
2810       851) series="851/D210/D410";;
2811       849) series="849/K410";;
2812       856) series="856/E55";;
2813       857) series="857/I30";;
2814       859) series="859/K220";;
2815       867) series="867/G40/H40";;
2816       869) series="869/K420";;
2817       877) series="877/I40";;
2818       887) series="887/G50/H50/G60/H60/G70/H70";;
2819       890) series="890";;
2820       891) series="891/T500";;
2821       892) series="892/T520";;
2822       897) series="897/I50/I60/I70";;
2823         *) series=$series
2824              Debug "Series type not found for $series" ;;
2825     esac
2826   fi
2827   if [ $osmajor -lt 10 ]
2828   then
2829     kernel=/hp-ux
2830   else
2831     kernel=/stand/vmunix
2832   fi
2833   Debug "  kernel=${kernel}"
2834   if [[ -f /etc/lvmtab ]]
2835   then
2836     lvm_installed=1
2837     Debug "  LVM Detected."
2838   else
2839     lvm_installed=0
2840     Debug "  LVM NOT Detected."
2841   fi
2842 # set PATH variable to ensure access to required commands
2843   for i in \
2844     /etc \
2845     /usr/sbin \
2846     /bin \
2847   ; 
2848   do
2849     if [ -d $i ]
2850     then
2851       PATH=$PATH:$i
2852     fi
2853   done
2854   export PATH
2855   Debug "  PATH = $PATH"
2856   if [ -f ${where}/system_db ]
2857   then
2858     conf_file=${where}/system_db
2859   elif [ -f /usr/local/bin/system_db ]
2860   then
2861     conf_file=/usr/local/bin/system_db
2862   fi
2863   if [[ -n ${conf_file} ]]
2864   then
2865     Debug "  Found config file = $conf_file"
2866     serial_number=$(grep $sysname $conf_file | awk -F: '{print $4}')
2867     Debug "    serial number = ${serial_number}"
2868   fi
2869   swap_devs=$(swapinfo -d | grep -v "Kb" |grep -v "TYPE" \
2870          | awk '{printf "%s ", $NF}')
2871 # if (($FULL_KERNEL)) || (( ${LITE_KERNEL} ))
2872 # then
2873 #   if (( ${osmajor} >= 10 ))
2874 #     rm -f $kernel_scan_done
2875 #     launch_kernel_scan
2876 #     Debug "Calling kernel_scan"
2877 #     if (($BATCH))
2878 #     then
2879 #       print "launching background kernel scan"
2880 #     fi
2881 #   fi
2882 # fi
2883   if (($IOSCAN)) || (($PHYSICAL))
2884   then
2885     rm -f $io_scan_done
2886     launch_io_scan $ioscan_args
2887     Debug "Calling io_scan"
2888     if (($BATCH))
2889     then
2890       print "launching background ioscan"
2891     fi
2892   fi
2893   if (($LVMSCAN))
2894   then
2895     rm -f $lvm_scan_done
2896     launch_lvm_scan
2897     Debug "Calling launch_lvm_scan"
2898     if (($BATCH))
2899     then
2900       print "launching background lvm scan"
2901     fi
2902   fi
2903 }                # end of f_get_sys_type
2904
2905 #===================================================================
2906 #
2907 #===================================================================
2908 function f_run_cstm
2909 {
2910 cstm_ok=0
2911 print -n "Checking digmond...."
2912
2913 diagmond_result=$(ps -ef | grep -v grep | grep  diagmond > /dev/null 2>&1)
2914 diagmond_result=$?
2915 if (($diagmond_result != 0))
2916 then
2917   cstm_ok=1
2918   Debug "Error: diagmond is not running."
2919   Debug "diagmond_result = $diagmond_result"
2920   print "diagmond is NOT running!"
2921   print "No cstm info is available."
2922   return
2923 else
2924   print "diagmond is running."
2925 fi
2926
2927 print -n "Checking cstm......."
2928 cstm_version=$(echo "Version" | /usr/sbin/cstm | grep Version \
2929           | tail -1 |  awk '{print $2}' )
2930 cstm_major=$(echo ${cstm_version} | awk -F. '{print $2}')
2931
2932 echo "Version" | /usr/sbin/cstm >/dev/null 2>&1
2933 cstm_result=$?
2934 if (($cstm_result != 0)) 
2935 then
2936   cstm_ok=1
2937   Debug "Error returned from cstm"
2938   print "Error returned from cstm"
2939   print "cstm_result = $cstm_result"
2940 fi
2941
2942 if (($cstm_ok == 0))
2943 then
2944   cstm_version=$(echo "Version" | /usr/sbin/cstm | grep Version \
2945             | tail -1 |  awk '{print $2}' )
2946   cstm_major=$(echo ${cstm_version} | awk -F. '{print $2}')
2947   print "found version ${cstm_version}"
2948   ### Changed 6/30/99 J.Semroc also works with V14 
2949   ### if (($cstm_major >= 08))  && (($cstm_major <= 13))
2950   ###  and V16 <st>
2951   ### if (($cstm_major >= 08))  && (($cstm_major <= 16))
2952   ### Removed upper end version check on cstm <st>
2953   if (($cstm_major >= 08))
2954   ### end Change
2955   then
2956     print "Running cstm....please wait."
2957   
2958     if (($cstm_major == 12))
2959     then
2960       cat <<==end_of_command==   > ${cstm_command_file}
2961       # testtt
2962       #
2963       # The following connects the UI to the system the UI is being run on,
2964       #  and selects this system.
2965       # SelCurrentSys system add localhost  system 1
2966       # Use current user name
2967       # No password required on local system.
2968       # don't prompt for overwrite
2969       gop confirmation no
2970       #Select all
2971       #Select class cpu
2972       SelClass type processor qualifier cpu
2973       #collect the information and wait for it to finish
2974       Information ; wait
2975       #now display the info log
2976       #version 12 has SaveAs & Print Commands reversed.
2977       InfoLog
2978         Print
2979         $cstm_cpu_out
2980         Done
2981       #map
2982       unselall
2983       SelClass type memory
2984       Information ; wait
2985       InfoLog
2986         Print
2987         $cstm_mem_out
2988         Done
2989       unselall
2990       SelClass type disk
2991       Information ; wait
2992       InfoLog
2993         Print
2994         $cstm_disk_out
2995         Done
2996       Exit
2997       Ok
2998   
2999 ==end_of_command==
3000   
3001     else
3002
3003       cat <<==end_of_command==   > ${cstm_command_file}
3004       # testtt
3005       #
3006       # The following connects the UI to the system the UI is being run on,
3007       #  and selects this system.
3008       #SelCurrentSys system add localhost  system 1
3009       # Use current user name
3010       # No password required on local system.
3011       #don't prompt for overwrite
3012       gop confirmation no
3013       #Select all
3014       #Select class cpu
3015       SelClass type processor qualifier cpu
3016       #collect the information and wait for it to finish
3017       Information ; wait
3018       #now display the info log
3019       InfoLog
3020         SaveAs
3021         $cstm_cpu_out
3022         Done
3023       #map
3024       unselall
3025       SelClass type memory
3026       Information ; wait
3027       InfoLog
3028         SaveAs
3029         $cstm_mem_out
3030         Done
3031       unselall
3032       SelClass type disk
3033       Information ; wait
3034       InfoLog
3035         SaveAs
3036         $cstm_disk_out
3037         Done
3038       Exit
3039       Ok
3040   
3041 ==end_of_command==
3042     fi
3043     /usr/sbin/cstm -f ${cstm_command_file} > /dev/null 2>&1
3044
3045   awk '
3046       /Hardware path/         {path = $3; next;}
3047       /Slot Number/           {slot = $3; next; }
3048       /PDC Firmware Revision/ {pdc = $4; next;}
3049       /Instruction Cache/     {icache = $4; next;}
3050       /Data Cache/            {dcache = $4; next;}
3051       /Instruction TLB/       {itlb = $4; next;}
3052       /Data TLB/              {dtlb = $5;
3053                                printf("%6s%6s  %12s%8s %6s%6s %6s\n",
3054                                path, slot, pdc, icache, dcache, itlb, dtlb);
3055                               }
3056       ' $cstm_cpu_out > $cstm_cpu_out2
3057
3058   rm -f ${cstm_command_file}
3059   #rm -f ${cstm_cpu_out}
3060   Debug "cstm_cpu_out2 = ${cstm_cpu_out2}"
3061   #Debug "Data Cache            = ${data_cache}"
3062   #Debug "Instruction Cache     = ${inst_cache}"
3063   #Debug "Data TLB              = ${data_cache}"
3064   #Debug "Instruction TLB       = ${inst_cache}"
3065   #Debug "PDC Firmware Revision = ${pdc_rev}"
3066   #Debug "${memory_interleave}"
3067
3068     check_na=$(awk ' /Total Physical Memory/   {print $NF}
3069             ' $cstm_mem_out  | tail -1)
3070     if [[ ${check_na} != "N/A" ]]
3071     then
3072       cstm_tot_phys=$(awk ' /Total Physical Memory/   {print $(NF -1)}
3073         ' $cstm_mem_out  | tail -1)
3074     else
3075       cstm_tot_phys="N/A"
3076     fi
3077     cstm_tot_conf=$(awk ' /Total Configured Memory/  {print $(NF -1)}
3078         ' $cstm_mem_out  | tail -1)
3079     cstm_page_size=$(awk ' /Page Size/ {print $(NF -1)}
3080         ' $cstm_mem_out  | tail -1)
3081     cstm_interleave=$(awk ' /Memory interleaving/ { print $0}
3082         ' $cstm_mem_out | tail -1)
3083     if [[ -z ${cstm_tot_conf} ]] || [[ -z ${cstm_page_size} ]]
3084     then
3085       cstm_tot_conf="N/A"
3086       cstm_page_size="N/A"
3087     fi
3088   else
3089     print "Sorry, this version is not supported by SysInfo."
3090     print "Hardware level information will not be available."
3091     Debug "unsupported cstm version ${cstm_version}"
3092     cstm_ok=1
3093   fi
3094 fi
3095 } # end of function f_run_cstm
3096
3097
3098 #===================================================================
3099 # f_get_array_data
3100 #===================================================================
3101 function f_get_array_data
3102 {
3103   if (( ${cstm_ok} == 0 ))
3104   then
3105     Debug "Getting array data"
3106     if (($cstm_major == 12))
3107     then
3108       cat <<==end_of_command==   > ${cstm_command_file}
3109       # testtt
3110       #
3111       # The following connects the UI to the system the UI is being run on,
3112       #  and selects this system.
3113       # SelCurrentSys system add localhost  system 1
3114       # Use current user name
3115       # No password required on local system.
3116       # don't prompt for overwrite
3117       gop confirmation no
3118       #unselall
3119       Sel path $hwpath
3120       Information ; wait
3121       InfoLog
3122         Print
3123         $cstm_array_out
3124         Done
3125       Exit
3126       Ok
3127
3128 ==end_of_command==
3129
3130     else   # cstm not equal to 12
3131
3132       cat <<==end_of_command==   > ${cstm_command_file}
3133       # testtt
3134       #
3135       # The following connects the UI to the system the UI is being run on,
3136       #  and selects this system.
3137       #SelCurrentSys system add localhost  system 1
3138       # Use current user name
3139       # No password required on local system.
3140       #don't prompt for overwrite
3141       gop confirmation no
3142       #unselall
3143       Sel path $hwpath
3144       Information ; wait
3145       InfoLog
3146         SaveAs
3147         $cstm_array_out
3148         Done
3149       Exit
3150       Ok
3151
3152 ==end_of_command==
3153
3154     fi
3155     /usr/sbin/cstm -f ${cstm_command_file} > /dev/null 2>&1
3156     cat $cstm_array_out | tail +6 >> /tmp/sysinfo.$$.array
3157     rm $cstm_array_out
3158   else
3159     print "Array info not available  -  Problem with cstm."
3160   fi
3161
3162 } # end of f_get_array_data
3163
3164 #===================================================================
3165 # f_get_system_data
3166 #        This function retrieves various system  and boot data.
3167 #        e.g. amount of memory, number of cpus, etc.
3168 #        It also checks to see if memory dumping is properly
3169 #        configured.
3170 #===================================================================
3171 function f_get_system_data
3172 {
3173   if [[ (-f /usr/sbin/cstm) && (-x /usr/sbin/cstm) ]]
3174   then
3175     f_run_cstm 
3176   else
3177     cstm_ok=1
3178     Debug " cstm not found....skipping"
3179     print "WARNING (${sysname}): CSTM not installed." >> \
3180            /tmp/sysinfo.$$.errwarn
3181   fi
3182   Debug "Beginning SYSTEM/ROOT check."
3183   if (($BATCH))
3184   then
3185     print -n "collecting system data "
3186   fi
3187   # Determine cpu speed in MHz
3188   # Determine the memory size.
3189   # Real memory expressed in units of pages (4 kbytes per page).
3190   if [ ${osmajor} -eq 11 ]
3191   then
3192   cpu_speed=$(echo itick_per_tick/D | adb -k $kernel /dev/kmem | tail -1 \
3193           | awk '{print $2 / 10000}')
3194   REAL_MEM=$(echo 'phys_mem_pages/D'| adb -k $kernel /dev/kmem | tail -1 \
3195              | awk '{print $2}')
3196   MemoryDumpSize=$(expr ${REAL_MEM} / 256)
3197   k32_64=$(getconf KERNEL_BITS)
3198   processor_count=$(echo 'processor_count/D' | adb -k $kernel /dev/kmem \
3199                     | tail -1 | awk '{print $2}')
3200   else
3201   cpu_speed=$(echo itick_per_tick/D | adb $kernel /dev/kmem | tail -1 \
3202           | awk '{print $2 / 10000}')
3203   dumppages=$(echo 'dumpsize/D'| adb  $kernel /dev/kmem | tail -1 \
3204               | awk '{print $2}')
3205   MemoryDumpSize=$(expr ${dumppages} / 256)
3206   REAL_MEM=$(echo 'physmem/D'| adb  $kernel /dev/kmem | tail -1 \
3207              | awk '{print $2}')
3208   # determine number of active processors (cpus)
3209   processor_count=$(echo 'processor_count/D' | adb $kernel /dev/kmem \
3210                     | tail -1 | awk '{print $2}')
3211   fi
3212   memory=$(expr ${REAL_MEM} / 256)
3213   if (($BATCH))
3214   then
3215     print -n "."
3216   fi
3217   boot_time=$(who -b | awk '{printf "%s %s %s ", $4, $5, $6}')
3218    
3219   #now get date of last patch
3220   #
3221   #Modified: Greg Sterling
3222   #updated lastpatch for 10.x & 11.x
3223   #
3224   last_patch="unknown"
3225   if (( $osmajor >= 10 ))
3226   then
3227     if [ -d /var/adm/sw/products ]
3228     then
3229       last_patch=$(ls -lt /var/adm/sw/products | egrep 'PHNE|PHCO|PHKL|PHSS' \
3230            | head -1 | awk '{ print $6,$7,$8}')
3231     else
3232       Debug "ERROR: Product IPD database does not exist."
3233     fi
3234   else
3235     if [ -d /system ]
3236     then
3237       last_patch=$(ls -lt /system/ | egrep 'PHNE|PHCO|PHKL|PHSS' \
3238            | head -1 | awk '{ print $6,$7,$8}')
3239     fi
3240   fi
3241   if (($BATCH))
3242   then
3243     print -n "."
3244   fi
3245   if (($BATCH))
3246   then
3247     print -n "."
3248   fi
3249   lvlnboot -v /dev/vg00 > /tmp/sysinfo.$$.root 2>&1
3250   rootboot=$(grep "Boot Disk" /tmp/sysinfo.$$.root \
3251              | awk '{printf "%s  ", $1}')
3252   rootroot=$(grep "^Root:" /tmp/sysinfo.$$.root \
3253              | awk '{print $2,$4}')
3254   rootswap=$(grep "^Swap:" /tmp/sysinfo.$$.root \
3255              | awk '{print $2,$4}')
3256   rootdump=$(grep "^Dump:" /tmp/sysinfo.$$.root \
3257              | awk '{printf  "%s ",$2}')
3258   if (($BATCH))
3259   then
3260     print -n "."
3261   fi
3262
3263   kernel_size=$(ll ${kernel} | awk '{print $5}' 2>&1)
3264 # gather memory dump parms
3265   (( KernelSizeMb=`ll ${kernel} | awk '{print $5}'` / 1024 / 1024 + 1 ))
3266   if (( $osmajor < 10 ))
3267   then                                        
3268     # it is a 9.x system
3269     if [[ $(grep "dumps" /etc/conf/gen/S800*) = *default* ]]
3270     then
3271       DumpDiskCapacity=$(swapinfo -mat | grep dev | head -1 | awk '{print $2}')
3272       rootdump="default"
3273       Debug "  9.x system. default found in S800."
3274       Debug "  rootdump=${rootdump}"
3275     else
3276       Debug "  9.x system. default not found in S800. using rootdump"
3277     fi
3278     SAVECORE=0
3279     grep "/etc/savecore" /etc/rc > /dev/null 2>&1
3280     if ((! ($?) ))
3281     then
3282       SAVECORE=1
3283     fi
3284     SAVECORE_DIR=$(grep "/etc/savecore" /etc/rc | tail -1 | awk '{print $NF}')
3285
3286   elif  (( $osmajor >= 11 ))
3287   then
3288     # 11.x system
3289     Debug "  11.x system."
3290     if [ -f /etc/rc.config.d/savecrash ] 
3291     then
3292       . /etc/rc.config.d/savecrash
3293       # check if SAVECRASH is set
3294       if [[ ! -z $SAVECRASH ]]
3295       then
3296       case ${COMPRESS} in
3297         0) Compress_Option="Turned off. ";;
3298         1) Compress_Option="Turned on. ";;
3299         2) Compress_Option="Don't care (default). ";;
3300         *) Compress_Option="N/A";;
3301       esac
3302       SAVECORE=$SAVECRASH
3303       SAVECORE_DIR=$SAVECRASH_DIR
3304       Debug "  found /etc/rc.config.d/savecrash with following parms:"
3305       Debug "    SAVECORE=$SAVECRASH"
3306       Debug "    SAVECORE_DIR=$SAVECRASH_DIR"
3307       Debug "    CHUNK_SIZE=$CHUNK_SIZE"
3308       Debug "    COMPRESS=$COMPRESS"
3309       Debug "    MIN_FREE=$MIN_FREE"
3310       Debug "    SWAP_LEVEL=$SWAP_LEVEL"
3311       Debug "    FOREGRD=$FOREGRD"
3312       Debug "    SAVE_PART=$SAVE_PART"
3313       Debug "    LOG_ONLY=$LOG_ONLY"
3314       else
3315       Debug "  SAVECRASH is DISABLED"
3316       SAVECORE=0
3317       fi
3318 #
3319 # Now check for the crashconf file. This file can be used to set additional
3320 # dump parameters in V11.x
3321 #
3322       if [ -f /etc/rc.config.d/crashconf ]
3323       then
3324         . /etc/rc.config.d/crashconf
3325         # check if CRASHCONF_ENABLED is set
3326         if [[ -z $CRASHCONF_ENABLED ]]
3327         then
3328           Debug "  CrashConf is disabled."
3329       else
3330
3331 # Changed: 12/15/98 by Greg Sterling
3332 # If we're using V11.x, and CRASHCONF is enabled, the we've costomized the
3333 # DUMP output. The equation below does not apply to this scenario.
3334 # TotalMemoryDumpSize = MemoryDumpSize + KernelSizeMb + KernelSafetyFactor
3335 #
3336 # The actual dumpsize can not be computed from the crashconf utility. The
3337 # kernel size and safety values can be set to zero since the crashconf utility
3338 # already calculates these values.
3339 #
3340         crashconf_dumpsize=$(/sbin/crashconf -v | grep 'Total pages included' \
3341                | awk '{ print $6}')
3342         crashconf_dumpsize=$(expr ${crashconf_dumpsize} \* 4096 / 1024 / 1024)
3343 #       KernelSizeMB=0
3344 #       KernelSafetyFactor=0
3345
3346         Debug "  found /etc/rc.config.d/crashconf with following parms:"
3347         Debug "    CRASHCONF_ENABLED=$CRASHCONF_ENABLED"
3348         Debug "    CRASH_INCLUDED_PAGES=$CRASH_INCLUDED_PAGES"
3349         Debug "    CRASH_EXCLUDED_PAGES=$CRASH_EXCLUDED_PAGES"
3350         Debug "    CRASHCONF_READ_FSTAB=$CRASHCONF_READ_FSTAB"
3351         Debug "    CRASHCONF_REPLACE=$CRASHCONF_REPLACE"
3352 #
3353 # Check to see if the CRASHCONF_READ_FSTAB variable is set. If yes, then
3354 # the system will check the /etc/fstab file to see if there are any additional
3355 # dump spaces defined. If the CRASHCONF_REPLACE variable is set then all
3356 # the definitions/parameters defined in this section will replace any
3357 # previously defined DUMP parameters in the kernel.
3358 #
3359         if [[ ! -z $CRASHCONF_READ_FSTAB ]]
3360         then
3361           Debug "  crashconf_read_fstab is enabled."
3362           crashconf_fstabs=$(awk ' $3=="dump" {printf("%s ",$1)}' /etc/fstab )
3363
3364           Debug "  list of crashconf_fstabs = $crashconf_fstabs"
3365           if [[ -z $crashconf_fstabs ]]
3366           then
3367             Debug "  crashconf_fstabs list is empty. Will continue to "
3368             Debug "    use the lvlnboot info."
3369           else
3370             if [[ -z $CRASHCONF_REPLACE ]]
3371             then
3372               Debug "  crashconf_fstabs will be added to existing \
3373                          configuration."
3374               rootdump="$rootdump $crashconf_fstabs"
3375             else
3376               Debug "  crashconf_fstabs will replace default dump config."
3377               rootdump=$crashconf_fstabs
3378             fi
3379           fi
3380         fi
3381       fi
3382     else
3383       Debug "  could not find /etc/rc.config.d/crashconf"
3384       print "ERROR ${sysname}:/etc/rc.config.d/crashconf defaults file MISSING" >> /tmp/sysinfo.$$.errwarn
3385     fi
3386   fi
3387   else  
3388     # must be a 10.x system
3389     Debug "  10.x system."
3390     if [ -f /etc/rc.config.d/savecore ] 
3391     then
3392       . /etc/rc.config.d/savecore
3393       case ${COMPRESS} in
3394         0) Compress_Option="Turned off. ";;
3395         1) Compress_Option="Turned on. ";;
3396         2) Compress_Option="Don't care (default). ";;
3397         *) Compress_Option="N/A";;
3398       esac
3399       Debug "  found /etc/rc.config.d/savecore with following parms:"
3400       Debug "    SAVECORE=$SAVECORE"
3401       Debug "    SAVECORE_DIR=$SAVECORE_DIR"
3402       Debug "    CHUNK_SIZE=$CHUNK_SIZE"
3403       Debug "    COMPRESS=$COMPRESS"
3404       Debug "    MIN_FREE=$MIN_FREE"
3405       Debug "    SWAP_LEVEL=$SWAP_LEVEL"
3406       Debug "    FOREGRD=$FOREGRD"
3407     else
3408       Debug "  could not find /etc/rc.config.d/savecore"
3409       print "ERROR: ${sysname}:/etc/rc.config.d/savecore defaults file MISSING" >> /tmp/sysinfo.$$.errwarn
3410     fi
3411
3412   fi
3413
3414 # Updated: Greg Sterling
3415 # I moved this section of code outside the savesore/crashconf checks above.
3416 # This dump calculation is pertinent to any version of HPUX and should not be
3417 # restricted to V10.x
3418 #
3419   if (($lvm_installed))
3420   then
3421     Debug "Checking for dump space"
3422     Debug "  rootdump = ${rootdump}"
3423     for logvol in ${rootdump}
3424     do
3425 #
3426 # Added by Greg Sterling
3427 # This code checks for a preceeding /dev. if it exists then
3428 # continue, otherwise append the /dev/vg00 to the lvol definition.
3429 #
3430       echo $logvol | grep -q "^/dev/"
3431       if [[ $? -ne 0 ]]
3432       then
3433         Debug "  adding /dev/vg00 to lvol name"
3434         logvol="/dev/vg00/${logvol}"
3435       fi
3436 #
3437 # Added by Greg Sterling
3438 # Validate the logvol is a logical volume. Its possible for dump
3439 # devices in later versions of HPUX to be disks w/out LVM
3440 #
3441         lvdisplay $logvol > /dev/null 2>&1
3442         if [[ $? -ne 0 ]]
3443         then
3444           Debug "    dump device is not a logical volume."
3445           rlogvol=$( echo $logvol | sed -e "s:^/dev/dsk/:/dev/rdsk/:" )
3446           DumpSize=$( diskinfo $rlogvol | grep "size" | awk '{print $2}')
3447           DumpSize=$( expr $DumpSize / 1024 )
3448         else
3449           DumpSize=$(lvdisplay $logvol | grep "LV Size" | awk '{print $4}')
3450           Debug "    $logvol DumpSize = ${DumpSize}"
3451         fi
3452         Debug "  Adding $DumpSize to DumpDiskCapacity = ${DumpDiskCapacity}"
3453         ((DumpDiskCapacity = DumpDiskCapacity + DumpSize))
3454       done
3455       Debug "  DumpDiskCapacity =${DumpDiskCapacity}"
3456     fi
3457     Debug "Checking how much to dump"
3458     # add kernel size to memory plus 2Mb safety factor
3459     ((TotalMemoryDumpSize = MemoryDumpSize + KernelSizeMb + KernelSafetyFactor))
3460     Debug "  REAL_MEM = $REAL_MEM"
3461     Debug "  memory =               $memory"
3462     Debug "  KernelSizeMb =           $KernelSizeMb"
3463     Debug "  KernelSafetyFactor =     $KernelSafetyFactor"
3464     Debug "                     ---------"
3465     Debug "  TotalMemoryDumpSize =  $TotalMemoryDumpSize"
3466
3467     if (($BATCH))
3468     then
3469       print -n "."
3470     fi
3471 # now check to see if everything is okay.
3472 #
3473 # Updated: 12/15/98 by Greg Sterling
3474 # I updated this code to consider the CRASHCONF utility on V11.x. The
3475 # TotalMemoryDumpSize parameter is only relevent for a FULL crash dump.
3476 # Normal system crashes (if there is such a thing), can be captured within
3477 # smaller dump spaces due to the CRASHUTIL utility.
3478 #
3479     case $osmajor in
3480       11 )
3481          if (( DumpDiskCapacity < TotalMemoryDumpSize ))
3482          then
3483            if (( DumpDiskCapacity < crashconf_dumpsize ))
3484            then
3485              print "WARNING (${sysname}): Dump space is underconfigured!" \
3486                      >> /tmp/sysinfo.$$.errwarn
3487            else
3488              print "WARNING (${sysname}): Dump space is underconfigured \
3489 for a FULL crashdump." >> /tmp/sysinfo.$$.errwarn
3490              print "WARNING (${sysname}): Dump space is adequate for the \
3491 CRASHCONF configuration." >> /tmp/sysinfo.$$.errwarn
3492            fi
3493          fi
3494        ;;
3495
3496  8 | 9 | 10 )
3497          if (( DumpDiskCapacity < TotalMemoryDumpSize ))
3498          then
3499            print "WARNING (${sysname}): Dump space is under configured!" \
3500                    >> /tmp/sysinfo.$$.errwarn
3501          fi
3502        ;;
3503   esac
3504   if ((! (($exit_code)) ))
3505   then
3506     exit_code=${WARN}
3507   fi
3508
3509   if (( ! $SAVECORE ))
3510   then
3511     SAVECORE=Disabled
3512     if ((! (($exit_code)) ))
3513     then
3514       exit_code=${WARN}
3515     fi
3516
3517     case $osmajor in
3518       8 | 9 | 10 )
3519        print "WARNING (${sysname}): Savecore is not enabled!" \
3520                  >> /tmp/sysinfo.$$.errwarn
3521       ;;
3522
3523       11 )
3524        if [[ -z $CRASHCONF_ENABLED ]]
3525        then
3526         Debug "Savecore is Disabled and CrashConf is Disabled."
3527         print "WARNING (${sysname}):Both Savecore and crashconf are disabled!" \
3528                  >> /tmp/sysinfo.$$.errwarn
3529        fi
3530       ;;
3531     esac
3532
3533   else
3534
3535
3536   # Now check if enough disk space exists to hold savecore
3537   Debug "Checking for sufficient savecore space"
3538   COMPRESSION="Not Applicable"
3539   if [[ -d $SAVECORE_DIR ]] 
3540   then
3541     #SaveCoreAvail=$(bdf $SAVECORE_DIR | grep /dev/ | awk '{print $4}')
3542     # fix for non-standard lvol names
3543     SaveCoreAvail=$(df -b $SAVECORE_DIR | awk '{print $5}')
3544     ((SaveCoreAvail = SaveCoreAvail / 1024))
3545     Debug "  SAVECORE=$SAVECORE"
3546     Debug "  SAVECORE_DIR=$SAVECORE_DIR" 
3547     Debug "  SaveCoreAvail=$SaveCoreAvail" 
3548   else
3549     SaveCoreAvail=0
3550     if ((! (($exit_code)) ))
3551     then
3552       exit_code=${WARN}
3553     fi
3554     print "WARNING (${sysname}): Directory $SAVECORE_DIR does not exist!" >> /tmp/sysinfo.$$.errwarn
3555   fi
3556     if ((($osmajor == 10))  && (($osminor >= 10))) || (( $osmajor > 10 ))
3557     then
3558       COMPRESSION="Available"
3559       compression_factor=${compression_factor:-50}
3560       ((MemoryCompression = (TotalMemoryDumpSize * $compression_factor) / 100 ))
3561       ((CompressedMemoryDumpSize = TotalMemoryDumpSize - MemoryCompression))
3562
3563       Debug "  Checking for savecore compression"
3564       Debug "    Compress_option=$Compress_Option"
3565       Debug "    Compression=$COMPRESSION"
3566       Debug "    compression_factor=$compression_factor"
3567       Debug "    CompressedMemoryDumpSize after = $CompressedMemoryDumpSize"
3568       if (( $CompressedMemoryDumpSize  > $SaveCoreAvail ))
3569       then
3570         if ((! (($exit_code)) ))
3571         then
3572           exit_code=${WARN}
3573         fi
3574         print "WARNING (${sysname}): Insufficient file space to hold savecore!" >> /tmp/sysinfo.$$.errwarn
3575       fi
3576     else
3577       if (( $TotalMemoryDumpSize  > $SaveCoreAvail ))
3578       then
3579         if ((! (($exit_code)) ))
3580         then
3581           exit_code=${WARN}
3582         fi
3583         print "WARNING (${sysname}): Insufficient file space to hold savecore!" >> /tmp/sysinfo.$$.errwarn
3584       fi
3585     fi
3586     SaveCoreAvail_Out=$SaveCoreAvail
3587     SAVECORE=Enabled
3588   fi
3589
3590   TotalMemoryDumpSizeOut=$TotalMemoryDumpSize
3591
3592 # now let's print it.
3593   if (($HTML))
3594   then
3595     print "</PRE>" >> /tmp/sysinfo.$$.sysout
3596     print "<A name='System'></A>" >> /tmp/sysinfo.$$.sysout
3597     print "<H2>" >> /tmp/sysinfo.$$.sysout
3598     print "<FONT COLOR=red>" >> /tmp/sysinfo.$$.sysout
3599     print "System Data" >> /tmp/sysinfo.$$.sysout
3600     print "</FONT></H2>" >> /tmp/sysinfo.$$.sysout
3601     print "<PRE><font size = '4'>" >> /tmp/sysinfo.$$.sysout
3602   else
3603     print "" >> /tmp/sysinfo.$$.sysout
3604     print "SYSTEM DATA" >> /tmp/sysinfo.$$.sysout
3605     print "===========" >> /tmp/sysinfo.$$.sysout
3606   fi
3607   print "HOSTNAME:      ${sysname}" >> /tmp/sysinfo.$$.sysout
3608   print "SYSTEM:        ${system}" >> /tmp/sysinfo.$$.sysout
3609   print "MODEL:         ${series}" >> /tmp/sysinfo.$$.sysout
3610   if [[ -n ${pa_chip} ]]
3611   then
3612     print "RISC CHIP:     ${pa_chip}" >> /tmp/sysinfo.$$.sysout
3613     print "PA VERSION:    ${pa_ver}" >> /tmp/sysinfo.$$.sysout
3614   fi
3615   if [[ -n ${serial_number} ]]
3616   then
3617     print "SERIAL #:      ${serial_number}" >> /tmp/sysinfo.$$.sysout
3618   fi
3619   print "SYSTEM ID:     ${machine_id}" >> /tmp/sysinfo.$$.sysout
3620   print "CPU SPEED:     ${cpu_speed} MHz" >> /tmp/sysinfo.$$.sysout
3621   print "CPUS:          ${processor_count} active processor(s) " >> /tmp/sysinfo.$$.sysout
3622   print "MEMORY:        ${memory} Mbytes of memory." >> /tmp/sysinfo.$$.sysout
3623   print -n "HP-UX VERSION: ${osletter}.${osmajor}.${osminor}" >> /tmp/sysinfo.$$.sysout
3624   if (( $osmajor == 11 ))
3625   then
3626     print "   ${k32_64} Bit" >> /tmp/sysinfo.$$.sysout
3627   else
3628     print "" >> /tmp/sysinfo.$$.sysout
3629   fi
3630   print "USER LICENSE:  ${license}" >> /tmp/sysinfo.$$.sysout
3631   print "LAST BOOT:     ${boot_time}" >> /tmp/sysinfo.$$.sysout
3632   print "LAST PATCH:    ${last_patch}\n" >> /tmp/sysinfo.$$.sysout
3633   print "" >> /tmp/sysinfo.$$.sysout
3634
3635   if (( ${cstm_ok} == 0 ))
3636   then
3637     print "System H/W data" >> /tmp/sysinfo.$$.sysout
3638     print "===============" >> /tmp/sysinfo.$$.sysout
3639     print "  Processor data" >> /tmp/sysinfo.$$.sysout
3640     print -- "  --------------" >> /tmp/sysinfo.$$.sysout
3641     print "       H/W          PDC        Cache Size    TLB Size" >>/tmp/sysinfo.$$.sysout
3642     print "   path  slot    rev level    Inst   Data  Inst   Data" >>/tmp/sysinfo.$$.sysout
3643     print -- "  -----------------------------------------------------" >>/tmp/sysinfo.$$.sysout
3644     cat $cstm_cpu_out2 | awk -F: '
3645         {printf("%8s%6s%14s%7s%7s%6s%6s\n",$1,$2,$3,$4,$5,$6,$7)}
3646         ' >> /tmp/sysinfo.$$.sysout
3647
3648     print "" >> /tmp/sysinfo.$$.sysout
3649     print    "  Memory Information" >> /tmp/sysinfo.$$.sysout
3650     print -- "  ------------------" >> /tmp/sysinfo.$$.sysout
3651     #print "    Total Physical Memory    = $cstm_tot_phys MB" \
3652     #         >> /tmp/sysinfo.$$.sysout
3653     #print "    Total Configured Memory  = $cstm_tot_conf MB" \
3654     #         >> /tmp/sysinfo.$$.sysout
3655     #print "    Memory Page Size         = $cstm_page_size Bytes" \
3656     #         >> /tmp/sysinfo.$$.sysout
3657     #print "$cstm_interleave" >> /tmp/sysinfo.$$.sysout
3658     #print "" >> /tmp/sysinfo.$$.sysout
3659
3660     cat ${cstm_mem_out} | tail -n +10 | sed -e '/^$/d' >> /tmp/sysinfo.$$.sysout
3661     print "" >> /tmp/sysinfo.$$.sysout
3662   fi
3663
3664   print "SWAP DATA" >> /tmp/sysinfo.$$.sysout
3665   print "=========" >> /tmp/sysinfo.$$.sysout
3666   if (( $osmajor >= 10 ))
3667   then
3668     Debug "`swapinfo -dtfnrMa`"
3669   else
3670     Debug "`swapinfo -dtfa`"
3671   fi
3672
3673   swapinfo -m | grep dev | \
3674       awk '{printf "%6s MB on %s\n",$2,$9}' >> /tmp/sysinfo.$$.sysout
3675   swapinfo -m | grep fs | \
3676       awk '{printf "%6s MB on %s\n",$2,$9}' >> /tmp/sysinfo.$$.sysout
3677   swapinfo -m | grep memory | \
3678       awk '{printf "%6s MB on memory\n",$2}' >> /tmp/sysinfo.$$.sysout
3679   print -- "  ----" >> /tmp/sysinfo.$$.sysout
3680
3681   if (( $osmajor >= 10 ))
3682   then
3683     swapinfo -mdfMt | grep total | \
3684         awk '{printf "%6s MB Total \n",$2}' >> /tmp/sysinfo.$$.sysout
3685   else
3686     swapinfo -mdft | grep tot | \
3687         awk '{printf "%6s MB Total \n",$2}' >> /tmp/sysinfo.$$.sysout
3688   fi
3689   print "" >> /tmp/sysinfo.$$.sysout
3690   print "DUMP DISKS"            >> /tmp/sysinfo.$$.sysout
3691   print "=========="            >> /tmp/sysinfo.$$.sysout
3692   lvlnboot -v /dev/vg00 2>&1 | grep Dump | awk '{print "  "$0}' >> \
3693                /tmp/sysinfo.$$.sysout 
3694   print "" >> /tmp/sysinfo.$$.sysout
3695   print "DUMP DATA" >> /tmp/sysinfo.$$.sysout
3696   print "=========" >> /tmp/sysinfo.$$.sysout
3697   print "SAVECORE:                  ${SAVECORE}" >> /tmp/sysinfo.$$.sysout
3698   case ${SAVECORE} in
3699     D* )
3700       ;;
3701     E* )
3702       print "SAVECORE DIR:              ${SAVECORE_DIR}" >> \
3703                    /tmp/sysinfo.$$.sysout
3704       if ((($osmajor == 10)) && (($osminor >= 10))) || (( $osmajor > 10 ))
3705       then
3706         print "SAVECORE COMPRESSION:      ${COMPRESSION}" >> \
3707                    /tmp/sysinfo.$$.sysout
3708         print "COMPRESSION OPTION:        ${Compress_Option}" >> \
3709                    /tmp/sysinfo.$$.sysout
3710         print "COMPRESSION FACTOR:          ${compression_factor} %" >> \
3711                    /tmp/sysinfo.$$.sysout
3712         print "COMPRESSED MEMORY TO DUMP:   ${CompressedMemoryDumpSize} MB" >> \
3713                    /tmp/sysinfo.$$.sysout
3714         print "SAVECORE CAPACITY:           ${SaveCoreAvail_Out} MB\n" >> \
3715                    /tmp/sysinfo.$$.sysout
3716       fi
3717       ;;
3718   esac
3719   
3720 #
3721 # Added: Greg Sterling
3722 # Added code to output the status of the CrashConf configuration.
3723 #
3724   if (($osmajor > 10))
3725   then
3726     if [[ ! -z $CRASHCONF_ENABLED ]]
3727     then
3728       print "" >> /tmp/sysinfo.$$.sysout
3729       if [[ -z $CRASHCONF_READ_FSTAB ]]
3730       then
3731         print "CRASHCONF             : Enabled" >> /tmp/sysinfo.$$.sysout
3732       else
3733         print "CRASHCONF             : Enabled (referencing /etc/fstab)" >> \
3734                 /tmp/sysinfo.$$.sysout
3735       fi
3736       if [[ -z $CRASHCONF_REPLACE ]]
3737       then
3738         print "   Replace Option     : CrashConf values have been Added to existing Kernel Definitions." >> /tmp/sysinfo.$$.sysout
3739       else
3740         print "   Replace Option     : CrashConf values REPLACE existing Kernel Definitions." >> /tmp/sysinfo.$$.sysout
3741       fi
3742
3743       print "   Included Pages     : $CRASH_INCLUDED_PAGES" >> \
3744                 /tmp/sysinfo.$$.sysout
3745       print "   Excluded Pages     : $CRASH_EXCLUDED_PAGES" >> \
3746                 /tmp/sysinfo.$$.sysout
3747       print "   FSTAB File Entries : $crashconf_fstabs" >> \
3748                 /tmp/sysinfo.$$.sysout
3749       print "   CRASHCONF Configured MEMORY TO DUMP: ${crashconf_dumpsize} MB" \
3750                  >> /tmp/sysinfo.$$.sysout
3751     else
3752       print "CRASHCONF             : Disabled" >> /tmp/sysinfo.$$.sysout
3753     fi
3754     print "" >> /tmp/sysinfo.$$.sysout
3755   fi
3756
3757   print "KERNEL SIZE:                ${kernel_size} Bytes." >> \
3758                      /tmp/sysinfo.$$.sysout
3759   print "TOTAL MEMORY TO DUMP:        ${TotalMemoryDumpSizeOut} MB" >> \
3760                      /tmp/sysinfo.$$.sysout
3761
3762   print "DUMP DISK CAPACITY:          ${DumpDiskCapacity} MB" >> \
3763                    /tmp/sysinfo.$$.sysout
3764
3765   f_display_file /tmp/sysinfo.$$.sysout 
3766   f_display_file /tmp/sysinfo.$$.stmout 
3767   #f_display_file /tmp/sysinfo.$$.dumpwarn 
3768   print "" >> /tmp/sysinfo.$$.sysout
3769
3770 #  if (($BATCH))
3771 #  then
3772     print 
3773 #  fi
3774 }                # end of f_get_system_data
3775
3776 function f_call_getkinfo
3777 {
3778 /usr/sam/lbin/getkinfo -b -o ${sam_kinfo}
3779 }
3780
3781 function get_all_parms
3782 {
3783 Debug "starting get_all_parms"
3784 awk '
3785      BEGIN { FS = "\n"; RS = "}" }
3786      {print $0}
3787     ' $sam_kinfo | \
3788     awk '
3789          /KC_PARAM_NAME/      {name = $3;  printf("%s,", name)}
3790          /KC_PARAM_CLASS/     {class = $3 " " $4; printf("%s\n", class)}
3791         ' #| sed -e 's/\"*//g'
3792 }
3793
3794 function get_all_classes
3795 {
3796 Debug "starting get_all_classes"
3797 awk ' BEGIN { FS = "\n"; RS = "}" }
3798       $0 ~ /'\"$parm\"'/ {print $0}' $sam_kinfo \
3799         | awk '
3800           /^KC_PARAM_CLASS/     {printf("%s %s\n",$3,$4)}
3801           ' #| sed -e 's/\"*//g'
3802 }
3803
3804 function f_query_sam
3805 {
3806   sam_parm=$1
3807   type=$2
3808     awk ' BEGIN { FS = "\n"; RS = "}" }
3809       $0 ~ /'$sam_parm'/ {print $0}' $sam_kinfo \
3810           | awk '
3811           /^KC_PARAM_NAME/      {name = $3}
3812           /^KC_PARAM_STATUS/    {status = $3}
3813           /^KC_PARAM_DEFAULT/   {default = $3}
3814           /^KC_PARAM_MAX/       {max = $3}
3815           /^KC_PARAM_MIN/       {min = $3}
3816           /^KC_PARAM_CLASS/     {class = $3" " $4}
3817           /^KC_PARAM_DESC/      {desc = ""
3818                                  for(i=3;i<=NF;i++)
3819                                  desc = desc $i " ";
3820                                  }
3821
3822           END { printf("%s@%s@%s@%s@%s@%s@%s\n",
3823                         name,status,default,max,min,desc,class)}
3824     ' | sed -e 's/\"*//g'
3825
3826 }
3827
3828 #===================================================================
3829 # f_get_kernel_data
3830 #        This function queries the kernel for various parameters.
3831 #===================================================================
3832 function f_get_kernel_data 
3833 {
3834
3835   Debug "Beginning KERNEL check."
3836   if (($BATCH))
3837   then
3838     print -n "collecting kernel data "
3839     print "" >> /tmp/sysinfo.$$.kernout
3840   else
3841     print    "Collecting kernel metrics....please wait."
3842   fi
3843  
3844   if (($HTML))
3845   then
3846     print "</PRE>" >> /tmp/sysinfo.$$.kernout
3847     print "<A name='Kernel'></A>" >> /tmp/sysinfo.$$.kernout
3848     print "<H2>" >> /tmp/sysinfo.$$.kernout
3849     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> /tmp/sysinfo.$$.kernout
3850     print "<FONT COLOR=red>" >> /tmp/sysinfo.$$.kernout
3851     if (( ${FULL_KERNEL} ))
3852     then
3853       print "Kernel Parms (Verbose Listing)" >> /tmp/sysinfo.$$.kernout
3854     else
3855       print "Kernel Parms (Brief Listing)" >> /tmp/sysinfo.$$.kernout
3856     fi
3857     print "</FONT></H2>" >> /tmp/sysinfo.$$.kernout
3858     print "<PRE><font size = '4'>" >> /tmp/sysinfo.$$.kernout
3859   else
3860     print "KERNEL PARAMETERS" >> /tmp/sysinfo.$$.kernout
3861     print "=================" >> /tmp/sysinfo.$$.kernout
3862   fi
3863
3864 Debug "calling f_call_getkinfo -> ${sam_kinfo}"
3865 f_call_getkinfo
3866
3867 Debug "calling get_all_parms -> ${all_parms_file}"
3868 get_all_parms > ${all_parms_file}
3869 Debug " parm names = `cat ${all_parms_file}`"
3870
3871 Debug "calling get_all_classes -> ${all_classes_file}"
3872 get_all_classes | sort -t , -k 7 | uniq  > ${all_classes_file}
3873     #sed -e 's/ /_/g' -e 's/_$//g'  > ${all_classes_file}
3874 Debug " class names = `cat ${all_classes_file}`"
3875
3876 exec 3< ${all_classes_file}
3877 exec 4< ${all_parms_file}
3878 while read -u3 class
3879 do
3880   if (($BATCH))
3881   then
3882     print -n "."
3883   fi
3884   print_class=$(echo $class | sed -e 's/\"*//g')
3885   if (($HTML))
3886   then
3887     print "<H3>${print_class} Metrics</H3>" >> /tmp/sysinfo.$$.kernout
3888   else
3889     print "${print_class} Metrics" >> /tmp/sysinfo.$$.kernout
3890     print "============================" >> /tmp/sysinfo.$$.kernout
3891   fi
3892   Debug "Class = ${class}"
3893   for parm1 in $(grep "${class}" ${all_parms_file} | awk -F, '{print $1}')
3894   do
3895     Debug "Parm1 = $parm1"
3896     if (($FULL_KERNEL))
3897     then
3898     f_query_sam ${parm1} | \
3899     awk 'BEGIN {FS = "@"}
3900          {printf("%s\n",$1)
3901           printf("   Title:   %s\n",$6)
3902           printf("   Current: %s\n",$2)
3903           printf("   Default: %s\n",$3)
3904           printf("   Min:     %s\n",$5)
3905           printf("   Max:     %s\n",$4)
3906          #printf("   Class:   %s\n",$7)
3907          } '>> /tmp/sysinfo.$$.kernout
3908     else
3909     f_query_sam ${parm1} | \
3910     awk 'BEGIN {FS = "@"}
3911          {printf("  %-20s  %s\n",$1,$2)
3912          } ' >> /tmp/sysinfo.$$.kernout
3913     fi
3914   done
3915 print "" >> /tmp/sysinfo.$$.kernout
3916 done
3917   print "" >> /tmp/sysinfo.$$.kernout
3918   f_display_file /tmp/sysinfo.$$.kernout 
3919
3920 if (($PASS))
3921 then 
3922   if (($DB_on_this_sys))
3923   then
3924     dbc_max=$(grep dbc_max /tmp/sysinfo.$$.kernout | awk '{print $2}')
3925     if (( dbc_max > 10 ))
3926     then
3927       print "WARNING ($sysname): dbc_max is set to ${dbc_max} on DB server" >> \
3928               /tmp/sysinfo.$$.sapwarn
3929     fi
3930   fi   
3931 fi
3932   f_display_file /tmp/sysinfo.$$.kernwarn 
3933   if (($BATCH))
3934   then
3935     print ""
3936   fi
3937 }                # end of f_get_kernel_data 
3938
3939 #===================================================================
3940 # f_get_9x_kernel_data
3941 #        This function queries the kernel for various parameters.
3942 #===================================================================
3943 function f_get_9x_kernel_data
3944 {
3945
3946   Debug "Beginning 9x KERNEL check."
3947   if (($BATCH))
3948   then
3949     print -n "collecting kernel data "
3950   fi
3951   shmmni=$(echo 'shmmni/D'|adb $kernel /dev/kmem \
3952            | tail -1 | awk '{print $2}')
3953   maxfiles=$(echo 'maxfiles/D'|adb  $kernel /dev/kmem \
3954            | tail -1 | awk '{print $2}')
3955   if (($BATCH))
3956   then
3957     print -n "."
3958   fi
3959   shmmax=$(echo 'shmmax/D'|adb $kernel /dev/kmem \
3960            | tail -1 | awk '{print $2}')
3961   shmseg=$(echo 'shmseg/D'|adb $kernel /dev/kmem \
3962            | tail -1 | awk '{print $2}')
3963   shmem=$(echo 'shmem/D'|adb $kernel /dev/kmem \
3964            | tail -1 | awk '{print $2}')
3965   if (($BATCH))
3966   then
3967     print -n "."
3968   fi
3969   maxfiles_lim=$(echo 'maxfiles_lim/D'|adb $kernel /dev/kmem \
3970            | tail -1 | awk '{print $2}')
3971   maxuprc=$(echo 'maxuprc/D'|adb $kernel /dev/kmem \
3972            | tail -1 | awk '{print $2}')
3973   if (($BATCH))
3974   then
3975     print -n "."
3976   fi
3977   nproc=$(echo 'nproc/D'|adb $kernel /dev/kmem \
3978            | tail -1 | awk '{print $2}')
3979   nfile=$(echo 'nfile/D'|adb $kernel /dev/kmem \
3980            | tail -1 | awk '{print $2}')
3981   if (($BATCH))
3982   then
3983     print -n "."
3984   fi
3985   nflocks=$(echo 'nflocks/D'|adb $kernel /dev/kmem \
3986            | tail -1 | awk '{print $2}')
3987   ninode=$(echo 'ninode/D'|adb $kernel /dev/kmem \
3988            | tail -1 | awk '{print $2}')
3989   if (($BATCH))
3990   then
3991     print -n "."
3992   fi
3993 # PA8000 chips support variable page sizes
3994   super_page_supp=$(echo cpu_has_var_size_pages/D | adb $kernel /dev/kmem \
3995            | tail -1 | awk '{print $2}')
3996   case $super_page_supp in
3997       0)  super_page_support=no;;
3998       1)  super_page_support=yes;;
3999       *)  super_page_support=n/a;;  # not found in kernel
4000   esac
4001   if (($BATCH))
4002   then
4003     print -n "."
4004   fi
4005   npty=$(echo 'npty/D'|adb $kernel /dev/kmem \
4006            | tail -1 | awk '{print $2}')
4007 # check for asynch disc writes enabled
4008   fs_async=$(echo 'fs_async/D'|adb $kernel /dev/kmem \
4009            | tail -1 | awk '{print $2}')
4010   if ((${fs_async} == 0))
4011   then
4012     fs_async=no
4013   else
4014     fs_async=yes
4015   fi
4016   if (($BATCH))
4017   then
4018     print -n "."
4019   fi
4020   nbuf=$(echo 'nbuf/D'|adb $kernel /dev/kmem \
4021            | tail -1 | awk '{print $2}')
4022   bufpages=$(echo 'bufpages/D'|adb $kernel /dev/kmem \
4023            | tail -1 | awk '{print $2}')
4024
4025   if (($BATCH))
4026   then
4027     print -n "."
4028   fi
4029   msgmap=$(echo 'msgmap/D'|adb $kernel /dev/kmem \
4030            | tail -1 | awk '{print $2}')
4031   if (($BATCH))
4032   then
4033     print -n "."
4034   fi
4035   maxdsiz=$(echo 'maxdsiz/D'|adb $kernel /dev/kmem \
4036            | tail -1 | awk '{print $2}')
4037   maxssiz=$(echo 'maxssiz/D'|adb $kernel /dev/kmem \
4038            | tail -1 | awk '{print $2}')
4039   if (($BATCH))
4040   then
4041     print -n "."
4042   fi
4043   maxtsiz=$(echo 'maxtsiz/D'|adb $kernel /dev/kmem \
4044            | tail -1 | awk '{print $2}')
4045   maxuprc=$(echo 'maxuprc/D'|adb $kernel /dev/kmem \
4046            | tail -1 | awk '{print $2}')
4047   if (($BATCH))
4048   then
4049     print -n "."
4050   fi
4051   ncdnode=$(echo 'ncdnode/D'|adb $kernel /dev/kmem \
4052            | tail -1 | awk '{print $2}')
4053   if (($BATCH))
4054   then
4055     print -n "."
4056   fi
4057   sema=$(echo 'sema/D'|adb $kernel /dev/kmem \
4058            | tail -1 | awk '{print $2}')
4059   if (($BATCH))
4060   then
4061     print -n "."
4062   fi
4063   semmap=$(echo 'semmap/D'|adb $kernel /dev/kmem \
4064            | tail -1 | awk '{print $2}')
4065   if (($BATCH))
4066   then
4067     print -n "."
4068   fi
4069 # get LVM related kernel parameters
4070   maxvgs=$(echo 'maxvgs/D'|adb $kernel /dev/kmem \
4071            | tail -1 | awk '{print $2}')
4072   lv_vgs_opn=$(echo 'lv_vgs_opn/D'|adb $kernel /dev/kmem \
4073            | tail -1 | awk '{print $2}')
4074   if (($BATCH))
4075   then
4076     print -n "."
4077   fi
4078   lv_lvs_opn=$(echo 'lv_lvs_opn/D'|adb $kernel /dev/kmem \
4079            | tail -1 | awk '{print $2}')
4080   lv_pbuf_cnt=$(echo 'lv_pbuf_cnt/D'|adb $kernel /dev/kmem \
4081            | tail -1 | awk '{print $2}')
4082   if (($BATCH))
4083   then
4084     print -n "."
4085   fi
4086   lv_pbuf_inuse=$(echo 'lv_pbuf_inuse/D'|adb $kernel /dev/kmem \
4087            | tail -1 | awk '{print $2}')
4088   lv_pbuf_maxuse=$(echo 'lv_pbuf_maxuse/D'|adb $kernel /dev/kmem \
4089            | tail -1 | awk '{print $2}')
4090   if (($BATCH))
4091   then
4092     print -n "."
4093   fi
4094   lv_pbuf_pending_Q=$(echo 'lv_pbuf_pending_Q/D'|adb $kernel /dev/kmem \
4095            | tail -1 | awk '{print $2}')
4096
4097   if (($HTML))
4098   then
4099     print "</PRE>" >> /tmp/sysinfo.$$.kernout
4100     print "<A name='Kernel'></A>" >> /tmp/sysinfo.$$.kernout
4101     print "<FONT COLOR=red>" >> /tmp/sysinfo.$$.kernout
4102     print "<H2>Kernel Data</H2></FONT>" >> /tmp/sysinfo.$$.kernout
4103     print "<PRE><font size = '4'>" >> /tmp/sysinfo.$$.kernout
4104   else
4105     print "KERNEL DATA" >> /tmp/sysinfo.$$.kernout
4106     print "===========" >> /tmp/sysinfo.$$.kernout
4107   fi
4108   print "Super page support (cpu_has_var_size_pages) $super_page_support" >> /tmp/sysinfo.$$.kernout
4109   print "" >> /tmp/sysinfo.$$.kernout
4110   print "Max shared memory segments in system (shmmni)$shmmni" >> /tmp/sysinfo.$$.kernout
4111   print "Enable Sys V Shared Memory(shmem)            ${shmem}" >> /tmp/sysinfo.$$.kernout
4112
4113   print "" >> /tmp/sysinfo.$$.kernout
4114   print "Soft file limit per process (maxfiles)       $maxfiles" >> /tmp/sysinfo.$$.kernout
4115   print "Hard file limit per process (maxfiles_lim)   $maxfiles_lim" >> /tmp/sysinfo.$$.kernout
4116   print "Max number of processes (nproc)              $nproc" >> /tmp/sysinfo.$$.kernout
4117   print "Max number of user processes (maxuprc)       $maxuprc" >> /tmp/sysinfo.$$.kernout
4118   print "Number of open files in system (nfile)       $nfile" >> /tmp/sysinfo.$$.kernout
4119   print "Maximum number of file locks (nflocks)       $nflocks" >> /tmp/sysinfo.$$.kernout
4120   print "Max number of in-core inodes (ninode)        $ninode" >> /tmp/sysinfo.$$.kernout
4121   print "Asynchronous disk writes allowed (fs_async)  $fs_async" >> /tmp/sysinfo.$$.kernout
4122   print "Number of pseudo-teletypes (npty)            $npty" >> /tmp/sysinfo.$$.kernout
4123   print "Number of filesystem buffer headers (nbuf)   $nbuf" >> /tmp/sysinfo.$$.kernout
4124   print "Number of buffer pages in cache (bufpages)   $bufpages" >> /tmp/sysinfo.$$.kernout
4125   print "Max Number of Message Map Entries (msgmap)   $msgmap" >> /tmp/sysinfo.$$.kernout
4126   print "Max Data Segment Size (Bytes) (maxdsiz)      $maxdsiz" >> /tmp/sysinfo.$$.kernout
4127   print "Max Stack Segment Size (Bytes) (maxssiz)     $maxssiz" >> /tmp/sysinfo.$$.kernout
4128   print "Max Text Segment Size (Bytes) (maxtsiz)      $maxtsiz" >> /tmp/sysinfo.$$.kernout
4129   print "Enable Sys V Semaphores (sema)               $sema" >> /tmp/sysinfo.$$.kernout
4130
4131   if (($lvm_installed))
4132   then
4133     print "" >> /tmp/sysinfo.$$.kernout
4134     print "LVM Parms" >> /tmp/sysinfo.$$.kernout
4135     print "  Max number of volume groups (maxvgs)       $maxvgs" >> /tmp/sysinfo.$$.kernout
4136     print "  Number of open volume groups (lv_vgs_opn)  $lv_vgs_opn" >> /tmp/sysinfo.$$.kernout
4137     print "  Number of open logical volumes (lv_lvs_opn)$lv_lvs_opn" >> /tmp/sysinfo.$$.kernout
4138     print "  Lvol pbuf count (lv_pbuf_cnt)              $lv_pbuf_cnt" >> /tmp/sysinfo.$$.kernout
4139     print "  Lvol pbuf current usage (lv_pbuf_inuse)    $lv_pbuf_inuse" >> /tmp/sysinfo.$$.kernout
4140     print "  Lvol pbuf high water mark (lv_pbuf_maxuse) $lv_pbuf_maxuse" >> /tmp/sysinfo.$$.kernout
4141     print "  lv_pbuf_pending_Q:                         $lv_pbuf_pending_Q \n" >> /tmp/sysinfo.$$.kernout
4142   fi
4143   f_display_file /tmp/sysinfo.$$.kernout
4144   f_display_file /tmp/sysinfo.$$.kernwarn
4145   if (($BATCH))
4146   then
4147     print ""
4148   fi
4149 }                # end of f_get_9x_kernel_data
4150
4151
4152 #===================================================================
4153 # f_get_network_data
4154 #        This function queries each lan card and retrieves information
4155 #        for each one.
4156 #===================================================================
4157 function f_get_network_data
4158 {
4159   Debug "Beginning NETWORK check."
4160   if (($BATCH))
4161   then
4162     print -n "scanning network cards "
4163   fi
4164   GetCurrentDNS
4165   #DOMAIN=$(nslookup ${sysname} | grep Name | grep -v Server | cut -d. -f2-6)
4166   default_router=$( netstat -r | grep default | awk '{print $2}')
4167   default_router_ip=$( netstat -rn | grep default | awk '{print $2}')
4168   if (($HTML))
4169   then
4170     print "</PRE>"                 >> /tmp/sysinfo.$$.netout
4171     print "<A NAME='Network'></A>" >> /tmp/sysinfo.$$.netout
4172     print "<H2>" >> /tmp/sysinfo.$$.netout
4173     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> /tmp/sysinfo.$$.netout
4174     print "<FONT COLOR=red>" >> /tmp/sysinfo.$$.netout
4175     print "Network Data </H2>" >> /tmp/sysinfo.$$.netout
4176     print "</FONT><PRE><font size = '4'>" >> /tmp/sysinfo.$$.netout
4177   else
4178     print "NETWORK DATA" >> /tmp/sysinfo.$$.netout
4179     print "============" >> /tmp/sysinfo.$$.netout
4180   fi
4181   print "DOMAIN NAME:    ${CURRENT_DOMAIN}" >> /tmp/sysinfo.$$.netout
4182   print -n "DNS SERVER:     ${CURRENT_DNS_SERVER}  " >> /tmp/sysinfo.$$.netout
4183   print "(${CURRENT_DNS_SERVER_IP})" >> /tmp/sysinfo.$$.netout
4184   print -n "DEFAULT ROUTER: ${default_router}  "  >> /tmp/sysinfo.$$.netout
4185   print "(${default_router_ip})"  >> /tmp/sysinfo.$$.netout
4186   print "" >> /tmp/sysinfo.$$.netout
4187
4188   #for CARD in $(netstat -in | grep lan | awk '{print $1}' | sed 's/\*//')
4189   # 1.42 change to handle multiple I/F cards
4190   if (( ${osmajor} >= 10 ))
4191   then
4192     card_list=$(/etc/lanscan -i | awk '{print $1}')
4193     Debug " 10.x using lanscan -i"
4194   else
4195     card_list=$(/etc/lanscan | tail +3 | awk '{printf("%s\n",$5)}')
4196     Debug " 9.x using lanscan "
4197   fi
4198   for CARD in ${card_list}
4199   do
4200     ifconfig "${CARD}" > /tmp/sysinfo.$$.ipdata 2>&1
4201     if [ $? -eq 0 ]
4202     then
4203       Debug " checking lan card -> $CARD"
4204       #lanconfig "$CARD" >> /tmp/sysinfo.$$.ipdata 2>&1
4205       #card_type=$(lanconfig "$CARD" | grep ${CARD} | awk '{print $2}')
4206       if (( ${osmajor} >= 11 ))
4207       then
4208         card_type=$(lanscan -im  | grep "${CARD} " | awk '{print $NF}')
4209       else
4210         card_type=$(lanscan | grep "${CARD} " | awk '{print $8}')
4211       fi
4212       Debug "  card_type=$card_type"
4213       #MWR fix for incorrect handling of multiple lan cards
4214       #macaddr=$(/etc/lanscan | grep x | awk '{print $2}')
4215       macaddr=$(/etc/lanscan | grep "${CARD} " | awk '{print $2}')
4216       lan_hw_addr=$(/etc/lanscan | grep "${CARD} " | awk '{print $1}')
4217       nmid=$(/etc/lanscan | grep "${CARD} " | awk '{print $7}')
4218       ip_addr=$(grep inet /tmp/sysinfo.$$.ipdata | awk '{print $2}')
4219       ip_addr_name=$(LookupName ${ip_addr})
4220       lanspeed=$(lanadmin -s ${nmid} | awk '{print $3}')
4221       netmask=$(grep inet /tmp/sysinfo.$$.ipdata | awk '{print $4}')
4222
4223       #convert hex netmask to decimal-dot.
4224       typeset -Z8  hex=0${netmask#0x}; typeset +Z hex
4225       typeset -L2  ott=
4226       typeset -i10 dec=
4227       netmask=""
4228       while [ "$hex" ]; do
4229         ott=$hex
4230         dec=16#$ott
4231         netmask=$netmask.$dec
4232         hex=${hex#??}
4233       done
4234       netmask=${netmask#.}
4235
4236       broadcast=$(grep inet /tmp/sysinfo.$$.ipdata | awk '{print $6}')
4237       if (($HTML))
4238       then
4239         print "</PRE>" >> /tmp/sysinfo.$$.netout
4240         print "<H3>INTERFACE DATA for ${CARD}</H3>" >> /tmp/sysinfo.$$.netout
4241         print "<PRE><font size = '4'>" >> /tmp/sysinfo.$$.netout
4242       else
4243         print "INTERFACE DATA for ${CARD}" >> /tmp/sysinfo.$$.netout
4244         print "===========================" >> /tmp/sysinfo.$$.netout
4245       fi
4246       #print "NMID:        ${nmid}" >> /tmp/sysinfo.$$.netout
4247       print "H/W ADDR:    ${lan_hw_addr}" >> /tmp/sysinfo.$$.netout
4248       print "CARD TYPE:   ${card_type}" >> /tmp/sysinfo.$$.netout
4249       print "SPEED:       ${lanspeed}" >> /tmp/sysinfo.$$.netout
4250       print "MAC ADDRESS: ${macaddr}" >> /tmp/sysinfo.$$.netout
4251       print -n "IP ADDRESS:  ${ip_addr}" >> /tmp/sysinfo.$$.netout
4252       print "   (${ip_addr_name})" >> /tmp/sysinfo.$$.netout
4253       print "BROADCAST:   ${broadcast}" >> /tmp/sysinfo.$$.netout
4254       print "NETMASK:     ${netmask}\n" >> /tmp/sysinfo.$$.netout
4255     fi
4256     if (($BATCH))
4257     then
4258       print -n "."
4259     fi
4260   done
4261   f_display_file /tmp/sysinfo.$$.netout 
4262   if (($BATCH))
4263   then
4264     print
4265   fi
4266 }                # end of f_get_network_data
4267
4268 function query_EMC_disks
4269 {
4270 Debug "Beginning query_EMC_disks"
4271 if [ -f ${where}/inq.hp ]
4272 then
4273   Debug "  found inq.hp"
4274   #inq.hp  
4275 else
4276   Debug "  Could not find inq.hp....no query done."
4277 fi
4278
4279 }
4280 rawDiskFilter () {
4281     # Filters out the first raw disk file after an HP Claimed disk
4282         awk '
4283         ( $0 ~ "CLAIMED" )              { hit=0 }
4284         ( $0 ~ "CLAIMED" && $0 ~ "HP")  { hit=1; next }
4285         ( $0 !~ "CLAIMED" && hit==1)    { hit=0; print $2 }
4286         '
4287 } # rawDiskFilter()
4288
4289
4290 #===================================================================
4291 # f_get_physical_disk_data
4292 #        This function scans each physical disk.
4293 #        It uses ioscan to collect disk info and the queries each
4294 #        device using diskinfo. 
4295 #        The output is displayed in sorted order.
4296 #===================================================================
4297 function f_get_physical_disk_data
4298 {
4299   Debug "Beginning PHYSICAL DISK check."
4300 # first let's print header information
4301   if (($HTML))
4302   then
4303     print "</PRE>"                             >> /tmp/sysinfo.$$.physinfoh
4304     print "<A NAME='Physical'></A>"            >> /tmp/sysinfo.$$.physinfoh
4305     print "<H2>"                               >> /tmp/sysinfo.$$.physinfoh
4306     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> /tmp/sysinfo.$$.physinfoh
4307     print "<FONT COLOR=red>"                   >> /tmp/sysinfo.$$.physinfoh
4308     print "Physical Disk Data </H2>"           >> /tmp/sysinfo.$$.physinfoh
4309     print "</FONT><PRE>"                       >> /tmp/sysinfo.$$.physinfoh
4310     print "</PRE>"                                >> /tmp/sysinfo.$$.boot
4311     print "<H3>Bootable Disks</H3>"               >> /tmp/sysinfo.$$.boot
4312     print "<PRE><font size = '3'>"                >> /tmp/sysinfo.$$.boot
4313     print    "Volume Name                 H/W Path    Auto Boot String" >> \
4314               /tmp/sysinfo.$$.boot
4315     print -- "--------------            ------------  ----------------" >> \
4316               /tmp/sysinfo.$$.boot
4317     print "<font size = '4'>"                     >> /tmp/sysinfo.$$.boot
4318   else
4319     print    "PHYSICAL DISK DATA" >> /tmp/sysinfo.$$.physinfoh
4320     print    "==================" >> /tmp/sysinfo.$$.physinfoh
4321     print    "BOOTABLE DISKS" >> /tmp/sysinfo.$$.boot
4322     print    "==============" >> /tmp/sysinfo.$$.boot
4323     print    "Volume Name                    H/W Path    Auto Boot String" >> \
4324               /tmp/sysinfo.$$.boot
4325     print -- "--------------               ------------  ----------------" >> \
4326               /tmp/sysinfo.$$.boot
4327   fi
4328
4329  # Header for XP256 Information
4330   print > /tmp/sysinfo.$$.256header
4331   print "XP256 Disc Array Information" >> /tmp/sysinfo.$$.256header
4332   print "============================" >> /tmp/sysinfo.$$.256header
4333   print -n "                                      " >> /tmp/sysinfo.$$.256header
4334   print "                                    Size" >> /tmp/sysinfo.$$.256header
4335   print -n "Device File            Port  Scsi  Lun CU:Ldev Serial#" \
4336                                    >> /tmp/sysinfo.$$.256header
4337   print "           Type     (MB)" >> /tmp/sysinfo.$$.256header
4338
4339  # Header for NIKE Array Information
4340   print > /tmp/sysinfo.$$.arrayheader
4341   print "Disk Array Information" >> /tmp/sysinfo.$$.arrayheader
4342   print "======================" >> /tmp/sysinfo.$$.arrayheader
4343   
4344   if (($PMAP))
4345   then
4346     if (($HTML))
4347     then
4348       print "</PRE>"                            >> /tmp/sysinfo.$$.pmap
4349       print "<A NAME='Pmap'></A>"               >> /tmp/sysinfo.$$.pmap
4350       print "<H2>"                               >> /tmp/sysinfo.$$.pmap
4351       print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> /tmp/sysinfo.$$.pmap
4352       print "<FONT COLOR=red>" >> /tmp/sysinfo.$$.pmap
4353       print "Physical Disk To Logical Volume Mapping</H2>" >> /tmp/sysinfo.$$.pmap
4354       print "</FONT><PRE><font size = '4'>"        >> /tmp/sysinfo.$$.pmap
4355     else
4356       print    "PHYSICAL DISK TO LOGICAL VOLUME MAPPING" >> /tmp/sysinfo.$$.pmap
4357       print    "=======================================" >> /tmp/sysinfo.$$.pmap
4358     fi
4359     print -n "Physical Disk                           " >> /tmp/sysinfo.$$.pmap
4360     print    "     Alternate Link" >> /tmp/sysinfo.$$.pmap
4361     print    "       Logical Volume     LE        PE" >> /tmp/sysinfo.$$.pmap
4362     print -n -- "----------------------------------------" >> /tmp/sysinfo.$$.pmap
4363     print --    "-----------------------" >> /tmp/sysinfo.$$.pmap
4364   fi
4365   Debug "  calling check_if_scan_done"
4366   check_if_scan_done io_scan
4367   print -n "scanning physical disks "
4368
4369 #get physical disk names
4370   if (( $osmajor >= 10 ))
4371   then
4372     Debug "Found 10.x system"
4373 #   hw_path=$(ioscan -kfC disk | sed '1,/^=/d' | awk '{print $3}')
4374     hw_path=$(grep disk $io_scan_out | awk -F: '{print $11}' | sort)
4375     Debug "hw_path=$hw_path"
4376     for hwpath in ${hw_path}
4377     do
4378       Debug "hwpath=${hwpath}"
4379       lu=""
4380       vendor=""
4381       tmpin=$(echo $hwpath | cut -d. -f1)
4382 ### Changed 6/15/99 J.Semroc - to improve Performance reuse existing data
4383 ###   inst=$(ioscan -kf | grep "^ext_bus" | grep " ${tmpin} " \
4384 ###               | grep -v fcpdev | awk '{print $2}')
4385       inst=$(grep $hwpath $io_scan_out | grep disk | awk '{print $NF}' \
4386                  | cut -d: -f2)
4387 ### end of Change
4388       #scsi_addr=$(echo $hwpath | cut -d. -f2)
4389       #unit_addr=$(echo $hwpath | cut -d. -f3)
4390       #physvol="/dev/dsk/c${inst}t${scsi_addr}d${unit_addr}"
4391       #rphysvol="/dev/rdsk/c${inst}t${scsi_addr}d${unit_addr}"
4392       #physvol=$(ioscan -kfnH ${hwpath} | awk ' BEGIN {FS=" "; RS=" "} /dev\/dsk/ {printf("%s", $1)}')
4393       #rphysvol=$(ioscan -kfnH ${hwpath} | awk ' BEGIN {FS=" "; RS=" "} /dev\/rdsk/ {printf("%s", $1)}')
4394       #block_major=$(grep "$hwpath" $io_scan_out | grep disk | awk -F: '{print $6}')
4395       #char_major=$(grep "$hwpath" $io_scan_out | grep disk | awk -F: '{print $7}')
4396       #block_minor=$(grep "$hwpath" $io_scan_out | grep disk | awk -F: '{print $8}')
4397       #Debug "  block_major = ${block_major}"
4398       #Debug "  char_major  = ${char_major}"
4399       #Debug "  block_minor = ${block_minor}"
4400
4401       scsi_addr=$(echo $hwpath | awk -F. '{print $(NF-1)}')
4402       unit_addr=$(echo $hwpath | awk -F. '{print $NF}')
4403       physvol="/dev/dsk/c${inst}t${scsi_addr}d${unit_addr}"
4404       rphysvol="/dev/rdsk/c${inst}t${scsi_addr}d${unit_addr}"
4405
4406       Debug "Physical volume ${physvol}"
4407       Debug "  tmpin=${tmpin}"
4408       Debug "  inst=${inst} scsi_addr=${scsi_addr} unit_addr=${unit_addr}"
4409
4410       XP256=$(grep ${hwpath} ${io_scan_out} | weed_targets | awk -F: '{print $18}')
4411       if [[ ${XP256} = *OPEN* ]] 
4412       then
4413         print -n "X"
4414         if [[ -f /usr/contrib/bin/inquiry256 ]]
4415         then 
4416           inqcmd="/usr/contrib/bin/inquiry256"
4417         else
4418           inqcmd="${where}/inquiry256"
4419         fi
4420         Debug "XP256 disc array found! ${XP256} ${hwpath}"
4421         Debug "inqcmd=${inqcmd}"
4422         info=$(diskinfo -v ${rphysvol}  2>&1)
4423         case "$info" in
4424           *"No such file or directory"* )
4425             Debug "  diskinfo reports No such file or directory on $physvol"
4426             #echo "$Inq" | \
4427             #   awk -F"+" '{printf("%55s\n"),$1}' \
4428             #      >> /tmp/sysinfo.$$.inq256
4429             rphysvold=$rphysvol
4430             print "$rphysvold   No such file or directory" \
4431                   >> /tmp/sysinfo.$$.inq256
4432           ;;
4433           *"No such device or address"* )
4434             Debug "  diskinfo reports No such device or address on $physvol"
4435            #echo "$Inq" | \
4436            #   awk -F"+" '{printf("%55s\n"),$1}' \
4437            #      >> /tmp/sysinfo.$$.inq256
4438             rphysvold=$rphysvol
4439             print "$rphysvold   No such device or address" \
4440                   >> /tmp/sysinfo.$$.inq256
4441           ;;
4442           * )
4443           Debug "  found a device (no diskinfo error)...so follow it"
4444           Inq=$(${inqcmd} ${rphysvol} 2>&1 )
4445           psize=$(echo $info | sed -e 's/^.*size: //' -e 's/ .*$//')
4446           psize_mb=$(expr ${psize} / 1024)
4447           product1=$(echo $info | sed -e 's/^.*product id: //' -e 's/ .*$//')
4448           echo "$Inq+$product1+$psize_mb" | \
4449              awk -F"+" '{printf("%55s%16s%8s\n"),$1,$2,$3}' \
4450                 >> /tmp/sysinfo.$$.inq256
4451         esac
4452       fi  # end of XP256
4453
4454       case ${XP256} in
4455
4456         *C1300* | *C2300* | *C3400* )
4457           Debug " found an Nike disk array at $hwpath"
4458           print -n "N" 
4459           #f_get_array_data
4460         ;;
4461         *C2430* )
4462           Debug " found a Cascade disk array at $hwpath"
4463           print -n "C" 
4464           #f_get_array_data
4465         ;;
4466         *C5447A* | *C3586A* )
4467           # C5447A is 12H   C3586A is 12
4468           Debug " found a AutoRaid disk array at $hwpath"
4469           print -n "A" 
4470           #f_get_array_data
4471         ;;
4472         *A5277A* )
4473           Debug " found a FC60 disk array at $hwpath"
4474           print -n "F" 
4475           #f_get_array_data
4476         ;;
4477         * )
4478           Debug " found a jbod disk at $hwpath"
4479           print -n "." 
4480           #f_get_array_data
4481         ;;
4482       esac
4483
4484
4485 # Run pvdisplay to get the disk information
4486       pvdisplay -v ${physvol} > /tmp/sysinfo.$$.pvdisp 2>&1
4487 # Check for alternate link so that we don't try to access it
4488       Debug "  Checking if this is an alternate link"
4489       grep "Using Primary Link" /tmp/sysinfo.$$.pvdisp > /dev/null 2>&1
4490       detect_alt_link=$?
4491       if ((detect_alt_link == 0))
4492       then
4493         Debug "  this IS an alternate link, so skip"
4494         alt_link=true
4495       elif [[ "${rphysvol}" = "" ]] then
4496         Debug "  no physvol found for $hwpath"
4497         if ((! (($exit_code)) ))
4498         then
4499           exit_code=${WARN}
4500         fi
4501         print "WARNING (${sysname}):No device file found for $hwpath" >> \
4502                      /tmp/sysinfo.$$.errwarn
4503       else
4504         Debug "  this is NOT an alternate link, so query disk"
4505         hwpathd=${hwpath} # for display purposes
4506         #info=$(diskinfo -v /dev/rdsk/c${inst}t${scsi_addr}d${unit_addr} 2>&1)
4507         info=$(diskinfo -v ${rphysvol}  2>&1)
4508         Debug "info= ${info}"
4509         case "$info" in
4510           *"Device busy"* )
4511             Debug "  diskinfo reports Device Busy Error on $rphysvol"
4512             lu=$(grep ${hwpath} $io_scan_out | grep -v target \
4513                   | awk '{print $2}')
4514             vendor1=$(ioscan -H $hwpath | tail -1 | awk '{print $3}')
4515             vendor=${vendor1}
4516             product1=$(ioscan -H $hwpath | tail -1 | awk '{print $NF}')
4517             product=${product1}
4518             print "${physvol}${lu}${hwpathd} ${vendor}${product}" \
4519                    >> /tmp/sysinfo.$$.physinfo
4520             Debug "  ${physvol}${lu}${hwpathd}${vendor}${product}" 
4521           ;;
4522           *"No such file or directory"* )
4523             Debug "  diskinfo reports No such file or directory on $physvol"
4524             lu="n/f"
4525             vendor1=$(ioscan -H $hwpath | tail -1 | awk '{print $3}')
4526             vendor=${vendor1}
4527             product1=$(ioscan -H $hwpath | tail -1 | awk '{print $NF}')
4528             product=${product1}
4529             print "${physvol}${lu}${hwpathd} ${vendor}${product}" \
4530                      >> /tmp/sysinfo.$$.physinfo
4531           ;;
4532           *"No such device or address"* )
4533             Debug "  diskinfo reports No such device or address on $physvol"
4534             lu="n/f"
4535             vendor1=$(ioscan -H $hwpath | tail -1 | awk '{print $3}')
4536             vendor=${vendor1}
4537             product1=$(ioscan -H $hwpath | tail -1 | awk '{print $NF}')
4538             product=${product1}
4539             print "${physvol}${lu}${hwpathd} ${vendor}${product}" \
4540                      >> /tmp/sysinfo.$$.physinfo
4541           ;;
4542           * )
4543             Debug "  found a device (no diskinfo error)...so follow it"
4544         
4545           #lu=$(grep ${hwpath} $io_scan_out | grep -v target | awk '{print $2}')
4546 ### Changed 6/15/99 J.Semroc - to improve Performance reuse existing data
4547 ###       lu=$(ioscan -kfCdisk | grep "${hwpath}" | awk '{print $2}')
4548           lu=$(grep ${hwpath} $io_scan_out | grep -v target | grep disk | \
4549                awk -F: '{print $13}')
4550 ### end of Change
4551           Debug "LU = ${lu}"
4552           ludebug=$(grep ${hwpath} $io_scan_out | grep -v target )
4553           Debug "ludebug= ${ludebug}"
4554           psize=$(echo $info | sed -e 's/^.*size: //' -e 's/ .*$//')
4555           psize_mb=$(expr ${psize} / 1024)
4556           product1=$(echo $info | sed -e 's/^.*product id: //' -e 's/ .*$//')
4557   
4558           vendor1=$(echo $info | sed -e 's/^.*vendor: //' -e 's/ .*$//')
4559           vendor=${vendor1}
4560           rev_level=$(echo $info | sed -e 's/^.*rev level: //' -e 's/ .*$//')
4561           #rev_level=$(echo $info | grep "rev level" \
4562           #       | awk '{print $3}')
4563           product=${product1}
4564           if [[ "${product1}" != "CD-ROM" ]] && [[ "${product1}" != "DVD-ROM" ]]
4565           then
4566             ((total_p_mb=total_p_mb + psize_mb))
4567             ((pcount=pcount + 1))
4568           fi
4569           Debug "    vendor1=$vendor1"
4570           Debug "    product=$product"
4571           Debug "    rev_level=$rev_level"
4572           Debug "    psize=$psize"
4573           Debug "    psize_mb=$psize_mb"
4574 #
4575 # check for bootable disk
4576 #
4577           Debug "  Checking for Bootable PV"
4578           lifls ${physvol} 2> /dev/null | grep -i isl > /dev/null 2>&1
4579           if [ $? -eq 0 ]
4580           then   
4581             Debug "    Found Bootable PV at ${physvol}"
4582             bootable_pv="Y"
4583             lifls ${rphysvol} | grep AUTO > /dev/null 2>&1
4584             if [ $? -eq 0 ]
4585             then   
4586               Debug "    Found auto_string=$auto_string"
4587               auto_string=$(lifcp ${rphysvol}:AUTO -)
4588               print "${physvol}${hwpathd}   ${auto_string}" >> \
4589                        /tmp/sysinfo.$$.boot
4590             else
4591               Debug "    Did not find auto_string."
4592             fi
4593           else 
4594             Debug "    Did not find Bootable PV on ${physvol}"
4595             bootable_pv="N"
4596           fi
4597           if grep "find the volume group" /tmp/sysinfo.$$.pvdisp > /dev/null
4598           then
4599             Debug "  NON-LVM   /dev/dsk/c${inst}t${scsi_addr}d${unit_addr}" 
4600             Debug "    id as::${vendor}${product}${psize_mb} Mbytes." 
4601             #lu="nlv"
4602           elif grep "path does not correspond" /tmp/sysinfo.$$.pvdisp > /dev/null
4603           then
4604             Debug "Specified path not found! ${rphysvol}"
4605           else            
4606             Debug "  LVM disk"
4607 ### Changed 6/15/99 J.Semroc - to improve Performance reuse existing data
4608 ###         lu=$(ioscan -kfCdisk | grep " ${hwpath}" | awk '{print $2}')
4609             lu=$(grep ${hwpath} $io_scan_out | grep -v target | grep disk | \
4610                  awk -F: '{print $13}')
4611 ### end of Change
4612             if [[ "${vendor1}" = "EMC" ]]  # && ((detect_alt_link == 0))
4613             then
4614               EMC_found=1
4615 ### Correction 6/15/99  J.Semroc - physvol was misspelled
4616               Debug " Found EMC  at ${physvol}."
4617               Debug "   detect_alt_link = ${detect_alt_link}"
4618               bblvols=$(pvdisplay -v ${physvol} |  \
4619                       awk ' /current/ {print $3}' | sort | uniq | \
4620                       grep -v "/dsk/")
4621               for bblvol in $bblvols
4622               do
4623                 bblock=$(lvdisplay $bblvol | awk ' /Bad block/ {print $3}')
4624                 Debug "    bblvol=  $bblvol"
4625                 Debug "    bblock=  $bblock"
4626                 if [[ "${bblock}" != "NONE" ]]
4627                 then
4628                   if ((! (($exit_code)) ))
4629                   then
4630                     exit_code=${WARN}
4631                   fi
4632                   print "WARNING (${sysname}):EMC w/ LVM bad block enabled on ${bblvol}" >> /tmp/sysinfo.$$.errwarn
4633                 fi
4634               done
4635             fi
4636             if (($PMAP)) 
4637             then
4638               Debug "  Begin PHYSICAL TO LOGICAL Mapping"
4639               alt_link=""
4640               if  (($osmajor == 11))
4641               then
4642                 # PVdisplay looks different on 10.20 (MWR)
4643                 alt_link=$(grep "^PV Name" /tmp/sysinfo.$$.pvdisp | \
4644                    grep "Alternate Link" | awk '{printf "%s ", $3}' )
4645                 Debug "  =11     alt_link=$alt_link"
4646               elif (($osmajor == 10)) && (($osminor >= 20))
4647               then
4648                 # PVdisplay looks different on 10.20 (MWR)
4649                 alt_link=$(grep "^PV Name" /tmp/sysinfo.$$.pvdisp | \
4650                    grep "Alternate Link" | awk '{printf "%s ", $3}' )
4651                 Debug "  >=10.20     alt_link=$alt_link"
4652               else 
4653                 #less than 10.20
4654                 alt_link=$(grep "^   PV Name" /tmp/sysinfo.$$.pvdisp | \
4655                    grep "Alternate Link" | awk '{printf "%s ", $3}' )
4656                 Debug "  <10.20   alt_link=$alt_link"
4657               fi
4658               if  [ "$alt_link" = "" ]
4659               then
4660                 alt_link="None"
4661               fi
4662               Debug "    alt_link=$alt_link"
4663               print "${physvol}                           ${alt_link}" \
4664                  >> /tmp/sysinfo.$$.pmap
4665               sed '1,15d;/current/d;/Status/d;/free/d;' \
4666                 /tmp/sysinfo.$$.pvdisp | \
4667                 sed '/^$/d;/---/d;/LV/d; s/\/dev/    \/dev/' \
4668                 >> /tmp/sysinfo.$$.pmap
4669             fi   # end of PMAP
4670           fi
4671           print -n "${physvol}${lu}${hwpathd} ${vendor}${product}" >> \
4672                       /tmp/sysinfo.$$.physinfo
4673           print " ${psize_mb} ${bootable_pv}" >> \
4674                       /tmp/sysinfo.$$.physinfo
4675           ;;
4676         esac
4677         #print -n "."
4678       fi
4679     done # end of hwpath loop
4680     # end of 10.x system
4681   else      
4682     Debug "must be a 9.x system"
4683     pvol=$(vgdisplay -v 2>&1 | grep "^   PV Name" | grep -v "Alternate Link" \
4684            | sort | awk '{printf "%s ", $3}' )
4685     ioscan -kfCdisk | sort > /tmp/sysinfo.$$.io_disk
4686     #now force access to disks.
4687     for physvol in ${pvol}                        # loop through all phys vols
4688     do
4689       hwpath=$(lssf ${physvol} | awk '{printf "%s ", $(NF -1)}')
4690       hwpathd=${hwpath} # for display purposes
4691       disktype=$(echo ${physvol} | sed s/dsk/rdsk/)
4692       diskinfo -v ${disktype} > /tmp/sysinfo.$$.diskinfo 2>&1
4693       if (($?))
4694       then
4695         print "ERROR:${sysname}: diskinfo reports an error on ${physvol}."
4696         >> /tmp/sysinfo.$$.errwarn
4697         exit_code=${SYS_ERROR}
4698       else
4699         vendor=$(grep "vendor" /tmp/sysinfo.$$.diskinfo \
4700                  | awk '{printf "%s ", $2}')
4701         product1=$(grep "product id" /tmp/sysinfo.$$.diskinfo \
4702                  | awk '{printf "%s ", $3}')
4703         type=$(grep "type" /tmp/sysinfo.$$.diskinfo \
4704                  | cut -b22- )
4705         psize=$(grep "size" /tmp/sysinfo.$$.diskinfo \
4706                  | awk '{printf "%s ", $2}')
4707         psize_mb=$(expr ${psize} / 1024)
4708         lu=$(grep " ${hwpath}" /tmp/sysinfo.$$.io_disk | awk '{print $2}')
4709         rev_level=$(grep "rev level" /tmp/sysinfo.$$.diskinfo \
4710                  | awk '{print $3}')
4711         product=${product1}
4712         if [[ "${product1}" != "CD-ROM" ]] && [[ "${product1}" != "DVD-ROM" ]]
4713         then
4714           ((total_p_mb=total_p_mb + psize_mb))
4715           ((pcount=pcount + 1))
4716         fi
4717         if (($PMAP))
4718         then
4719           pvdisplay -v ${physvol} > /tmp/sysinfo.$$.pvdisp 2>&1
4720           alt_link=""
4721           alt_link=$(grep "^   PV Name" /tmp/sysinfo.$$.pvdisp | \
4722                grep "Alternate Link" | awk '{printf "%s ", $3}' )
4723           #alt_link="/dev/dsk/cxtxdx"
4724           if  [ "$alt_link" = "" ]
4725           then
4726             alt_link="None"
4727           fi
4728           print "${physvol}                           ${alt_link}" \
4729              >> /tmp/sysinfo.$$.pmap
4730           sed '1,15d;/current/d;/Status/d;/free/d;' /tmp/sysinfo.$$.pvdisp | \
4731             sed '/^$/d;/---/d;/LV/d; s/\/dev/    \/dev/' \
4732             >> /tmp/sysinfo.$$.pmap
4733         fi
4734         Debug "\ndisktype=$disktype"
4735         Debug "hwpath=$hwpath"
4736         Debug "vendor=$vendor"
4737         Debug "product=$product"
4738         Debug "psize=$psize"
4739         Debug "psize_mb=$psize_mb"
4740         Debug "lu=$lu"
4741         Debug "type=$type"
4742         Debug "total_p_mb=$total_p_mb"
4743         Debug "pcount=$pcount"
4744         Debug "rev_level=$rev_level"
4745         Debug "alt_link=$alt_link"
4746         print -n "."
4747         print "${physvol}${lu}${hwpathd}${vendor}${product}${psize_mb}" >> /tmp/sysinfo.$$.physinfo
4748       fi
4749     done
4750   fi # end of 9.x
4751
4752   print "                             Rev" > /tmp/sysinfo.$$.disk_rev
4753   print "             HW Path        Level         Serial Number      LUN" \
4754           >> /tmp/sysinfo.$$.disk_rev
4755   print "   ---------------------    -----    ---------------------   ----" \
4756           >> /tmp/sysinfo.$$.disk_rev
4757   
4758   if (( ${cstm_ok} == 0 ))
4759   then
4760   awk '
4761     /Hardware path/ {path = $3; next;}
4762     /Product Id/   {prod = $3; vend = $NF; next;}
4763     /Firmware Rev/ {fw = $NF; next;}
4764     /Logical Unit/ {lu = $NF; next;}
4765     /Serial Number/ {sn = $3; next;}
4766     /Capacity/ {cap = $NF; printf("%24s %8s %24s %6s\n",
4767        path,fw,sn,lu);}' $cstm_disk_out >> /tmp/sysinfo.$$.disk_rev
4768   print "" >> /tmp/sysinfo.$$.disk_rev
4769   fi
4770
4771   if (($EMC_found))
4772   then
4773     Debug "calling EMC query routine"
4774     #query_EMC_disks
4775
4776   fi
4777 #
4778 # check for boot path settings
4779 #
4780   if [[ -f /usr/sbin/setboot ]]
4781   then
4782     pri_boot_path=$(/usr/sbin/setboot | grep Primary | awk '{print $4}')
4783     alt_boot_path=$(/usr/sbin/setboot | grep Alternate | awk '{print $4}')
4784     auto_boot=$(/usr/sbin/setboot | grep Autoboot | awk '{print $3}')
4785     auto_search=$(/usr/sbin/setboot | grep Autosearch | awk '{print $3}' )
4786     print "" >> /tmp/sysinfo.$$.boot
4787     print "Primary Boot Path   = ${pri_boot_path}" >> /tmp/sysinfo.$$.boot
4788     print "Alternate Boot Path = ${alt_boot_path}" >> /tmp/sysinfo.$$.boot
4789     print "Autoboot            = ${auto_boot}"     >> /tmp/sysinfo.$$.boot
4790     print "Autosearch          = ${auto_search}"   >> /tmp/sysinfo.$$.boot
4791   fi
4792   print  "\n" >> /tmp/sysinfo.$$.boot
4793
4794 # now print out totals
4795 ### Changed 6/16/99 J.Semroc sort LU numerically
4796 ###  sort -k2. -o /tmp/sysinfo.$$.physinfos /tmp/sysinfo.$$.physinfo
4797   sort -k2n -o /tmp/sysinfo.$$.physinfos /tmp/sysinfo.$$.physinfo
4798 ### end of Change
4799   rm -f /tmp/sysinfo.$$.physinfo 2>&1
4800   print
4801 # print     "" >> /tmp/sysinfo.$$.physinfoh
4802   print  -n "                         " >> /tmp/sysinfo.$$.physinfoh
4803   print     "                                               Size" >> /tmp/sysinfo.$$.physinfoh
4804   print  -n " Volume Name      LU#         " >> /tmp/sysinfo.$$.physinfoh
4805   print     "     H/W Path     Vendor  /  Model        (MB)  B" >> /tmp/sysinfo.$$.physinfoh
4806   print  -n " --------------   ---       " >> /tmp/sysinfo.$$.physinfoh
4807   print     " ----------------  --------------------    ------ -" >> /tmp/sysinfo.$$.physinfoh
4808   print     "                                                                       ======" >> /tmp/sysinfo.$$.physinfot
4809   print  -n "                                                   Total (MB)" >> /tmp/sysinfo.$$.physinfot
4810   print     "     ${total_p_mb}" >> /tmp/sysinfo.$$.physinfot
4811 ### Changed 6/15/99 J.Semroc - generated the following error
4812 ###  "cat: Cannot use /tmp/sysinfo.14950.physinfod as both input and output."
4813 ###  cat /tmp/sysinfo.$$.physinfo? > /tmp/sysinfo.$$.physinfod
4814   cat /tmp/sysinfo.$$.physinfo? > /tmp/sysinfo.$$.PHYSINFOD
4815   mv /tmp/sysinfo.$$.PHYSINFOD /tmp/sysinfo.$$.physinfod
4816 ### end of Change
4817   print "B = Bootable Disk" >> \
4818              /tmp/sysinfo.$$.physinfod
4819   print "n/v = Not Valid, n/f = Not Found\n" >> \
4820              /tmp/sysinfo.$$.physinfod
4821   f_display_file /tmp/sysinfo.$$.physinfod
4822   print "" >> /tmp/sysinfo.$$.physwarn
4823   f_display_file /tmp/sysinfo.$$.physwarn
4824   f_display_file /tmp/sysinfo.$$.disk_rev
4825   if [[ -f  /tmp/sysinfo.$$.inq256 ]]
4826   then
4827     f_display_file /tmp/sysinfo.$$.256header
4828     print "" >> /tmp/sysinfo.$$.inq256
4829     f_display_file /tmp/sysinfo.$$.inq256
4830   fi
4831
4832   if [[ -f  /tmp/sysinfo.$$.array ]]
4833   then
4834     f_display_file /tmp/sysinfo.$$.arrayheader
4835     print "\n\n" >> /tmp/sysinfo.$$.array
4836     f_display_file  /tmp/sysinfo.$$.array
4837   fi
4838
4839   f_display_file /tmp/sysinfo.$$.boot
4840   if (($PMAP))
4841   then
4842     f_display_file /tmp/sysinfo.$$.pmap
4843   fi
4844   
4845 }                # end of f_get_physical_disk_data
4846
4847 #===================================================================
4848 # f_get_ioscan_data
4849 #===================================================================
4850 function f_get_ioscan_data
4851 {
4852   Debug "  calling check_if_scan_done"
4853   check_if_scan_done io_scan
4854   GREP_V_ARGS="-eboot_console $GREP_V_ARGS"
4855   if (($HTML))
4856   then
4857     print "</PRE>"                          >> /tmp/sysinfo.$$.ioout
4858     print "<A NAME='IO'></A>"               >> /tmp/sysinfo.$$.ioout
4859     print "<H2>"                            >> /tmp/sysinfo.$$.ioout
4860     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> /tmp/sysinfo.$$.ioout
4861     print "<FONT COLOR=red>"                >> /tmp/sysinfo.$$.ioout
4862     print "I/O Configuration Data</H2>"     >> /tmp/sysinfo.$$.ioout
4863     print "</FONT><PRE><font size = '4'>"   >> /tmp/sysinfo.$$.ioout
4864   else
4865     print "I/O CONFIGURATION DATA" >> /tmp/sysinfo.$$.ioout
4866     print "======================" >> /tmp/sysinfo.$$.ioout
4867   fi
4868   print "" >> /tmp/sysinfo.$$.ioout
4869   print "              H/W Path       Driver  Identifier String" >>/tmp/sysinfo.$$.ioout
4870   print "              --------       ------  -----------------" >>/tmp/sysinfo.$$.ioout
4871  
4872   Debug "  `cat ${io_scan_out}`"
4873   if (( ${osmajor} >= 10 ))
4874   then
4875     Debug "found 10.x or later"
4876     Debug "sending $io_scan_out to formatter"
4877     Debug "  GREP_V_ARGS = $GREP_V_ARGS"
4878
4879     cat $io_scan_out | weed_targets | formatter | \
4880         grep -F -v $GREP_V_ARGS >> /tmp/sysinfo.$$.ioout
4881   else
4882     Debug "found 9.x"
4883     cp ${io_scan_out} /tmp/sysinfo.$$.ioout
4884   fi
4885   Debug "  `cat /tmp/sysinfo.$$.ioout`"
4886   
4887   #rm -f $io_scan_tmp
4888   print "" >>/tmp/sysinfo.$$.ioout
4889   f_display_file /tmp/sysinfo.$$.ioout
4890
4891 }                # end of f_get_ioscan_data
4892
4893 #===================================================================
4894 # f_get_volume_group_data
4895 #        This function retrieves volume group data using vgdisplay
4896 #        and by scannig /etc/lvmconf for config files.
4897 #===================================================================
4898 function f_get_volume_group_data
4899 {
4900   Debug "Beginning VOLUME GROUP check."
4901   # first print header information
4902
4903   if (($HTML))
4904   then
4905     print "</PRE>"                     >> /tmp/sysinfo.$$.vginfoh
4906     print "<A NAME='Volume'></A>"      >> /tmp/sysinfo.$$.vginfoh
4907     print "<H2>"                       >> /tmp/sysinfo.$$.vginfoh
4908     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> /tmp/sysinfo.$$.vginfoh
4909     print "<FONT COLOR=red>"           >> /tmp/sysinfo.$$.vginfoh
4910     print "Volume Group Data</H2>"     >> /tmp/sysinfo.$$.vginfoh
4911     print "</FONT><PRE><font size = '4'>"     >> /tmp/sysinfo.$$.vginfoh
4912   else
4913     print                     >> /tmp/sysinfo.$$.vginfoh
4914     print "VOLUME GROUP DATA" >> /tmp/sysinfo.$$.vginfoh
4915     print "=================" >> /tmp/sysinfo.$$.vginfoh
4916   fi
4917   Debug "  calling check_if_scan_done"
4918   check_if_scan_done lvm_scan
4919
4920   vgdisplay -v > /tmp/sysinfo.$$.vgout 2>&1
4921   #MWR fix when PVG-strict policies used
4922   #all_volgroups=$(grep "VG Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
4923   all_volgroups=$(grep -v "PVG Name" /tmp/sysinfo.$$.vgout | \
4924      grep "VG Name" | awk '{print $3}' | sort)
4925   all_logvols=$(grep "LV Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
4926   #Debug "all_volgroups=\n$all_volgroups"
4927   #Debug "all_logvols=\n$all_logvols"
4928   
4929   print -n "scanning volume groups "
4930   for volgroup in ${all_volgroups}
4931   do
4932     Debug "Volumegroup = $volgroup"
4933     vgdisplay $volgroup > /tmp/sysinfo.$$.volgroup 2>&1
4934     #Debug "vgdisplay=\n`cat /tmp/sysinfo.$$.volgroup`"
4935     ((vgcount=vgcount + 1))
4936     CURLV=$(grep "Cur LV" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
4937     CURPV=$(grep "Cur PV" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
4938     AllocPe=$(grep "Alloc PE" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
4939     FreePe=$(grep "Free PE" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
4940     TotalPe=$(grep "Total PE" /tmp/sysinfo.$$.volgroup | awk '{print $3}')
4941     PeSize=$(grep "PE Size" /tmp/sysinfo.$$.volgroup | awk '{print $4}')
4942     ((AllocMb = AllocPe * PeSize))
4943     ((FreeMb = FreePe * PeSize))
4944     ((TotalMb = TotalPe * PeSize))
4945     ((TotalAllocMb = TotalAllocMb + AllocMb))
4946     ((TotalFreeMb = TotalFreeMb + FreeMb))
4947     ((SystemTotalMb = SystemTotalMb + TotalMb))
4948     Debug "  Physical Extent Size = ${PeSize}"
4949     Debug "  Number of Allocated Physical Extents = ${AllocPe}"
4950     Debug "  Free Physical Extents = ${FreePe}"
4951     Debug "  Total Physical Extents = ${TotalPe}"
4952     Debug "  Allocated Mb = ${AllocMb}"
4953     Debug "  Free Mb = ${FreeMb}"
4954     Debug "  Total Mb = ${TotalMb}"
4955     Debug "  Total Allocated Mb = ${TotalAllocMb}"
4956     Debug "  Total Free Mb = ${TotalFreeMb}"
4957     Debug "  System Total Mb = ${SystemTotalMb}"
4958     print -n "."
4959     print -n "${volgroup}${CURLV}${CURPV}${PeSize}" >> /tmp/sysinfo.$$.vginfos
4960     print    "${AllocMb}${FreeMb}${TotalMb}" >> /tmp/sysinfo.$$.vginfos
4961   done
4962   print  
4963   Debug "Checking for vgcount = maxvgs"
4964   if [[ -z $maxvgs ]]
4965   then
4966     maxvgs=$(echo 'maxvgs/D'|adb -k $kernel /dev/kmem \
4967              | tail -1 | awk '{print $2}')
4968   fi
4969   Debug " vgcount = $vgcount"
4970   Debug " maxvgs = $maxvgs"
4971   if ((vgcount == maxvgs))
4972   then
4973     if ((! (($exit_code)) ))
4974     then
4975       exit_code=${WARN}
4976     fi
4977     print "WARNING (${sysname}): number of volume groups is at maximum."\
4978            >> /tmp/sysinfo.$$.errwarn
4979   fi
4980   
4981 # now check for a cfg backup file for each volume group.
4982
4983   print -n "scanning config files "
4984   Debug "Checking vg config files"
4985   for volgroup in ${all_volgroups}
4986   do
4987     Debug "  volgroup ${volgroup}"
4988     vg=$(echo ${volgroup} | awk -F/ '{print $3}')
4989     print -n "."
4990     if [ -f /etc/lvmconf/${vg}.conf ]
4991     then
4992       # this is a kludge. if file is less than 6 months old then 
4993       # ls -l prints the time, so scan for a colon.
4994       ls -l /etc/lvmconf/${vg}.conf | awk '{print $8}' | grep ":" > /dev/null
4995       if (($?))
4996       then
4997         if ((! (($exit_code)) ))
4998         then
4999           exit_code=${WARN}
5000         fi
5001         print "WARNING (${sysname}): vgconfig file > 6 months old for /etc/lvmconf/${vg}.conf"\
5002                >> /tmp/sysinfo.$$.errwarn
5003       fi
5004     else
5005       if ((! (($exit_code)) ))
5006       then
5007         exit_code=${WARN}
5008       fi
5009       print -n "WARNING (${sysname}): no config " >> /tmp/sysinfo.$$.errwarn
5010       print    "file found for volume group ${vg}." >> /tmp/sysinfo.$$.errwarn
5011       if ((! (($exit_code)) ))
5012       then
5013         exit_code=${WARN}
5014       fi
5015     fi
5016   done
5017   print  ""
5018   f_display_file /tmp/sysinfo.$$.novgcfg 
5019   print    "" >> /tmp/sysinfo.$$.vginfoh
5020   print    " Volume               Logical  Physical  Extent   MBs of Physical Space" >> /tmp/sysinfo.$$.vginfoh
5021   print    " Group                Volumes  Volumes  Size(MB)  Alloc    Free   Total"  >> /tmp/sysinfo.$$.vginfoh
5022   print    " ---------            -------  --------  ------   -----    ----   -----"  >> /tmp/sysinfo.$$.vginfoh
5023   print    "                                                  =====    ====   =====" >> /tmp/sysinfo.$$.vginfot
5024   print -n "                                        Totals " >> /tmp/sysinfo.$$.vginfot
5025   print     "${TotalAllocMb}${TotalFreeMb}${SystemTotalMb}" >> /tmp/sysinfo.$$.vginfot
5026   cat /tmp/sysinfo.$$.vginfo? > /tmp/sysinfo.$$.vginfod
5027   f_display_file /tmp/sysinfo.$$.vginfod
5028
5029 } # end of f_get_volume_group_data
5030
5031 #===================================================================
5032 # f_get_logical_volume_data
5033 #        This function uses lvdisplay to scan logical volumes.
5034 #        It retrieves information about the logvol and also checks
5035 #        for stale mirrors (if used).
5036 #===================================================================
5037 function f_get_logical_volume_data
5038 {
5039   Debug "Beginning LOGICAL DISK check."
5040   # first print out header information
5041   
5042   if (($HTML))
5043   then
5044     print "</PRE>"                                  >> /tmp/sysinfo.$$.lvinfoh
5045     print "<A NAME='Logical'></A>"                  >> /tmp/sysinfo.$$.lvinfoh
5046     print "<H2>"                                    >> /tmp/sysinfo.$$.lvinfoh
5047     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> /tmp/sysinfo.$$.lvinfoh
5048     print "<FONT COLOR=red>"           >> /tmp/sysinfo.$$.lvinfoh
5049     print "Logical Volume And Extent Data</H2>"     >> /tmp/sysinfo.$$.lvinfoh
5050     print "</FONT><PRE><font size = '4'>"           >> /tmp/sysinfo.$$.lvinfoh
5051   else
5052     print                                     >> /tmp/sysinfo.$$.lvinfoh
5053     print  "LOGICAL VOLUME AND EXTENT DATA"   >> /tmp/sysinfo.$$.lvinfoh  
5054     print  "=============================="   >> /tmp/sysinfo.$$.lvinfoh
5055   fi
5056   Debug "  calling check_if_scan_done"
5057   check_if_scan_done lvm_scan
5058   
5059   print -n "scanning logical volumes "
5060   if [[ ! -f /tmp/sysinfo.$$.vgout ]]
5061   then
5062     vgdisplay -v > /tmp/sysinfo.$$.vgout 2>&1
5063     all_volgroups=$(grep "VG Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
5064     all_logvols=$(grep "LV Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' | sort)
5065   fi
5066   for logvol in ${all_logvols}
5067   do
5068     Debug "lvdisplay of ${logvol}"
5069     lvol_major=$(ls -l $logvol | awk '{print $5}')
5070     lvol_minor=$(ls -l $logvol | awk '{print $6}')
5071     Debug "  major= $lvol_major minor=$lvol_minor"
5072     lvdisplay -v ${logvol} > /tmp/sysinfo.$$.logical 2>&1
5073     STATUS=$(grep "LV Status" /tmp/sysinfo.$$.logical | awk '{print $3}')
5074     LVSize=$(grep "LV Size" /tmp/sysinfo.$$.logical | awk '{print $4}')
5075     LogicalExtents=$(grep "Current LE" /tmp/sysinfo.$$.logical \
5076                   | awk '{print $3}')
5077     StaleExtents=$(grep stale /tmp/sysinfo.$$.logical | wc -l)
5078     MirrorCopies=$(grep "Mirror copies" /tmp/sysinfo.$$.logical \
5079                   | awk '{print $3}')
5080     Consistency=$(grep "Consistency Recovery" /tmp/sysinfo.$$.logical \
5081                   | awk '{print $3}')
5082   
5083   
5084     ((total_l_mb = total_l_mb + LVSize))
5085     ((MirrorMb = LVSize * MirrorCopies))
5086     ((TotalMirrorMb = TotalMirrorMb + MirrorMb))
5087     
5088   # check to make sure lvol has extents allocated to it
5089     if (( $LogicalExtents > 0 ))                 
5090     then
5091 ### Changed 6/15/99 J.Semroc - grep for lvol1 would also match lvol10, lvol11...
5092 ###   MOUNT=$(cat /etc/mnttab | grep ${logvol}  | cut -f 2 -d" ")
5093       MOUNT=$(cat /etc/mnttab | grep "${logvol} " | cut -f 2 -d" ")
5094 ### end of Change
5095       if [[ ${swap_devs} = *${logvol}* ]]
5096       then
5097         MOUNT="(swapdisk)"
5098       fi
5099       ((lcount=lcount + 1))
5100       if (( ${StaleExtents} > 0 ))        # we found stale extents
5101       then
5102         Debug " Found ${StaleExtents} STALE extents on ${logvol}!"
5103         stale=1
5104         ((StaleMB = (LVSize / LogicalExtents) * StaleExtents ))
5105         ((TotalStaleMb = TotalStaleMb + StaleMB))
5106         ((total_stale = $total_stale + $StaleExtents))
5107       fi                                # end of stale extents
5108     else                                # no extents allocated
5109       if ((! (($exit_code)) ))
5110       then
5111         exit_code=$WARN
5112       fi
5113       zero_length=1
5114       print -n "\nWARNING (${sysname}): Detected logical " >> /tmp/sysinfo.$$.errwarn
5115       print "volume (${logvol}) with no extents!\n" >> /tmp/sysinfo.$$.errwarn
5116     fi                                # end of check for allocated extents
5117     Debug "  STATUS= ${STATUS}"
5118     Debug "  LVSize= ${LVSize}"
5119     Debug "  LogicalExtents = ${LogicalExtents}"
5120     Debug "  StaleExtents = ${StaleExtents}"
5121     Debug "  StaleMb= $StaleMB"
5122     Debug "  TotalStaleMb= $TotalStaleMb "
5123     Debug "  TotalMb checked= $total_l_mb"
5124
5125 # now let's print out the results.
5126     print -n "."
5127     logvold=${logvol}                        # for display purposes only.
5128     print "${logvold}${MOUNT}"               >> /tmp/sysinfo.$$.lvinfos
5129     #print "${LogicalExtents}${StaleExtents}" >> /tmp/sysinfo.$$.lvinfos
5130     #print "${MirrorCopies}${Consistency}"    >> /tmp/sysinfo.$$.lvinfos
5131   done                                
5132 # end of loop for all log vols
5133 # now print out any errors or warnings.
5134   f_display_file /tmp/sysinfo.$$.nolvext 
5135 # print    "" >> /tmp/sysinfo.$$.lvinfoh
5136   print    "                                     "  >> /tmp/sysinfo.$$.lvinfoh
5137   print -n " Volume Name                            " >> /tmp/sysinfo.$$.lvinfoh
5138   print    "Mounted File System"  >> /tmp/sysinfo.$$.lvinfoh
5139   print -n " --------------                         " >> /tmp/sysinfo.$$.lvinfoh
5140   print -- "--------------------"  >> /tmp/sysinfo.$$.lvinfoh
5141   print    "" >> /tmp/sysinfo.$$.lvinfos
5142   cat /tmp/sysinfo.$$.lvinfo? > /tmp/sysinfo.$$.lvinfod
5143   f_display_file /tmp/sysinfo.$$.lvinfod 
5144
5145   print "\nAllocation" > /tmp/sysinfo.$$.lvol_legend
5146   print -n "  ns    non-strict                " >> /tmp/sysinfo.$$.lvol_legend
5147   print    "PVG-s  PVG-strict                " >> /tmp/sysinfo.$$.lvol_legend
5148   print -n "  ns-c  non-strict/contiguous     " >> /tmp/sysinfo.$$.lvol_legend
5149   print    "PVG-c  PVG-strict/contiguous" >> /tmp/sysinfo.$$.lvol_legend
5150   print -n "  s     strict                    " >> /tmp/sysinfo.$$.lvol_legend
5151   print    "PVG-d  PVG-strict/distributed    " >> /tmp/sysinfo.$$.lvol_legend
5152   print -n "  s-c   strict/contiguous         " >> /tmp/sysinfo.$$.lvol_legend
5153   print    "PVG-p  PVG-strict/partially-distributed" >> /tmp/sysinfo.$$.lvol_legend
5154   print "" >> /tmp/sysinfo.$$.lvol_legend
5155
5156
5157 # display using data from batch lvm_scan
5158   print    "" > /tmp/sysinfo.$$.lvinfoh
5159   print -n "                                 "  >> /tmp/sysinfo.$$.lvinfoh
5160   print    "                                  Bad" >> /tmp/sysinfo.$$.lvinfoh
5161   print -n "                                 "  >> /tmp/sysinfo.$$.lvinfoh
5162   print    "  Size Stripes    Mirrors    LV   Block" >> /tmp/sysinfo.$$.lvinfoh
5163   print -n " Volume Name                     "  >> /tmp/sysinfo.$$.lvinfoh
5164   print    "  (MB)  # Size    #  Const  State Reloc  Alloc" >> /tmp/sysinfo.$$.lvinfoh
5165   print -n " --------------                  "  >> /tmp/sysinfo.$$.lvinfoh
5166   print    " ----- -------   ---------  ----- -----  -----"  >> /tmp/sysinfo.$$.lvinfoh
5167   f_display_file /tmp/sysinfo.$$.lvinfoh
5168   f_display_file $lvol_out_file
5169   f_display_file /tmp/sysinfo.$$.lvol_legend
5170   if (($BATCH))
5171   then
5172     print
5173   fi
5174
5175 }         # end of f_get_logical_volume_data
5176
5177
5178 #===================================================================
5179 # f_logical_to_physical
5180 #        This function produces a cross reference of physical disks
5181 #        for each logical volume.
5182 #===================================================================
5183 function f_logical_to_physical
5184 {
5185   Debug "Beginning LOGICAL TO PHYSICAL Mapping."
5186   
5187   if [[ ! -f /tmp/sysinfo.$$.vgout ]]
5188   then
5189     Debug "/tmp/sysinfo.$$.vgout not found....building."
5190     vgdisplay -v > /tmp/sysinfo.$$.vgout 2>&1
5191     all_logvols=$(grep "LV Name" /tmp/sysinfo.$$.vgout | awk '{print $3}' |sort)
5192   fi
5193   if (($HTML))
5194   then
5195     print "</PRE>"                                    >> /tmp/sysinfo.$$.l2p
5196     print "<A NAME='Lmap'></A>"                       >> /tmp/sysinfo.$$.l2p
5197     print "<H2>"                                      >> /tmp/sysinfo.$$.l2p
5198     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >> /tmp/sysinfo.$$.l2p
5199     print "<FONT COLOR=red>"                          >> /tmp/sysinfo.$$.l2p
5200     print "Logical Volume To Physical Disk Mapping</H2>" >> /tmp/sysinfo.$$.l2p
5201     print "</FONT><PRE><font size = '4'>"             >> /tmp/sysinfo.$$.l2p
5202   else
5203     print    "" >> /tmp/sysinfo.$$.l2p
5204     print    "LOGICAL VOLUME TO PHYSICAL DISK MAPPING                 " >> /tmp/sysinfo.$$.l2p
5205     print    "=========================================================" >> /tmp/sysinfo.$$.l2p
5206   fi
5207   print "Logical Volume" >> /tmp/sysinfo.$$.l2p
5208   print " extents  Primary disk     Mirror Disk 1    Mirror Disk 2" >> /tmp/sysinfo.$$.l2p
5209   print -- "---------------------------------------------------------" >> /tmp/sysinfo.$$.l2p
5210   print -n "generating disk mappings "
5211
5212   for logvol in ${all_logvols}
5213   do
5214     Debug "  scanning ${logvol}"
5215     lvdisplay -v ${logvol} > /tmp/sysinfo.$$.logical 2>&1
5216     PhysicalDisks=$(awk '$1 ~ /\/dev\/dsk\/.*/ {printf "%s\n",$1}' \
5217                      /tmp/sysinfo.$$.logical \
5218                      | sed -e 's/\/dev\/dsk\///' | sort)
5219     # output physical disk data for each logical volume
5220     print    "${logvol}    " >> /tmp/sysinfo.$$.l2p
5221 #   print -n "     Disks = " >> /tmp/sysinfo.$$.l2p
5222
5223 # count the number of physical disks found.
5224     diskcount=0
5225     for disk in ${PhysicalDisks}
5226     do
5227       ((diskcount = diskcount + 1))
5228       Debug "    disk = $disk"
5229     done
5230     Debug "    found $diskcount physical disks"
5231     lvdisplay -v $logvol | sed '1,/   LE/d' | awk '{print $2, $5, $8}' \
5232                      | sort | grep "dev" | uniq -c | awk \
5233                      '{printf "%6s %18s %16s %16s\n",$1,$2,$3,$4}' \
5234                      >> /tmp/sysinfo.$$.l2p
5235 #   print "" >> /tmp/sysinfo.$$.l2p
5236     print -n "."
5237   done
5238   print "" >> /tmp/sysinfo.$$.l2p
5239   f_display_file /tmp/sysinfo.$$.l2p 
5240   print  ""
5241
5242 }        # end of f_logical_to_physical
5243
5244
5245 #===================================================================
5246 # f_filesystem_check
5247 #        This function checks mounted filesystems and reports 
5248 #        capcity information. It prints warnings if greater than
5249 #        95% full.
5250 #===================================================================
5251
5252 function f_filesystem_check
5253 {
5254   Debug "Beginning FILE SYSTEM check."
5255
5256   # first print out headers
5257   if (($HTML))
5258   then
5259     print "</PRE>"                    >> /tmp/sysinfo.$$.bdf_outh
5260     print "<A NAME='File'></A>"       >> /tmp/sysinfo.$$.bdf_outh
5261     print "<H2>"                      >> /tmp/sysinfo.$$.bdf_outh
5262     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >>/tmp/sysinfo.$$.bdf_outh
5263     print "<FONT COLOR=red>"          >> /tmp/sysinfo.$$.bdf_outh
5264     print "File System Data</H2>"     >> /tmp/sysinfo.$$.bdf_outh
5265     print "</FONT><PRE><font size = '4'>" >> /tmp/sysinfo.$$.bdf_outh
5266   else
5267     print    "" >> /tmp/sysinfo.$$.bdf_outh
5268     print    "FILE SYSTEM DATA" >> /tmp/sysinfo.$$.bdf_outh
5269     print    "================" >> /tmp/sysinfo.$$.bdf_outh
5270   fi
5271   print -n "scanning filesystems "
5272
5273   typeset -R10 kbytes used avail iused ifree
5274   typeset -R5 percent_used
5275   mnttab=$(cat /etc/mnttab | grep /dev  | awk '{printf "%s\n", $2}')
5276   num_fs=$(bdf -il 2>&1 | grep "/dev/" | wc -l)
5277   ((num_fs = num_fs -1))
5278   Debug "Found $num_fs mounted file systems"
5279 # bdf -i | tail -${num_fs} > /tmp/sysinfo.$$.bdf_data 2>&1
5280   for mounted in ${mnttab}
5281   do
5282     bdf -i ${mounted} 2>&1 | tail -1 > /tmp/sysinfo.$$.bdf_data 2>&1
5283     if ( grep "No such file" /tmp/sysinfo.$$.bdf_data >/dev/null 2>&1 )
5284     then 
5285       Debug " bdf reports No such file or directory on ${mounted}"
5286       print "WARNING (${sysname}): No such file or directory for ${mounted}" >>  /tmp/sysinfo.$$.errwarn
5287     else
5288     fs_type=$(cat /etc/mnttab | grep " ${mounted} " | awk '{printf "%s\n", $3}')
5289     Debug "filesys = ${mounted}  fs_type = ${fs_type}"
5290     if [[ $fs_type = vxfs ]]
5291     then
5292       mnt_lvol=$(cat /etc/mnttab | grep " ${mounted} " | awk '{printf "%s\n", $1}')
5293       fs_ver=$(fstyp -v ${mnt_lvol} 2>&1 | grep version | awk '{printf "%s\n", $2}')
5294       if [[ -f ${mounted}/lost+found/.fsadm ]]
5295       then
5296       vxfs_defrag=$(fsadm -F vxfs -E ${mounted} | grep \
5297                   "extents 64 blks or larger" | awk '{print $NF}')
5298       ((vxfs_frag = 100 - vxfs_defrag))
5299       vxfs_pct="%"
5300       else
5301         Debug " ${mounted}/lost+found/.fsadm not found - no frag check"
5302         no_lost=1
5303         vxfs_frag="**"
5304         vxfs_pct="*"
5305       fi
5306       Debug "fs_ver = ${fs_ver} vxfs_frag = ${vxfs_frag}"
5307       if ( [[ $osmajor = 10 ]] && [[ $osminor > 10 ]] ) || [[ $osmajor = 11 ]]
5308       then
5309         if [[ $fs_ver < 3 ]]
5310         then
5311           Debug "Found vxfs version $fs_ver"
5312           print "WARNING (${sysname}): Version ${fs_ver} of vxfs found on ${mounted}" >> /tmp/sysinfo.$$.errwarn
5313         fi
5314       fi
5315     fi
5316     Debug "  `cat /tmp/sysinfo.$$.bdf_data`"
5317     kbytes=$(awk '{if (NF == 9) print $2; else print $1}' /tmp/sysinfo.$$.bdf_data) 
5318     used=$(awk '{if (NF == 9) print $3; else print $2}' /tmp/sysinfo.$$.bdf_data)
5319     if [[ $fs_type  != "cdfs" ]]
5320     then
5321       avail=$(awk '{if (NF == 9) print $4; else print $3}' /tmp/sysinfo.$$.bdf_data)
5322       iused=$(awk '{if (NF == 9) print $6; else print $5}' /tmp/sysinfo.$$.bdf_data)
5323       ifree=$(awk '{if (NF == 9) print $7; else print $6}' /tmp/sysinfo.$$.bdf_data)
5324       #((percent_used = (used * 100) / (used + avail) ))
5325       percent_used=$(echo $used $avail | \
5326         awk '{ used = $1
5327                avail = $2
5328                pct_used =  ($1 * 100) / ($1 + $2)
5329                printf("%d", pct_used)
5330               } ' )
5331
5332       if (($percent_used > 95)) && [[ $fs_type  != "cdfs" ]]
5333       then
5334         if ((! (($exit_code)) ))
5335         then
5336           exit_code=${WARN}
5337         fi
5338         print "WARNING (${sysname}): ${mounted} has less than 5% free space left!" >> /tmp/sysinfo.$$.errwarn
5339       fi
5340     else #must be a cdrom, so don't calculate free space
5341       avail=0
5342       iused="-"
5343       ifree="-"
5344       percent_used="-"
5345     fi
5346     if [[ $fs_type != vxfs ]]
5347     then
5348       vxfs_frag="n/"
5349       vxfs_pct="a"
5350     fi
5351     print "${mounted}" >> /tmp/sysinfo.$$.bdf_outs
5352 #   print "              ${fs_type} ${kbytes}${used}${avail}${percent_used}${iused}${ifree}" >> /tmp/sysinfo.$$.bdf_outs
5353     print "              ${fs_type} ${kbytes}${used}${avail}${percent_used}     ${vxfs_frag}${vxfs_pct}" >> /tmp/sysinfo.$$.bdf_outs
5354     print -n "."
5355     fi
5356   done
5357   print "" >> /tmp/sysinfo.$$.bdf_outs
5358   print -n "Mounted                               " >> /tmp/sysinfo.$$.bdf_outh
5359   print -- "                    Extents" >> /tmp/sysinfo.$$.bdf_outh
5360   print -n "Filesystems   Type     Kbytes      Used     Avail" >> /tmp/sysinfo.$$.bdf_outh
5361 # print    "   %      Iused     Ifree" >> /tmp/sysinfo.$$.bdf_outh
5362   print    "   %    Fragmented" >> /tmp/sysinfo.$$.bdf_outh
5363   print -n " ----------   ----     ------    ------    ------" >> /tmp/sysinfo.$$.bdf_outh
5364   print -- "  ---   ----------" >> /tmp/sysinfo.$$.bdf_outh
5365   cat /tmp/sysinfo.$$.bdf_out? > /tmp/sysinfo.$$.bdf_outd
5366   if (( ${no_lost} == 1 ))
5367   then
5368     print -n "***  could not get fsadm lock - " >> /tmp/sysinfo.$$.bdf_outd
5369     print "lost+found/.fsadm not found" >> /tmp/sysinfo.$$.bdf_outd
5370     print "" >> /tmp/sysinfo.$$.bdf_outd
5371   fi
5372   f_display_file /tmp/sysinfo.$$.bdf_outd 
5373   f_display_file /tmp/sysinfo.$$.bdf_warn 
5374   print ""
5375
5376 }        # end of f_filesystem_check
5377
5378 #===================================================================
5379 # f_disk_capacity
5380 #        This function displays total disk, group, and lvol capacities.
5381 #        The data comes from the logical, physical, & volume functions.
5382 #        Therefore, this function does not stand alone. It must be run
5383 #        with the l, p, & v options.
5384 #===================================================================
5385 function f_disk_capacity
5386 {
5387   Debug "Beginning DISK CAPACITY calculations."
5388   if (($HTML))
5389   then
5390     print "</PRE>"                      >> /tmp/sysinfo.$$.capacity
5391     print "<A NAME='Capacity'></A>"     >> /tmp/sysinfo.$$.capacity
5392     print "<H2>"                        >> /tmp/sysinfo.$$.capacity
5393     print "<P ALIGN=RIGHT><A HREF='#Top'>TOP</A></P>" >>/tmp/sysinfo.$$.capacity
5394     print "<FONT COLOR=red>"          >> /tmp/sysinfo.$$.capacity
5395     print "Disk Capacity Data</H2>"     >> /tmp/sysinfo.$$.capacity
5396     print "</FONT><PRE><font size = '4'>" >> /tmp/sysinfo.$$.capacity
5397   else
5398     print "DISK CAPACITY DATA" >> /tmp/sysinfo.$$.capacity
5399     print "==================" >> /tmp/sysinfo.$$.capacity
5400   fi
5401   ((unused_cap = total_p_mb - TotalAllocMb))
5402   ((OtherMb = TotalAllocMb - total_l_mb - TotalMirrorMb))
5403   print "Logical Volume Space  =    $total_l_mb MB" >> /tmp/sysinfo.$$.capacity
5404   print "Mirror Space          =    $TotalMirrorMb MB" >> /tmp/sysinfo.$$.capacity
5405   print "Other Space Allocated =    $OtherMb MB" >> /tmp/sysinfo.$$.capacity
5406   print "                        -----------" >> /tmp/sysinfo.$$.capacity
5407   print "Total Disk Allocated  =    $TotalAllocMb MB" >> /tmp/sysinfo.$$.capacity
5408   print "Unallocated Disk      =    $unused_cap MB" >> /tmp/sysinfo.$$.capacity
5409   print "                        ===========" >> /tmp/sysinfo.$$.capacity
5410   print "Total Physical Disk   = $total_p_mb MB\n" >> /tmp/sysinfo.$$.capacity
5411
5412   print "Checked:" >> /tmp/sysinfo.$$.capacity
5413   print "${pcount} physical volumes" >> /tmp/sysinfo.$$.capacity
5414   print "${vgcount} volume groups" >> /tmp/sysinfo.$$.capacity
5415   print "${lcount} logical volumes" >> /tmp/sysinfo.$$.capacity
5416
5417   Debug "  found ${pcount} physical volumes"
5418   Debug "  found ${vgcount} volume groups"
5419   Debug "  found ${lcount} logical volumes"
5420   
5421   if  ((${stale}))
5422   then
5423     Debug "found ${total_stale} STALE extents"
5424     Debug "  calculating re-syncing time"
5425     exit_code=${SYS_ERROR}
5426     print "STALE extents detected!" >> /tmp/sysinfo.$$.capacity
5427     print "  check error listing for more details." >> /tmp/sysinfo.$$.capacity
5428     print -n "\n\nERROR:${sysname}: ${total_stale}" >> /tmp/sysinfo.$$.errwarn
5429     print    " stale extents detected.\n" >> /tmp/sysinfo.$$.errwarn
5430     print -n "Estimated time to re-sync ${total_stale}" >> /tmp/sysinfo.$$.errwarn
5431     print    " stale extents is" >> /tmp/sysinfo.$$.errwarn
5432     if ((${TotalStaleMb} < 100))
5433     then
5434       print " less than 1 minute." >> /tmp/sysinfo.$$.errwarn
5435       Debug " less than 1 minute" 
5436     else
5437       ((TIME = TotalStaleMb / 100))
5438       ((HOURS = TIME /60))
5439       ((MINUTES = TIME % 60))
5440       print " ${HOURS} hours and ${MINUTES} minutes." >> /tmp/sysinfo.$$.errwarn
5441       Debug " ${TIME} total minutes or" 
5442       Debug "     ${HOURS} hours and ${MINUTES} minutes" 
5443     fi
5444     print >> /tmp/sysinfo.$$.errwarn
5445   else
5446     print "with no stale extents detected.\n"   >> /tmp/sysinfo.$$.capacity
5447     Debug "No stale extents detected"
5448   fi
5449   f_display_file /tmp/sysinfo.$$.capacity
5450
5451 }                 # end of f_disk_capacity
5452
5453
5454 #===================================================================
5455 # f_check_root
5456 #        This function checks to see if the user is root.
5457 #===================================================================
5458 function f_check_root
5459 {
5460   id | grep '(root)' > /dev/null
5461   if (($?))
5462   then
5463     print "\nYou must be super-user to run ${script}.\n"
5464     exit ${ERROR}
5465   fi
5466 }                # end of check_root
5467
5468 #===================================================================
5469 # f_check_hpux
5470 #        This function checks to see if running on HP-UX
5471 #===================================================================
5472 function f_check_hpux
5473 {
5474   uname -s | grep HP-UX > /dev/null
5475   if (($?))
5476   then
5477     print "\nThis utility is only supported on HP-UX systems!\n"
5478     exit ${ERROR}
5479   fi
5480 }                # end of check_hpux
5481
5482 #===================================================================
5483 # f_extract_errors
5484 #        This function extract WARNINGS & ERRORS from the logfile
5485 #===================================================================
5486 function f_extract_errors
5487 {
5488   if [[ -f /tmp/sysinfo.$$.errwarn ]]
5489   then
5490     if (($HTML))
5491     then
5492       print "</PRE>"                          >> /tmp/sysinfo.$$.errwarn.header
5493       print "<A NAME='ErrWarn'></A>"          >> /tmp/sysinfo.$$.errwarn.header
5494       print "<H2>"                            >> /tmp/sysinfo.$$.errwarn.header
5495       print "<P ALIGN=RIGHT><A HREF='#Top'>"  >> /tmp/sysinfo.$$.errwarn.header
5496       print "TOP</A></P>"                     >> /tmp/sysinfo.$$.errwarn.header
5497       print "<FONT COLOR=red>"                >> /tmp/sysinfo.$$.errwarn.header
5498       print "Summary of Errors/Warnings</H2>" >> /tmp/sysinfo.$$.errwarn.header
5499       print "</FONT><PRE><font size = '4'>"   >> /tmp/sysinfo.$$.errwarn.header
5500     else
5501       print ""                                >> /tmp/sysinfo.$$.errwarn.header
5502       print "ERROR/WARNING SUMMARY"           >> /tmp/sysinfo.$$.errwarn.header
5503       print "====================="           >> /tmp/sysinfo.$$.errwarn.header
5504     fi
5505
5506     grep  -e WARNING -e ERROR /tmp/sysinfo.$$.errwarn > /dev/null 2>&1
5507     if [ $? -eq 1 ]
5508     then
5509       Debug "No errors/warnings found."
5510       if (($BATCH))
5511       then
5512         print "No ERRORS or WARNINGS found."
5513       fi
5514       print "($sysname): No errors/warnings found." >> /tmp/sysinfo.$$.errwarn
5515     else
5516       Debug "Found errors/warnings, displaying /tmp/sysinfo.$$.errwarn"
5517       if (($BATCH))
5518       then
5519         print "Errors and/or Warnings were found." 
5520         print "Please check output file ${LOGFILE}."
5521       fi
5522     fi
5523     print "" >> /tmp/sysinfo.$$.errwarn
5524     f_display_file /tmp/sysinfo.$$.errwarn.header
5525     f_display_file /tmp/sysinfo.$$.errwarn
5526   else
5527     print "Could not find /tmp/sysinfo.$$.errwarn"
5528   fi
5529 }
5530
5531 function print_header
5532 {
5533 #print
5534 #print " ****             *****"
5535 #print "*                   *                       "
5536 #print "*     *   *  ***    *   **   * ****  **** "
5537 #print " ****  * *  *       *   * *  * *    *    *"
5538 #print "     *  *    ***    *   *  * * ***  *    *"
5539 #print "     *  *       *   *   *   ** *    *    *"
5540 #print " ****   *    ***  ***** *    * *     ****"
5541 #print
5542 print
5543 print " @@@@             @@@@@"
5544 print "@                   @                       "
5545 print "@     @   @  @@@    @   @@   @ @@@@  @@@@ "
5546 print " @@@@  @ @  @       @   @ @  @ @    @    @"
5547 print "     @  @    @@@    @   @  @ @ @@@  @    @"
5548 print "     @  @       @   @   @   @@ @    @    @"
5549 print " @@@@   @    @@@  @@@@@ @    @ @     @@@@"
5550 print
5551 }
5552 #===================================================================
5553 # BEGIN MAIN CODE
5554 #===================================================================
5555 typeset -fx lvm_scan
5556 typeset -fx sam_scan
5557 typeset -fx io_scan
5558 typeset -fx f_query_sam
5559 sysname=$(hostname)
5560 where=`dirname ${0}`
5561 f_check_hpux
5562 f_check_root
5563 get_args $*
5564 if (($BATCH))
5565 then
5566   #print "\n${script}  ${version} by Scott Truesdale\n"
5567   print_header
5568   print "Author:  Scott Truesdale"
5569   print "Version: ${version}\n"
5570   if (($HTML))
5571   then
5572     print "<HTML><HEAD>"                                 >> $LOGFILE
5573     print "<HTML><HEAD>"                                 >> $LOGFILE_INDEX
5574     print "<HTML><HEAD>"                                 >> $LOGFILE_MAIN
5575     print "<TITLE>Sysinfo for ${sysname}</TITLE>"        >> $LOGFILE
5576     print "<TITLE>Sysinfo (Index) for ${sysname}</TITLE>" >> $LOGFILE_INDEX
5577     print "<TITLE>Sysinfo (Main) for ${sysname}</TITLE>" >> $LOGFILE_MAIN
5578     print "</HEAD>"                                      >> $LOGFILE
5579     print "<FRAMESET ROWS='175,*' FRAMEBORDER='YES'"     >> $LOGFILE
5580     print "BORDERCOLOR='darkblue' FRAMESPACING='2'"      >> $LOGFILE
5581     print "BORDER='2'>"                                  >> $LOGFILE
5582     print "<FRAME SRC='${LOGFILE_INDEX_REL}'"            >> $LOGFILE
5583     print "NAME='IndexFrame' SCROLLING='NO'>"            >> $LOGFILE
5584     print "<FRAME SRC='${LOGFILE_MAIN_REL}'"             >> $LOGFILE
5585     print "NAME='MainFrame'"                             >> $LOGFILE
5586     print "SCROLLING='AUTO'><NOFRAMES>"                  >> $LOGFILE
5587     print "<BODY BGCOLOR=lightblue>"                     >> $LOGFILE
5588     print "</HEAD><BODY BGCOLOR=lightblue>"              >> $LOGFILE_INDEX
5589     print "</HEAD><BODY BGCOLOR=lightblue>"              >> $LOGFILE_MAIN
5590     print "<CENTER>"                                     >> $LOGFILE
5591     print "<A name='TOP'></A>"                           >> $LOGFILE
5592     print "<FONT SIZE=6 COLOR=darkblue>"                 >> $LOGFILE
5593     print "${script} ${version} "                        >> $LOGFILE
5594     print "by Scott Truesdale</FONT><BR>"                >> $LOGFILE
5595     print "<FONT SIZE=6>Configuration Data for"          >> $LOGFILE
5596     print "<FONT COLOR=red>${sysname}</FONT></FONT><BR>" >> $LOGFILE
5597     print "<FONT SIZE=3>Collected on `date`.</FONT><BR>" >> $LOGFILE
5598     print "<A HREF='#System'>System</A>"                 >> $LOGFILE
5599     print "<A HREF='#Kernel'>Kernel</A>"                 >> $LOGFILE
5600     print "<A HREF='#Network'>Network</A>"               >> $LOGFILE
5601     print "<A HREF='#File'>File System</A>"              >> $LOGFILE
5602     print "<BR>"                                         >> $LOGFILE
5603     print "<A HREF='#IO'>IO Configuration</A>"           >> $LOGFILE
5604     print "<A HREF='#Physical'>Physical Disks</A>"       >> $LOGFILE
5605     print "<A HREF='#Pmap'>Physical Mapping</A>"         >> $LOGFILE
5606     print "<A HREF='#Volume'>Volume Groups</A>"          >> $LOGFILE
5607     print "<BR>"                                         >> $LOGFILE
5608     print "<A HREF='#Logical'>Logical Disks</A>"         >> $LOGFILE
5609     print "<A HREF='#Lmap'>Logical Mapping</A>"          >> $LOGFILE
5610     print "<A HREF='#Capacity'>Disk Capacity</A>"        >> $LOGFILE
5611     print "<A HREF='#Software'>Software List</A>"        >> $LOGFILE
5612     print "<BR>"                                         >> $LOGFILE
5613     print "<A HREF='#SYSACCESS'>Security Check</A>"      >> $LOGFILE
5614     print "<A HREF='#DIAGNOSTICS'>Diagnostic Settings</A>" >> $LOGFILE
5615     print "<A HREF='#LOGFILES'>System Logfiles</A>"      >> $LOGFILE
5616     print "<A HREF='#ErrWarn'>Errors/Warnings</A>"       >> $LOGFILE
5617     if (($PASS))
5618     then
5619       print "<BR>"                                       >> $LOGFILE
5620       print "<A HREF='#SAP'>SAP R/3 Info</A>"            >> $LOGFILE
5621     fi
5622     print "</CENTER>"                                    >> $LOGFILE
5623     print "<CENTER>"                                     >> $LOGFILE_INDEX
5624     print "<A name='TOP'></A>"                           >> $LOGFILE_INDEX
5625     print "<FONT SIZE=6 COLOR=darkblue>"                 >> $LOGFILE_INDEX
5626     print "${script} ${version} "                        >> $LOGFILE_INDEX
5627     print "by Scott Truesdale</FONT><BR>"                >> $LOGFILE_INDEX
5628     print "<FONT SIZE=6>Configuration Data for"          >> $LOGFILE_INDEX
5629     print "<FONT COLOR=red>${sysname}</FONT></FONT><BR>" >> $LOGFILE_INDEX
5630     print "<FONT SIZE=3>Collected on `date`.</FONT><BR>" >> $LOGFILE_INDEX
5631     print "<A HREF='${LOGFILE_MAIN_REL}#System' TARGET='MainFrame'>System</A>"                 >> $LOGFILE_INDEX
5632     print "<A HREF='${LOGFILE_MAIN_REL}#Kernel' TARGET='MainFrame'>Kernel</A>"                 >> $LOGFILE_INDEX
5633     print "<A HREF='${LOGFILE_MAIN_REL}#Network' TARGET='MainFrame'>Network</A>"               >> $LOGFILE_INDEX
5634     print "<A HREF='${LOGFILE_MAIN_REL}#File' TARGET='MainFrame'>File System</A>"              >> $LOGFILE_INDEX
5635     print "<A HREF='${LOGFILE_MAIN_REL}#IO' TARGET='MainFrame'>IO Configuration</A>"           >> $LOGFILE_INDEX
5636     print "<A HREF='${LOGFILE_MAIN_REL}#Physical' TARGET='MainFrame'>Physical Disks</A>"       >> $LOGFILE_INDEX
5637     print "<A HREF='${LOGFILE_MAIN_REL}#Pmap' TARGET='MainFrame'>Physical Mapping</A>"         >> $LOGFILE_INDEX
5638     print "<A HREF='${LOGFILE_MAIN_REL}#Volume' TARGET='MainFrame'>Volume Groups</A>"          >> $LOGFILE_INDEX
5639     print "<A HREF='${LOGFILE_MAIN_REL}#Logical' TARGET='MainFrame'>Logical Disks</A>"         >> $LOGFILE_INDEX
5640     print "<A HREF='${LOGFILE_MAIN_REL}#Lmap' TARGET='MainFrame'>Logical Mapping</A>"          >> $LOGFILE_INDEX
5641     print "<A HREF='${LOGFILE_MAIN_REL}#Capacity' TARGET='MainFrame'>Disk Capacity</A>"        >> $LOGFILE_INDEX
5642     print "<A HREF='${LOGFILE_MAIN_REL}#Software' TARGET='MainFrame'>Software List</A>"        >> $LOGFILE_INDEX
5643     print "<A HREF='${LOGFILE_MAIN_REL}#SYSACCESS' TARGET='MainFrame'>Security Check</A>"      >> $LOGFILE_INDEX
5644     print "<A HREF='${LOGFILE_MAIN_REL}#DIAGNOSTICS' TARGET='MainFrame'>Diagnostic Settings</A>" >> $LOGFILE_INDEX
5645     print "<A HREF='${LOGFILE_MAIN_REL}#LOGFILES' TARGET='MainFrame'>System Logfiles</A>"      >> $LOGFILE_INDEX
5646     print "<A HREF='${LOGFILE_MAIN_REL}#ErrWarn' TARGET='MainFrame'>Errors/Warnings</A>"       >> $LOGFILE_INDEX
5647     if (($PASS))
5648     then
5649       print "<A HREF='${LOGFILE_MAIN_REL}#SAP' TARGET='MainFrame'>SAP R/3 Info</A>"            >> $LOGFILE_INDEX
5650     fi
5651     print "</CENTER>"                                    >> $LOGFILE_INDEX
5652
5653   else
5654     print "\n${script} ${version} by Scott Truesdale\n" >> $LOGFILE
5655     print "Configuration data for ${sysname}\ncollected on `date`\n" >> $LOGFILE
5656   fi
5657 else
5658   print_header
5659   print "Author:  Scott Truesdale"
5660   print "Version: ${version}\n"
5661   print "Configuration data for ${sysname}\ncollected on `date`.\n" 
5662 fi
5663 touch /tmp/sysinfo.$$.errwarn
5664 #===================================================================
5665 # Begin PASS section
5666 #===================================================================
5667 if (($PASS))
5668 then
5669   touch /tmp/sysinfo.$$.sapwarn
5670   check_for_sap
5671 fi
5672
5673 #===================================================================
5674 #  SYSTEM CHECK AND ROOT DATA 
5675 #===================================================================
5676 f_get_sys_type
5677
5678 if (($SYSTEM))
5679 then
5680   f_get_system_data
5681 fi
5682 #===================================================================
5683 # KERNEL DATA 
5684 #===================================================================
5685 if (($FULL_KERNEL)) || (($LITE_KERNEL))
5686 then
5687   if (( ${osmajor} >= 10 ))
5688   then
5689     f_get_kernel_data
5690   else
5691     f_get_9x_kernel_data
5692   fi
5693 fi
5694
5695 #if (($SAMSCAN)) && (( ${osmajor} >= 10 ))
5696 #then
5697 #  f_display_sam_kernel_data
5698 #fi
5699
5700 #===================================================================
5701 # NETWORK CARD DATA
5702 #===================================================================
5703 if (($NETWORK))
5704 then
5705   f_get_network_data
5706 fi
5707
5708 #===================================================================
5709 # FILE SYSTEM CHECK
5710 #===================================================================
5711 if (($FILESYSTEM))
5712 then
5713   f_filesystem_check
5714 fi
5715
5716 #===================================================================
5717 # IOSCAN CHECK
5718 #===================================================================
5719 if (($IOSCAN))
5720 then
5721   f_get_ioscan_data
5722 fi
5723
5724 #===================================================================
5725 # PHYSICAL DISK CHECK
5726 #===================================================================
5727 if (($PHYSICAL))
5728 then
5729   f_get_physical_disk_data
5730 fi
5731
5732 #===================================================================
5733 # VOLUME GROUP CHECK
5734 #===================================================================
5735 if (($VOLUMES)) 
5736 then
5737   if (($lvm_installed))
5738   then
5739     f_get_volume_group_data
5740   else
5741     print "LVM must be installed to use this option."
5742   fi
5743 fi
5744
5745 #===================================================================
5746 # LOGICAL DISK CHECK
5747 #===================================================================
5748 if (($LOGICAL)) 
5749 then
5750   if (($lvm_installed))
5751   then
5752     f_get_logical_volume_data
5753   else
5754     print "LVM must be installed to use this option."
5755   fi
5756 fi
5757
5758 #===================================================================
5759 # LOGICAL VOLUME TO PHYSICAL DISK MAPPING 
5760 #===================================================================
5761 # check which physical disks have this logvol on them
5762 if (($LMAP))
5763 then
5764   if (($lvm_installed))
5765   then
5766     f_logical_to_physical
5767   else
5768     print "LVM must be installed to use this option."
5769   fi
5770 fi
5771
5772 #===================================================================
5773 # DISK CAPACITY TABLE
5774 #===================================================================
5775 # note that the CAPACITY flag cannot be set directly.
5776 # it is automatically enabled when either the -a or -lpv flags
5777 if (($CAPACITY))
5778 then
5779   if (($lvm_installed))
5780   then
5781     f_disk_capacity
5782   else
5783     print "LVM must be installed to use this option."
5784   fi
5785 fi
5786
5787 #===================================================================
5788 # SOFTWARE LIST
5789 #===================================================================
5790 if (($SWLIST))
5791 then
5792   sw_scan
5793 fi
5794
5795 #===================================================================
5796 # Check system file/directory access and some security parms.
5797 #===================================================================
5798 if (($FILEACCESS))
5799 then
5800   chk_sysaccess
5801 fi
5802
5803 #===================================================================
5804 # Check to see if the system has diagnostics
5805 #===================================================================
5806 if (($DIAGNOSTICS))
5807 then
5808   chk_diags
5809   chk_ignite
5810 fi
5811
5812 #===================================================================
5813 # Check System Logfiles
5814 #===================================================================
5815
5816 if (($LOGFILES))
5817 then
5818   chk_logfiles
5819 fi
5820
5821 #===================================================================
5822 # Extract ERROR/WARNING messages
5823 #===================================================================
5824 f_extract_errors
5825
5826 if (($PASS))
5827 then
5828   f_display_file /tmp/sysinfo.$$.sap
5829   print "\n\n" >> /tmp/sysinfo.$$.sapwarn
5830   f_display_file /tmp/sysinfo.$$.sapwarn
5831
5832 fi
5833
5834 #===================================================================
5835 # Clean up end of HTML files if necessary
5836 #===================================================================
5837
5838 if (($HTML))
5839 then
5840   print "</BODY></HTML>" >> $LOGFILE_INDEX
5841   print "</BODY></HTML>" >> $LOGFILE_MAIN
5842   print "</BODY></NOFRAMES></FRAMESET></HTML>" >> $LOGFILE
5843   chmod 444 $LOGFILE_INDEX $LOGFILE_MAIN $LOGFILE
5844 fi
5845
5846 #===================================================================
5847 # END OF SCRIPT - SO LET'S GET OUT OF HERE!
5848 #===================================================================
5849 Debug "exit_code = ${exit_code}" 
5850 exit ${exit_code}
5851