Script to check the Tablespace sizes

What does this script do ?
  1. Check for the DMS(Auto Resize Enabled – No) Tablespaces ( As there is no point in checking the SMS and DMS with Auto Resize Enabled – Yes Tablespaces)
  2. Query returns the following columns (Tablespace Name , Free Pages , Container path )
  3. If less than 1000 pages throws warning message
Here’s the script


if [ /home/db2inst1/sqllib/db2profile ]; then
. /home/db2inst1/sqllib/db2profile
fi
#!/bin/sh
echo -e "\nTablespace’s having less than 1000 pages for the `date`\n" | tee -a /path/TBSP_CRT_RPT.txt
/home/db2inst1/sqllib/bin/db2 connect to db-name > /dev/null
# Get the above mentioned 3 columns and check if the free pages column is less than 1000, Change the no. of pages to your requirement
/home/db2inst1/sqllib/bin/db2 "select RTRIM(substr(A.TBSP_NAME,1,30)),A.TBSP_TYPE as TYPE,A.TBSP_FREE_PAGES as FREE,B.CONTAINER_NAME as CON_PATH from SYSIBMADM.TBSP_UTILIZATION A ,SYSIBMADM.CONTAINER_UTILIZATION B where A.TBSP_ID=B.TBSP_ID and A.TBSP_AUTO_RESIZE_ENABLED=0 with UR"| grep -i dms|while read line ; do awk ‘{ if($3 < 1000) print $1," Tablespace has ",$3,"Pages allocate some pages"; else print "No Tablespaces Less than 1000 Pages";}’ ; done | tee -a /path/TBSP_CRT_RPT.txt
/home/db2inst1/sqllib/bin/db2 commit work
/home/db2inst1/sqllib/bin/db2 connect reset > /dev/null
view raw tbspchk.sh hosted with ❤ by GitHub

No comments:

Post a Comment