Wednesday, 1 February 2017

tablespace monitor html report shell script

#!/bin/ksh
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/oracle
PATH=$ORACLE_HOME/bin:$PATH
export PATH
$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF > /home/oraprod/TBS.log
SET ECHO OFF
set pages 1000
set feedback off
SET MARKUP HTML ON SPOOL ON
SPOOL TBS.html
select tablespace_name, free_percent, free_size_mb
from (
            SELECT b.tablespace_name, b.tablespace_size_mb, sum(nvl(fs.bytes,0))/1024/1024 free_size_mb,
            (sum(nvl(fs.bytes,0))/1024/1024/b.tablespace_size_mb *100) free_percent
            FROM dba_free_space fs,
                 (SELECT tablespace_name, sum(bytes)/1024/1024 tablespace_size_mb FROM dba_data_files
                  GROUP BY tablespace_name
                 ) b
           where fs.tablespace_name = b.tablespace_name
           group by b.tablespace_name, b.tablespace_size_mb
        ) ts_free_percent
WHERE free_percent < 10
ORDER BY free_percent;
spool off
exit
EOF
export MAILTO="mail address"
export CONTENT="/home/oraprod/TBS.html"
export SUBJECT="TABLESPACE FREESPACE REPORT"
(
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 cat $CONTENT
) | /usr/sbin/sendmail $MAILTO


Comment me if you find this post is useful also let me know if you need any new topics.

3 comments:

  1. I have runed the script, but no result are comming!!! please check once more time !

    ReplyDelete
    Replies
    1. It will show the report only if any tablespace having less than 10 percent free space..

      Delete
  2. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp a great deal more around this condition. and I could assume you are an expert on this subject. Same as your blog i found another one Oracle Fusion Financials.Actually I was looking for the same information on internet for Oracle Financials Cloud and came across your blog. I am impressed by the information that you have on this blog. Thanks a million and please keep up the gratifying work.

    ReplyDelete