提取DB2多分区环境当前的状态

##最近整理了一下先前主机的内容,竟然发现好多的内容都没有备份,失误呀
########################################################################
##echo "本脚本是提取DB2多分区环境当前的状态"
##echo "主要是每个分区中对应的表空间和容器的信息"
##echo "使用方法:db2_check_dpf_status.sh dbname"
##echo "CopyRight  "
########################################################################
#!/bin/sh
check_time=`date '+%Y%m%d'`
FILEPATH=$0
FILENAME=${FILEPATH##*/}
echo
    usage()
    {
        echo "Invalid parameter,you must use it like this:${FILENAME} dbname !"
        exit 3
    }
if [ $# -ne 1 ]
then
  usage
fi
dbname=$1
db2level >> db2status.${dbname}.log.$check_time
db2 list db directory >> db2status.${dbname}.log.$check_time
db2 get dbm cfg show detail>> db2status.${dbname}.log.$check_time
db2 connect to $dbname >> db2status.${dbname}.log.$check_time
db2 list database partition groups >> db2status.${dbname}.log.$check_time
db2 "select * from syscat.bufferpools" >> db2status.${dbname}.log.$check_time
db2 list DBPARTITIONNUMS | grep "      " >> /tmp/DBPARTITIONNUMS.$dbname.log
cat /tmp/DBPARTITIONNUMS.$dbname.log | while read line
do
   db_partnum=`echo $line | awk '{print $1}'`
   if [ "$db_partnum" = "" ]
   then
       break
   fi
   echo "Begin to get Information of partition Node $db_partnum " >> db2status.${dbname}.log.$check_time
   export DB2NODE=$db_partnum >> db2status.${dbname}.log.$check_time
   db2 terminate >> db2status.${dbname}.log.$check_time
   db2 connect to $dbname >> db2status.${dbname}.log.$check_time
   db2 "values (current dbpartitionnum)" >> db2status.${dbname}.log.$check_time
   db2 get db cfg for $dbname show detail >> db2status.${dbname}.log.$check_time
   db2 list tablespaces show detail >> db2status.${dbname}.log.$check_time
   db2 list tablespaces | grep "Tablespace ID" | while read line2
   do
      tbsp_id=`echo $line2 | awk '{print $4}'`
      if [ "$tbsp_id" = "" ]
      then
         break
      fi
      db2 list tablespace containers for $tbsp_id show detail  >> db2status.${dbname}.log.$check_time    
   done
   sleep 2
done
rm -rf /tmp/DBPARTITIONNUMS.$dbname.log
echo "Get Information successful!"
exit 0
请使用浏览器的分享功能分享到微信等