db2巡檢小指令碼

kisslfcr發表於2016-12-28
寫了下db2巡檢的一個小指令碼,只能做常規檢查,減少日常工作量,指令碼內容如下:

#!/bash/bin


echo "物理CPU個數為:"
cat /proc/cpuinfo| grep "cpu cores"| uniq


echo "邏輯CPU個數為:"
cat /proc/cpuinfo| grep "processor"| wc -l


echo "記憶體空間為:"
sed -n '/MemTotal/p' /proc/meminfo


echo "swap空間大小為:"
sed -n '/SwapTotal/p' /proc/meminfo


echo "系統資源使用情況:"
top -d 2 -n 1


echo "檔案系統使用情況為:"
df -h


echo "db2版本為:"
db2level


echo "檢查db2主程式:"
ps  -ef  | grep db2sysc


echo "檢查所有可用資料庫:"
db2 list active databases|grep 'Database name'|awk -F '[=]' '{print $2}'
db2 list active databases|grep 'Database name'|awk -F '[=]' '{print $2}' > aaa.txt


echo "檢查所有資料庫表空間狀態:"
cat aaa.txt |while read line  
do  
  echo "資料庫$line:";
  db2 connect to $line;
  db2 "select char(TBSP_NAME,50) as TBSP_NAME, TBSP_USABLE_PAGES, TBSP_USED_PAGES, rtrim(100*TBSP_USED_PAGES/TBSP_USABLE_PAGES)||'%' as USED_RATE from sysibmadm.SNAPTBSP_PART where TBSP_USABLE_PAGES>0 order by TBSP_NAME,DBPARTITIONNUM";
done


echo "檢視備份狀態:"
cat aaa.txt |while read line  
do  
  echo "資料庫$line:";
  db2 connect to $line;
  db2 list history backup all for $line;
done

rm -rf aaa.txt


echo "常規檢查完成"

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2131525/,如需轉載,請註明出處,否則將追究法律責任。

相關文章