Email Generation Shell Scripts for Temporary Tablespace Monitor

. /d01/oracle/VIS/db/tech_st/11.1.0/oracle.env
cat /home/oracle/OCM/tablespace.log
sqlplus '/ as sysdba' << EOF
set feedback off echo off
set linesize 100
set pagesize 200
set colsep |
spool /home/oracle/OCM/tablespace.log
SELECT A.tablespace_name tablespace, D.mb_total,
SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used,
D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free
FROM v\$sort_segment A,
SELECT, C.block_size, SUM (C.bytes) / 1024 / 1024 mb_total
FROM v\$tablespace B, v\$tempfile C
WHERE B.ts#= C.ts#
GROUP BY, C.block_size
) D
WHERE A.tablespace_name =
GROUP by A.tablespace_name, D.mb_total;
spool off
if [ `cat /home/oracle/OCM/tablespace.log|wc -l` -gt 0 ]
cat /home/oracle/OCM/tablespace.log >> /home/oracle/OCM/mailcontent
cat /home/oracle/OCM/tablespace.log |mailx -s "Temporary Tablespace Monitor"
rm -rf /home/oracle/OCM/tablespace.log
rm -rf /home/oracle/OCM/mailcontent

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: