3 ###############################################################################
4 # collect some configuration, trace, and debug
5 # information about the S390 Linux system
7 # Copyright IBM Corp. 2002, 2006.
8 ###############################################################################
14 SCRIPTNAME
="dbginfo.sh"
15 WORKDIR
=DBGINFO-
`date +%Y-%m-%d-%H-%M-%S`-`hostname`
17 # write output to following directory
19 WORKPATH
=$WORKPFX/$WORKDIR
20 # write output to following files
22 VM_CMDOUTPUT
=zvm_runtime.out
23 SYSFSFILELIST
=sysfsfiles.out
25 MOUNT_POINT_DEBUGFS
="/sys/kernel/debug"
30 # procfs entries to be collected (except s390dbf and scsi)
46 /proc/qeth_ipa_takeover \
51 /proc/dasd/statistics \
52 /proc/sys/kernel/spin_retry \
53 /proc/sys/vm/cmm_pages \
54 /proc/sys/vm/cmm_timed_pages \
55 /proc/sys/vm/cmm_timeout \
56 /proc/sys/vm/swappiness \
66 # log files to be collected
70 /var/log/IBMtape.trace \
71 /var/log/IBMtape.errorlog \
72 /var/log/lin_tape.trace \
73 /var/log/lin_tape.errorlog \
76 # config files to be collected;
77 # additional all files "modules.dep" are collected
99 #sysfs files NOT to be collected
104 # collect output of following commands;
105 # commands are separated by ':'
110 :ps -eo pid,tid,nlwp,policy,user,tname,ni,pri,psr,sgi_p,stat,wchan,start_time,time,pcpu,pmem,vsize,size,rss,share,command\
125 :dmsetup table --target multipath\
149 :cat /root/.bash_history\
164 :q xstore user system\
203 # function definitions
210 $SCRIPTNAME: Debug information script version %S390_TOOLS_VERSION%
211 Copyright IBM Corp. 2002, 2006
215 # print usage and help
219 Usage: $SCRIPTNAME [OPTIONS]
221 This script collects some runtime, configuration and
222 trace information about your Linux for zSeries system
223 for debugging purposes. It also traces information
224 about z/VM if the Linux runs under z/VM.
225 This information is written to a file
226 /tmp/DBGINFO-[date]-[time]-[hostname].tgz
227 where [date] and [time] are the date and time when debug
228 data is collected. [hostname] indicates the hostname of the
229 system the data was collected from.
233 -h, --help print this help
234 -v, --version print version information
236 Please report bugs to: linux390@de.ibm.com
240 # copy file $1 to $WORKPATH
241 collect_file_contents
()
243 echo " $1" >> $LOGFILE
246 echo " WARNING: No such file: \"$1\"" >> $LOGFILE
250 echo " WARNING: Permission denied: \"$1\"" >> $LOGFILE
253 if [ ! -e $WORKPATH`dirname $1` ]
255 mkdir
--parents $WORKPATH`dirname $1`
257 cp -r -d -L --parents $1 $WORKPATH 2>> $LOGFILE
258 # head -c 10m $1 >> $2
261 echo " WARNING: cp failed for file: \"$1\"" >> $LOGFILE
269 # append output of command $1 to file $2
272 local raw_cmd
=`echo $1 | awk '{ print $1 }'`;
274 echo "#######################################################">>$2
276 # check if command exists
277 which $raw_cmd >/dev
/null
2>&1;
280 # check if command is a builtin
281 command -v $raw_cmd >/dev
/null
;
282 [ $?
-ne 0 ] && echo "command '$raw_cmd' not available">>$2 && return 1;
285 echo "$USER@$HOST> $1">>$2
290 echo " WARNING: Command not successfully completed: \"$1\"">> $2
298 # check cmd line arguments
301 # currently no options available
304 if [ $1 = '-h' ] ||
[ $1 = '--help' ]
307 elif [ $1 = '-v' ] ||
[ $1 = '--version' ]
312 echo "$SCRIPTNAME: invalid option $1"
313 echo "Try '$SCRIPTNAME --help' for more information"
319 echo "ERROR: Invalid number of arguments"
326 # change into temporary directory; if necessary create the directory
337 echo "Clean up target directory $WORKPATH"
340 echo "Create target directory $WORKPATH"
343 echo "Change to target directory $WORKPATH"
347 # collect single proc fs entries
348 # (PRCFILES should not contain /proc/scsi and /proc/s390dbf)
351 echo "Get procfs entries" |
tee -a $LOGFILE
354 collect_file_contents
$i
358 # collect procfs entries of /proc/s390dbf
361 echo "Get entries of /proc/s390dbf" |
tee -a $LOGFILE
362 if [ -e /proc
/s390dbf
]
364 for i
in `find /proc/s390dbf -type f \
365 -not -path "*/raw" -not -path "*/flush"`
367 collect_file_contents
$i
370 echo " WARNING: /proc/s390dbf not found" |
tee -a $LOGFILE
374 # collect procfs entries of /proc/scsi
375 collect_procfs_scsi
()
377 echo "Get entries of /proc/scsi" |
tee -a $LOGFILE
380 for i
in `find /proc/scsi -type f \
383 collect_file_contents
$i
386 echo " WARNING: /proc/scsi not found" >> $LOGFILE
390 #check for excluded files in sysfs
393 for filename
in ${SYSFSFILEEXCLUDES[@]}
395 if [ `basename $1` = $filename ]
403 # collect sysfs entries
407 # check if debugfs is mounted
408 mount |
grep -q $MOUNT_POINT_DEBUGFS
410 if [ $rc_mount -eq 1 ] && [ $kernel_version_tmp -ge 13 ]; then
411 mount
-t debugfs debugfs
$MOUNT_POINT_DEBUGFS
414 echo "Get file list of /sys" |
tee -a $LOGFILE
415 collect_cmd_output
"ls -Rl /sys" $SYSFSFILELIST
417 echo "Get entries of /sys" |
tee -a $LOGFILE
418 for i
in `find /sys -noleaf -type f -perm +444`
422 if check_for_excludes
$i
424 collect_file_contents
$i
427 echo " WARNING: $i not found" |
tee -a $LOGFILE
430 #unmount debugfs if not mounted at the beginning
431 if [ $rc_mount -eq 1 ] && [ $kernel_version_tmp -ge 13 ]; then
432 umount
$MOUNT_POINT_DEBUGFS
437 # collect output of commands
442 if [ $rc_check_zvm -eq 1 ]; then
443 echo "Saving z/VM runtime information into $outputfile" |
tee -a $LOGFILE
445 echo "Saving runtime information into $outputfile" |
tee -a $LOGFILE
452 if [ $rc_check_zvm -eq 1 ]; then
455 collect_cmd_output
"$i" "$outputfile"
461 # config files and module dependencies
464 echo "Copy config files" |
tee -a $LOGFILE
465 for i
in $CONFIGFILES
467 collect_file_contents
$i
469 for i
in `find /lib/modules -name modules.dep`
471 collect_file_contents
$i
475 # Check if we run under z/VM and which Linux cp tool is installed
479 echo "Check if we run under z/VM" |
tee -a $LOGFILE
480 # Are we running under z/VM
481 cat /proc
/sysinfo |
grep -q "z/VM"
484 echo " Running in LPAR" |
tee -a $LOGFILE
487 echo " Running under z/VM" |
tee -a $LOGFILE
489 which vmcp
> /dev
/null
2>&1
493 which hcp
> /dev
/null
2>&1
496 echo " No cp tool installed" |
tee -a $LOGFILE
500 echo " Installed CP tool: $cp_tool" |
tee -a $LOGFILE
505 echo " Installed CP tool: $cp_tool" |
tee -a $LOGFILE
514 lsmod |
grep -q $cp_tool
516 if [ $rc_lsmod -eq 1 ]; then
517 if [ $cp_tool = "hcp" ]; then
525 collect_cmdsout
"$VM_CMDS" "$VM_CMDOUTPUT"
526 if [ $rc_lsmod -eq 1 ]; then
527 if [ $cp_tool = "hcp" ]; then
535 # Caputure FCP configuration data if possible
538 which ziomon_fcpconf
>/dev
/null
2>&1;
539 [ $?
-eq 0 ] && ziomon_fcpconf
-o $FCPCONFOUTPUT;
545 echo "Copy log files" |
tee -a $LOGFILE
548 collect_file_contents
$i
552 # create gzip-ped tar file
556 tar -czf $WORKDIR.tgz
$WORKDIR 2>/dev
/null
559 echo "Collected data was saved to:"
560 echo " $WORKPFX/$WORKDIR.tgz"
565 [ -d $WORKPATH ] && rm -rf $WORKPATH;
578 trap emergency_exit SIGHUP SIGTERM SIGINT
580 kernel_version
=`uname -r`
581 kernel_version_tmp
=`echo ${kernel_version:4:2} | sed s/[^0-9]//g`
584 printversion
>$LOGFILE
585 if [ $kernel_version_tmp -lt 13 ]
589 collect_procfs
$PROCFILES
590 collect_cmdsout
"$CMDS" "$CMDOUTPUT"
591 if [ "${kernel_version:2:1}" \
> 4 ]
595 collect_procfs
$PROCFILES_24
600 if [ $rc_check_zvm -eq 1 ]; then