寫了下db2巡檢的一個小腳本,只能做常規檢查,減少日常工作量,腳本內容如下:#!/bash/binecho "物理CPU個數為:"cat /proc/cpuinfo| grep "cpu cores"| uniqecho "邏輯CPU個數為:"cat /proc/cpuinfo| grep "pro ...
寫了下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 "常規檢查完成"