db2巡检小脚本

it2022-05-07  44

写了下db2巡检的一个小脚本,只能做常规检查,减少日常工作量,脚本内容如下:#!/bash/binecho "物理CPU个数为:"cat /proc/cpuinfo| grep "cpu cores"| uniqecho "逻辑CPU个数为:"cat /proc/cpuinfo| grep "processor"| wc -lecho "内存空间为:"sed -n '/MemTotal/p' /proc/meminfoecho "swap空间大小为:"sed -n '/SwapTotal/p' /proc/meminfoecho "系统资源使用情况:"top -d 2 -n 1echo "文件系统使用情况为:"df -hecho "db2版本为:"db2levelecho "检查db2主进程:"ps  -ef  | grep db2syscecho "检查所有可用数据库:"db2 list active databases|grep 'Database name'|awk -F '[=]' '{print $2}'db2 list active databases|grep 'Database name'|awk -F '[=]' '{print $2}' > aaa.txtecho "检查所有数据库表空间状态:"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";doneecho "查看备份状态:"cat aaa.txt |while read line  do    echo "数据库$line:";  db2 connect to $line;  db2 list history backup all for $line;donerm -rf aaa.txtecho "常规检查完成"

转载于:https://www.cnblogs.com/Clark-cloud-database/p/7813190.html


最新回复(0)