#!/bin/bash
# IBM Confidential
# OCO Source Materials
# 5724-V51
#
# (c) Copyright IBM Corp. 2000, 2008 All Rights Reserved.
#
# The source code for this program is not published or otherwise
# divested of its trade secrets, irrespective of what has been
# deposited with the U.S. Copyright Office.

echo "*******************************************************************"
echo "THIS SCRIPT MUST BE RUN FROM DB2 INSTANCE (DB2INST1) USER ID ONLY"
echo "*******************************************************************"

if [ $# -lt 1 ] 
then
  echo "Usage " $0 "dbname"
  echo "Exampe: " $0 "mdmpimdb"
  exit 0
fi
dbname=$1

db2 connect to $dbname
db2level

echo "Checking DB2 settings" 

echo "DB2_RR_TO_RS registry setting should be ON "
db2set -all | grep -i DB2_RR_TO_RS  
echo ""
echo "DB2_SKIPINSERTED registry setting should be ON "
db2set -all | grep -i  DB2_SKIPINSERTED 
echo ""
echo "DB2_EVALUNCOMMITTED registry setting should be ON "
db2set -all | grep -i DB2_EVALUNCOMMITTED 
echo ""
echo "DB2_SKIPDELETED registry setting should be ON "
db2set -all | grep -i  DB2_SKIPDELETED 
echo ""
echo "DB2_HASH_JOIN registry setting should be ON "
db2set -all | grep -i DB2_HASH_JOIN 
echo ""
echo "DB2_NO_MPFA_FOR_NEW_DB registry setting should not be present "
db2set -all | grep -i DB2_NO_MPFA_FOR_NEW_DB 
echo ""


#echo "PREFETCH SIZE should be multiple of EXTENT SIZE"
#db2 list tablespaces show detail|grep -E "Name|size \(pages\)"

echo "Checking Bufferpools"
db2 "select npages, 'ATLEAST_19200' install_guide_value, bpname from syscat.bufferpools where bpname in ('USERSBP','INDXBP')"
db2 "select npages, 'ATLEAST_1000' install_guide_value, bpname from syscat.bufferpools where bpname in ('BLOBBP')"
db2 "select npages, 'ATLEAST_9600' install_guide_value, bpname from syscat.bufferpools where bpname in ('TEMPUSRBP','TEMPSYSBP')"

echo "Checking DBM configuration"
echo MON_HEAP_SZ "should be atleast  5120"
db2 get dbm cfg | grep -i MON_HEAP_SZ 
echo ""
echo SHEAPTHRES "should be atleast 20480, 40960 for 64-bit or 0 (automatic)" 
db2 get dbm cfg | grep -i SHEAPTHRES 
echo ""
echo ASLHEAPSZ "should be atleast 512 (1024 for 64-bit)" 
db2 get dbm cfg | grep -i ASLHEAPSZ 
echo ""
echo QUERY_HEAP_SZ "should be atleast 2560 (5120 for 64-bit)" 
db2 get dbm cfg | grep -i QUERY_HEAP_SZ 
echo ""
echo MAXAGENTS "should be atleast 120" 
db2 get dbm cfg | grep -i MAXAGENTS 
echo ""

echo "Checking DB configuration"
echo "DFT_QUERYOPT should be 5" 
db2 get db cfg for $1|grep -i DFT_QUERYOPT 
echo ""
echo "DBHEAP should be atleast 10000 (20000 for 64-bit)" 
db2 get db cfg for $1|grep -i DBHEAP 
echo ""
echo "CATALOGCACHE_SZ should be atleast 2048 (5120 for 64-bit)"  
db2 get db cfg for $1|grep -i CATALOGCACHE_SZ 
echo ""
echo "LOGBUFSZ should be atleast 4096" 
db2 get db cfg for $1|grep -i LOGBUFSZ 
echo ""
echo "UTIL_HEAP_SZ should be atleast 5120" 
db2 get db cfg for $1|grep -i UTIL_HEAP_SZ 
echo ""
echo "BUFFPAGE should be atleast 1024" 
db2 get db cfg for $1|grep -i BUFFPAGE 
echo ""
echo "LOCKLIST should be atleast 5120 (10240 for 64-bit), or automatic" 
db2 get db cfg for $1|grep -i LOCKLIST 
echo ""
echo "APP_CTL_HEAP_SZ should be atleast 512" 
db2 get db cfg for $1|grep -i APP_CTL_HEAP_SZ 
echo ""
echo "SORTHEAP should be atleast 1024 (2048 for 64-bit), or automatic" 
db2 get db cfg for $1|grep -i SORTHEAP 
echo ""
echo "STMTHEAP should be atleast 1024 (2048 for 64-bit)"
db2 get db cfg for $1|grep -i STMTHEAP 
echo ""
echo "APPLHEAPSZ should be atleast 512 (1024 for 64-bit)"
db2 get db cfg for $1|grep -i APPLHEAPSZ 
echo ""
echo "STAT_HEAP_SZ should be atleast 5120 (10240 for 64-bit)" 
db2 get db cfg for $1|grep -i STAT_HEAP_SZ 
echo ""
echo "MAXLOCKS should be 50 or automatic" 
db2 get db cfg for $1|grep -i MAXLOCKS 
echo ""
echo "LOCKTIMEOUT should be 60" 
db2 get db cfg for $1|grep -i LOCKTIMEOUT 
echo ""
echo "NUM_IOCLEANERS should be 7" 
db2 get db cfg for $1|grep -i NUM_IOCLEANERS 
echo ""
echo "NUM_IOSERVERS should be atleast 8" 
db2 get db cfg for $1|grep -i NUM_IOSERVERS 
echo ""
echo "MAXAPPLS should be atleast 120" 
db2 get db cfg for $1|grep -i MAXAPPLS 
echo ""
echo "AVG_APPLS should be 5" 
db2 get db cfg for $1|grep -i AVG_APPLS 
echo ""
echo "MAXFILOP should be 640" 
db2 get db cfg for $1|grep -i MAXFILOP 
echo ""
echo "LOGFILSIZ should be atleast 60000 for production" 
db2 get db cfg for $1|grep -i LOGFILSIZ 
echo ""
echo "LOGPRIMARY should be 40" 
db2 get db cfg for $1|grep -i LOGPRIMARY 
echo ""
echo "LOGSECOND should be 2" 
db2 get db cfg for $1|grep -i LOGSECOND 
echo ""

