Commit 0fd36882 authored by bnachtw's avatar bnachtw
Browse files

Upload New File

parent d4861cf6
#! /bin/bash
##############################################################################
#
# db-selects.sh
#
# a script collecting some information from DB2 for offline reorg
#
# (C) 2020 -- 2020 GWDG Göttingen, Bjørn Nachtwey
# mailto:bjoern.nachtwey@gwdg.de
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# changelog
# date version remark
# 2020-08-XX 0.0.1 initial coding using bash
# 2020-08-12 0.1.0 first version put to gitlab
# check if user isn't root (so maybe the instance user)
if [ $USER == "root" ]
then
echo "script must run as instance user, not ROOT!"
exit;
fi
# print headline
printf "%25s ; %15s ; %15s ; %15s ; %15s ; %10s \n" "Tabname" "object-Count" "est. time (sec)" "object-space" "space needed" "Pagesize"
# for loop on *all* tables
for tab in ACTIVITY_LOG AF_SEGMENTS AF_BITFILES ARCHIVE_OBJECTS AS_SEGMENTS BACKUP_OBJECTS BF_AGGREGATE_ATTRIBUTES BF_AGGREGATED_BITFILES GROUP_LEADERS EXPORT_OBJECTS TSMMON_STATUS
do
count=$(db2 connect to tsmdb1 2>&1>/dev/null && db2 "select count_big(*) from tsmdb1.$tab" | tail -n 4 | head -n 1 | sed -e 's/ //g' -e 's/\.$//');
estim=$(awk "BEGIN {print ($count / 140000)}");
tabsize=$(db2 connect to tsmdb1 2>&1>/dev/null && db2 "call sysproc.reorgchk_tb_stats('T','tsmdb1.$tab')" > /dev/null && db2 "select tsize from session.tb_stats" | tail -n 4 | head -n 1 | sed -e 's/ //g' -e 's/\.$//') ;
tabspace=$(awk "BEGIN {print ($tabsize / 1024 / 1024 / 1024)}")
pages=$(db2 connect to tsmdb1 2>&1>/dev/null && db2 "select t1.PAGESIZE from syscat.tablespaces t1 left join syscat.tables t2 on (t1.TBSPACEID=t2.TBSPACEID) where t2.tabname='$tab'" | tail -n 4 | head -n 1 | sed -e 's/ //g' -e 's/\.$//');
pagesize=$(awk "BEGIN {print ($pages / 1024)}")
printf "%25s ; %15d ; %15.3f ; %15d ; %12.3f GB ; %9sK \n" $tab $count $estim $tabsize $tabspace $pagesize
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment