db2

Troubleshooting with DB2 snapshots

Multiple db2 snapshots can reveal performance issue, but its going to difficult to execute multiple snapshots while troubleshooting, so here is a script that will take various snapshots and db2pd information in a loop while you are looking at the system. Modify it to suit your needs :

#!/bin/ksh 
typeset -i maxCount=10
typeset -i intervalCount=1
typeset -i sleeptime=120
if [ $# -eq 0 ] ; then
echo “Usage: snaps.ksh <database>”
 exit
fi
DB=$1
db2 terminate 2>&1
db2 connect to $DB
db2 update monitor switches using bufferpool on lock on sort on statement on table on uow on timestamp on
while (( intervalCount <= maxCount)) ; do
datestamp=`date +”%m%d”`.`date +”%H%M”`
  ps -kelf > pself.$datestamp 2>&1
  db2pd -edus > db2pd.edus.$datestamp 2>&1
  db2 get snapshot for database manager >  dbmsnap.$datestamp 2>&1
  db2 list applications show detail >  listapps.$datestamp 2>&1
  db2 get snapshot for database on $DB >  $DB.dbsnap.$datestamp 2>&1
  db2 get snapshot for applications on $DB >  $DB.appsnap.$datestamp 2>&1
  db2 get snapshot for tables on $DB >  $DB.tablesnap.$datestamp 2>&1
  db2 get snapshot for tablespaces on $DB >  $DB.tbspsnap.$datestamp 2>&1
  db2 get snapshot for locks on $DB >  $DB.locksnap.$datestamp 2>&1
  db2 get snapshot for bufferpools on $DB >  $DB.bpsnap.$datestamp 2>&1
  db2 get snapshot for dynamic sql on $DB >  $DB.dynsql.$datestamp 2>&1
  db2pd -inst -alldbs > db2pd.inst.alldbs.$datestamp 2>&1
  intervalCount=intervalCount+1
sleep $sleeptime
done
db2 terminate