we use the table function to monitor
drop view db2monitor.ts_space;
create view db2monitor.ts_space as select * from table(snapshot_tbs_cfg('PLDA',-1)) as sntable;
--
drop view db2monitor.ts_free_space ;
create view db2monitor.ts_free_space (tsname,type,state,size_meg,pct_free,meg_free) as
select substr(tablespace_name,1,30) ,
case (tablespace_type)
when 0 then 'DMS'
else 'SMS'
end ,
case (tablespace_state)
when 0 then 'Normal'
else 'Other' || char(tablespace_state)
end ,
int((total_pages*page_size)/1024/1024) ,
case (total_pages)
when 0 then 0
else smallint((float(free_pages) / float(total_pages))*100)
end ,
int((free_pages*page_size) / 1024 /1024 )
from db2monitor.ts_space ;
then monitor this
db2 "connect to $DBNAME "
db2 -x "select count(*) from db2monitor.ts_free_space where SIZE_MEG>1 and type='DMS' and pct_free < 21" |tr -d ' ' | read WARNTOT
db2 -x "select count(*) from db2monitor.ts_free_space where SIZE_MEG>1 and type='DMS' and pct_free between 11 and 20" |tr -d ' ' | read WARNCNT
db2 -x "select count(*) from db2monitor.ts_free_space where SIZE_MEG>1 and type='DMS' and pct_free < 11" |tr -d ' ' | read ERRCNT
# -----------------------------------------------------------------------
# no warnings/error -----------------------------------------------------
# -----------------------------------------------------------------------
if [[ $WARNTOT -eq 0 ]]; then
$SCRDIR/sendfile.sh -s "NO_WARNING_ON_TS_SPACE_USAGE_FOR_$HOSTNAME.$DB2IN STANCE.$DBNAME" ...
fi
if [[ $WARNCNT -ne 0 ]]; then....
ship mail if any alerts...