#!/bin/sh
# test
# Developed by Sun Microsystems, Inc.
# 2550 Garcia Avenue
# Mountain View, California 94043
#
# Copyright (c) 1996, Sun Microsystems, Inc.
#
# RESTRICTED RIGHTS: Use, duplication or disclosure by the government is
# subject to the restrictions as set forth in
# subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer
# Software Clause as DFARS 252.227-7013 and FAR 52.227-19.
#
# SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
# THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
# SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS
# SOFTWARE OR ITS DERIVATIVES.
#
# By using or copying this Software, Licensee agrees to abide by the
# intellectual property laws, and all other applicable laws of the U.S.,
# and the terms of this license.
#
# ----------------------------------------------------------------------
#
# iscda -- script to print out Initial System Crash Dump Analysis
#
# History:
#
# Edit 1 940707 krb First script for Solaris 2.3, Rev 1.0
# Edit 2 950220 krb Ported to Solaris 2.4
# Edit 3 950830 krb Time to start cleaning this up a bit
# Edit 4 960122 cjd Some 2.4 changes; put in more "conditional"
# execution of specific commands.
# Edit 5 961211 krb More conditionals. Calling this Rev 1.5
# Edit 6 010117 cjd Update for Solaris 7, 8
#
#
# Files this script creates:
#
# /tmp/iscda.{pid}
#
# Notes:
#
# This script must be run on the same kernel architecture and
# under the same OS as the system crash dump we are analyzing.
#
# ----------------------------------------------------------------------
if [ ! $# = 2 ]
then
echo
echo "Usage: iscda unixfile corefile > your-output-file"
echo
echo "Examples: iscda unix.3 vmcore.3"
echo " iscda /dev/ksyms /dev/mem"
echo
exit
fi
#
# Make sure we can see the files.
#
if [ ! -f $1 ] && [ ! $1 = "/dev/ksyms" ]
then
echo; echo "Unable to locate $1. Exiting."
echo; exit
fi
if [ ! -f $2 ] && [ ! $2 = "/dev/mem" ]
then
echo; echo "Unable to locate $2. Exiting."
echo; exit
fi
PATH=${PATH}:/etc
export PATH
# Find the release we're dealing with.
rel=`echo '$<utsname' | adb -k $1 $2 | grep release | sed 's/^.*release[ ]*//'`
#
# The cpu, thread, and u-area structures differ from release to
# release. Set the following variables so that we can get the name
# of the running processes later on. (Rev 1.5 edit)
#
case "$rel" in
5.3) Cpu2Thread=8; CpuIdle=c; CpuNext=1c; Thread2Proc=a0; Proc2Cmd=260
;;
5.4) Cpu2Thread=8; CpuIdle=c; CpuNext=1c; Thread2Proc=a0; Proc2Cmd=268
;;
5.5*) Cpu2Thread=c; CpuIdle=10; CpuNext=24; Thread2Proc=a8; Proc2Cmd=298
;;
5.6) Cpu2Thread=24; CpuIdle=10; CpuNext=2c; Thread2Proc=a8; Proc2Cmd=2b0
;;
5.7) Cpu2Thread=c; CpuIdle=10; CpuNext=28; Thread2Proc=a8; Proc2Cmd=2f8
;;
5.8) Cpu2Thread=c; CpuIdle=10; CpuNext=28; Thread2Proc=ac; Proc2Cmd=300
;;
5.*) Cpu2Thread=8; CpuIdle=c; CpuNext=1c; Thread2Proc=a0; Proc2Cmd=260
;;
*)
echo "Operating system release $rel is not supported by this script."
exit
;;
esac
#
# Okay, we are ready! Create and put some stuff into output file.
#
echo "Working....."
cat <<EOC
******************************************************************************
Initial System Crash Dump Analysis Output ISCDA Rev 1.6
`date`
******************************************************************************
EOC
#
# We will be creating our own macros for use in adb sessions.
# Odds are we will create a unique filename if we use the PID.
# If it is not unique, let the user do something about it.
#
WHERE=/tmp/iscda.$$
if [ -f $WHERE ]
then
echo; echo "File $WHERE already exists. Exiting."
echo; exit
fi
#
# The following will get the name of the processes running on each
# CPU. The structures from release to release differ, so we use
# variables throughout. The variables were computed earlier, above.
# (Rev 1.5 edit)
#
cat > $WHERE <<EOC
*(<c+${CpuNext})>n
<c+${Cpu2Thread}/X"Thread address"
*(<c+${Cpu2Thread})>p
<p+${Thread2Proc}/X"Proc address"
*(<p+${Thread2Proc})>j
<j+${Proc2Cmd}/s
.,#((*(<c+${Cpu2Thread}))-(*(<c+${CpuIdle})))="This CPU was idle"
0,#(#(<n))&#(#(<n-<e))=n"Next CPU..."n
<n>c
<n,#(#(<n))&#(#(<n-<e))\$<$WHERE
EOC
#
# Get initial information from adb
#
cat <<EOC
************************************
** Initial information from adb **
************************************
EOC
adb -k $1 $2 <<EOA
\$<utsname
srpc_domain/s16t"Domain name"
lbolt>a
*time-(*<a%0t100)=Y16t"Time of boot"
time/Y16t"Time of crash"
,#(*audit_active)=n"Auditing is not enabled"
,##(*audit_active)=n"Auditing is enabled"
,#(*quotas_initialized)=n"Quotas are not enabled"
,##(*quotas_initialized)=n"Quotas are enabled"
=nn"** Panic String **"
="--------------------"
*panicstr/s
=nn"** Stack Backtrace **"
="-----------------------"
\$c
=nn"** Per CPU information **"
="---------------------------"
ncpus/X"# of CPUs present"
ncpus_online/X"# of CPUs online"
=nn
*cpu_list>c
<c>e
<c,#(<c)="The cpu_list pointer is NULL. Not a good sign."n
<c,#(#(<c))\$<$WHERE
=nn"** Stacktrace **"
="-----------------"
<sp\$<stacktrace
=nn
="** CPU structures **"
="--------------------"
\$<cpus
=nn
="** Msgbuf **"
="------------"
\$<msgbuf
EOA
cat > $WHERE <<EOC
=nn"** System is sun4m architecture - Checking enable_sm_wa **"
="------------------------------------------------------------"
cpunodes/s
enable_sm_wa/D
,##(*enable_sm_wa)="Fix to bug 1146924 is installed"
,#(*enable_sm_wa)="Fix to bug 1146924 is not installed"
EOC
adb -k $1 $2 <<EOA
0,#(*(utsname+408)-6d000000)\$<$WHERE
EOA
#
# Get process information by using crash.
#
cat <<EOC
**************************************
** Process information from crash **
**************************************
EOC
crash -d $2 -n $1 <<EOC
p -e
EOC
#
# Get more of the message buffer, if possible, because the
# msgbuf macro has a tendency to truncate things.
#
case "$rel" in
5.4|5.5*|5.6)
#
#
# Get strings output to capture message buffer.
#
cat <<EOC
******************************************************
** Strings output of complete message ring buffer **
******************************************************
EOC
strings $2 | head -100
;;
#
# For 5.7/5.8, the message buffer is not contained in the first
# part of memory, so strings won't work. It's now in a streams
# buffer.
#
5.7|5.8)
;;
*)
;;
esac
#
# Additional adb stuff
#
cat <<EOC
***********************
** Some Statistics **
***********************
EOC
#
# Get DNLC statistics. Divide all stats by 1000 for the larger
# servers which tend to get odd hit rate percentages out of vmstat
# due to using integer arithmetic.
#
# This works up through 2.6, but Solaris 7 and 8 have changed
# things. The long_enter and long_look entries are deprecated in
# 5.7, and the whole accounting method changes in 5.8 (although the
# old structure is maintained for backward compatibility).
#
case "$rel" in
5.7|5.8)
adb -k $1 $2 <<EOA
=nn"** Directory Name Lookup Cache Statistics **"
="----------------------------------------------"
ncsize/D"Directory name cache size"
ncstats/D"# of cache hits that we used"
+/D"# of misses"
+/D"# of enters done"
+/D"# of enters tried when already cached"
ncstats+18/D"# of times entry moved to front"
+/D"# of purges of cache"
="(See /usr/include/sys/dnlc.h for more information)"
EOA
;;
5.*)
adb -k $1 $2 <<EOA
=nn"** Directory Name Lookup Cache Statistics **"
="----------------------------------------------"
ncsize/D"Directory name cache size"
ncstats/D"# of cache hits that we used"
+/D"# of misses"
+/D"# of enters done"
+/D"# of enters tried when already cached"
+/D"# of long names tried to enter"
+/D"# of long name tried to look up"
+/D"# of times LRU list was empty"
+/D"# of purges of cache"
*ncstats%1000>a
*(ncstats+4)%1000>b
*(ncstats+14)%1000>c
<a+<b+<c>n
<a*0t100%<n=D"Hit rate percentage"
="(See /usr/include/sys/dnlc.h for more information)"
EOA
;;
esac
#
# Not all stats are available on all releases of the OS, so
# back to checking the release before we go on...
#
case "$rel" in
5.4|5.5*|5.6|5.7|5.8)
cat <<EOC
** Kernel Memory Request Statistics **
----------------------------------------
EOC
crash -d $2 -n $1 <<EOC
kmastat
EOC
;;
5.*)
adb -k $1 $2 <<EOA
=nn"** Kernel Memory Request Statistics **"
="----------------------------------------"
="Small"16t"Large"16t"Outsized"
kmeminfo/3X"Owned by kmem"
+/3X"Mem allocated"
+/3X"# of failures"n
pagesize/D"Memory page size"
="(See /usr/include/sys/sysinfo.h for more information)"
=nn"** Streams Statistics **"
="--------------------------"
="In use"16t"Total"16t"Maximum"16t"Failures"
strst/4X"Streams"
+/4X"Queues"
+/4X"MsgBlks"
+/4X"LinkBlks"
="(See /usr/include/sys/strstat.h for more information)"
EOA
;;
*)
;;
esac
#
# end of case
#
#
# Print out some of the tunable variables. Do this via macros
# so that we don't get alot of symbol not found messages if
# the driver was not modloaded for use.
#
cat > $WHERE <<EOC
=nn"** Shared Memory Tuning Variables (if in use) **"
="--------------------------------------------------"
shminfo_shmmax/D"Max segment size"
+/D"Min segment size"
+/D"Max identifiers"
+/D"Max attached shm segs per proc"
EOC
adb -k $1 $2 <<EOA
\$<$WHERE
EOA
cat > $WHERE <<EOC
=nn"** Semaphore Tuning Variables (if in use) **"
="----------------------------------------------"
seminfo_semmap/D"Entries per map"
+/D"Max identifiers"
+/D"Max in system"
+/D"Max undos"
+/D"Max sems per id"
+/D"Max ops per semop"
+/D"Max undos per proc"
+/D"Max bytes in undos"
+/D"Max sem value"
+/D"Max adjust on exit"
EOC
adb -k $1 $2 <<EOA
\$<$WHERE
EOA
cat > $WHERE <<EOC
=nn"** Message Queue Tuning Variables (if in use) **"
="--------------------------------------------------"
msginfo_msgmap/D"Max entries in map"
+/D"Max message size"
+/D"Max bytes on queue"
+/D"Max msg queue ids"
+/D"Max segment size (word size multiple)"
+/D"Max system message headers"
+/d16t"Max msg segments (must be < 32768)"
EOC
adb -k $1 $2 <<EOA
\$<$WHERE
EOA
##
## optional - eats up lots of space
##
#
#############################################
#panicstring=`echo "*panicstr/s" | adb -k $1 $2 | sed -e '1d' -e 's/^.* //' | head -1`
#if [ "$panicstring" = "zero" ] ; then
#adb -k $1 $2 << EOA
#\$<threadlist
#EOA
#fi
#
rm $WHERE
#
## Get some basic configuration information which is always
## useful.
#
cat << EOC
************************************
** Current patch revision status **
************************************
EOC
showrev -p
cat << EOC
****************************************
** Hardware Configuration Information **
****************************************
EOC
prtconf -vp
echo "*****"
echo "Done!"
############################################
#
# +---------------------------------------------------------------------+
# | For more information about system crash dump analysis, refer to |
# | the SunSoft Press book, "Panic! UNIX System Crash Dump Analysis", |
# | ISBN 0-13-149386-8, published by Prentice Hall. |
# +---------------------------------------------------------------------+
#
############################################
#
# end of iscda
#
ִ ũƮ vi ̿Ͽ iscda ϴ.
#chmod 750 iscda
# iscda /var/crash/ȣƮ/unix.0 /var/crash/ȣƮ/vmcore.0 > output
# vi output