@@header

/*
*
*  Author  : Vishal Gupta
*  Purpose : ASM usage by file type for all mounted diskgroups (including other databases)
*
*  Revision History:
*  ===================
*  Date       Author        Description
*  ---------  ------------  -----------------------------------------
*  27-Jan-10  Vishal Gupta  First Draft
*
*
*/


DEFINE size_label=GB
DEFINE size_divider="1024/1024/1024"

PROMPT 
PROMPT *******************************************************************
PROMPT *   A S M    S P A C E   U S A G E   B Y    F I L E T Y P E       *
PROMPT *                                                                 *
PROMPT *   - For all diskgroups mounted in current instance              *
PROMPT *   - Including files for other databases                         *
PROMPT *******************************************************************


COLUMN NAME                        HEADING "DiskGroup"                                 FORMAT A15

COLUMN DISKGROUP_UnMirroredSize    HEADING "Total|(&&size_label)"                      FORMAT 999,999
COLUMN DATAFILE_UnMirroredSize     HEADING "Data|File|(&&size_label)"                  FORMAT 999,999
COLUMN TEMPFILE_UnMirroredSize     HEADING "Temp|File|(&&size_label)"                  FORMAT 999,999
COLUMN ONLINELOG_UnMirroredSize    HEADING "Redo|Log|(&&size_label)"                   FORMAT 9,999
COLUMN ARCHIVELOG_UnMirroredSize   HEADING "Arch|Log|(&&size_label)"                   FORMAT 999,999
COLUMN BACKUPSET_UnMirroredSize    HEADING "Backup|Set|(&&size_label)"                 FORMAT 999,999
COLUMN FLASHBACK_UnMirroredSize    HEADING "Flash|Back|(&&size_label)"                 FORMAT 999,999
COLUMN OCRFILE_UnMirroredSize      HEADING "OCR|(&&size_label)"                        FORMAT 999
COLUMN AUTOBACKUP_UnMirroredSize   HEADING "Auto|Backup|(&&size_label)"                FORMAT 999,999
COLUMN CONTROLFILE_UnMirroredSize  HEADING "Ctrl|File|(&&size_label)"                  FORMAT 999
COLUMN PARAMFILE_UnMirroredSize    HEADING "Param|File|(&&size_label)"                 FORMAT 999

COLUMN DISKGROUP_MirroredSize      HEADING "Total|(&&size_label)"                      FORMAT 999,999
COLUMN DATAFILE_MirroredSize       HEADING "Data|File|(&&size_label)"                  FORMAT 999,999
COLUMN TEMPFILE_MirroredSize       HEADING "Temp|File|(&&size_label)"                  FORMAT 999,999
COLUMN ONLINELOG_MirroredSize      HEADING "Redo|Log|(&&size_label)"                   FORMAT 9,999
COLUMN ARCHIVELOG_MirroredSize     HEADING "Arch|Log|(&&size_label)"                   FORMAT 999,999
COLUMN BACKUPSET_MirroredSize      HEADING "Backup|Set|(&&size_label)"                 FORMAT 999,999
COLUMN FLASHBACK_MirroredSize      HEADING "Flash|Back|(&&size_label)"                 FORMAT 999,999
COLUMN OCRFILE_MirroredSize        HEADING "OCR|(&&size_label)"                        FORMAT 999
COLUMN AUTOBACKUP_MirroredSize     HEADING "Auto|Backup|(&&size_label)"                FORMAT 999,999
COLUMN CONTROLFILE_MirroredSize    HEADING "Ctrl|File|(&&size_label)"                  FORMAT 999
COLUMN PARAMFILE_MirroredSize      HEADING "Param|File|(&&size_label)"                 FORMAT 999

BREAK ON REPORT 

COMPUTE SUM LABEL 'Total' OF DISKGROUP_MirroredSize     FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF DATAFILE_MirroredSize      FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF TEMPFILE_MirroredSize      FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF ONLINELOG_MirroredSize     FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF ARCHIVELOG_MirroredSize    FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF BACKUPSET_MirroredSize     FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF FLASHBACK_MirroredSize     FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF OCRFILE_MirroredSize       FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF AUTOBACKUP_MirroredSize    FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF CONTROLFILE_MirroredSize   FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF PARAMFILE_MirroredSize     FORMAT 99,999,999  ON REPORT

COMPUTE SUM LABEL 'Total' OF DISKGROUP_UnMirroredSize   FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF DATAFILE_UnMirroredSize    FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF TEMPFILE_UnMirroredSize    FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF ONLINELOG_UnMirroredSize   FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF ARCHIVELOG_UnMirroredSize  FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF BACKUPSET_UnMirroredSize   FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF FLASHBACK_UnMirroredSize   FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF OCRFILE_UnMirroredSize     FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF AUTOBACKUP_UnMirroredSize  FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF CONTROLFILE_UnMirroredSize FORMAT 99,999,999  ON REPORT
COMPUTE SUM LABEL 'Total' OF PARAMFILE_UnMirroredSize   FORMAT 99,999,999  ON REPORT



/*
Sample Output

*******************************************************************
*   A S M    S P A C E   U S A G E   B Y    F I L E T Y P E       *
*                                                                 *
*   - For all diskgroups mounted in current instance              *
*   - Including files for other databases                         *
*******************************************************************


-               <----------------------- Mirrored (GB) ---------------------------------------> <-----------------------  UnMirrored (GB) ------------------------------------->

                                             Redo     Arch   Backup          Auto Control Param                              Redo     Arch                    Auto Control Param
                   Total DataFile TempFile    Log      Log      Set  OCR   Backup    File  File    Total DataFile TempFile    Log      Log BackupSet  OCR   Backup    File  File
DiskGroup           (GB)     (GB)     (GB)   (GB)     (GB)     (GB) (GB)     (GB)    (GB)  (GB)     (GB)     (GB)     (GB)   (GB)     (GB)      (GB) (GB)     (GB)    (GB)  (GB)
--------------- -------- -------- -------- ------ -------- -------- ---- -------- ------- ----- -------- -------- -------- ------ -------- --------- ---- -------- ------- -----
DATA               8,129    5,698        0     94    2,328        0    0        8       0     0   16,273   11,397        0    189    4,667         0    0       17       1     0
DATA_DM01         44,472   43,727        0    745        0        0    0        0       0     0   88,973   87,480        0  1,492        0         0    0        0       1     0
FLASH_DM01           881        0      881      0        0        0    0        0       0     0    1,764        0    1,764      0        0         0    0        0       0     0
RECO              21,883   21,629      164     88        0        0    0        0       1     0   43,782   43,273      329    176        0         0    0        0       4     0
RECO_DM01         38,510    4,442       23    121   33,923        0    0        1       0     0   77,186    8,885       46    243   68,011         0    0        2       1     0
SYSTEMDG               0        0        0      0        0        0    0        0       0     0        1        0        0      0        0         0    1        0       0     0
                -------- -------- -------- ------ -------- -------- ---- -------- ------- ----- -------- -------- -------- ------ -------- --------- ---- -------- ------- -----
Total            113,875   75,496    1,068  1,048   36,251        0    0        9       1     0  227,979  151,035    2,139  2,100   72,678         0    1       19       7     0

*/

PROMPT 
PROMPT 
PROMPT  -               <----------------------- Mirrored (GB) ----------------------------------> <-----------------------  UnMirrored (GB) ------------------------------------>

select dg.name
     , ROUND(SUM(f.bytes)/&&size_divider)                                   DISKGROUP_MirroredSize
     , ROUND(SUM(DECODE(f.type, 'DATAFILE',f.bytes,0))/&&size_divider)      DATAFILE_MirroredSize
     , ROUND(SUM(DECODE(f.type, 'TEMPFILE',f.bytes,0))/&&size_divider)      TEMPFILE_MirroredSize
     , ROUND(SUM(DECODE(f.type, 'ONLINELOG',f.bytes,0))/&&size_divider)     ONLINELOG_MirroredSize
     , ROUND(SUM(DECODE(f.type, 'ARCHIVELOG',f.bytes,0))/&&size_divider)    ARCHIVELOG_MirroredSize
     , ROUND(SUM(DECODE(f.type, 'BACKUPSET',f.bytes,0))/&&size_divider)     BACKUPSET_MirroredSize
     , ROUND(SUM(DECODE(f.type, 'FLASHBACK',f.bytes,0))/&&size_divider)     FLASHBACK_MirroredSize
     , ROUND(SUM(DECODE(f.type, 'OCRFILE',f.bytes,0))/&&size_divider)       OCRFILE_MirroredSize
     , ROUND(SUM(DECODE(f.type, 'AUTOBACKUP',f.bytes,0))/&&size_divider)    AUTOBACKUP_MirroredSize
   --, ROUND(SUM(DECODE(f.type, 'CONTROLFILE',f.bytes,0))/&&size_divider)   CONTROLFILE_MirroredSize
   --, ROUND(SUM(DECODE(f.type, 'PARAMETERFILE',f.bytes,'ASMPARAMETERFILE',f.bytes,0))/&&size_divider) PARAMFILE_MirroredSize

     , ROUND(SUM(f.space)/&&size_divider)                                   DISKGROUP_UnMirroredSize
     , ROUND(SUM(DECODE(f.type, 'DATAFILE',f.space,0))/&&size_divider)      DATAFILE_UnMirroredSize
     , ROUND(SUM(DECODE(f.type, 'TEMPFILE',f.space,0))/&&size_divider)      TEMPFILE_UnMirroredSize
     , ROUND(SUM(DECODE(f.type, 'ONLINELOG',f.space,0))/&&size_divider)     ONLINELOG_UnMirroredSize
     , ROUND(SUM(DECODE(f.type, 'ARCHIVELOG',f.space,0))/&&size_divider)    ARCHIVELOG_UnMirroredSize
     , ROUND(SUM(DECODE(f.type, 'BACKUPSET',f.space,0))/&&size_divider)     BACKUPSET_UnMirroredSize
     , ROUND(SUM(DECODE(f.type, 'FLASHBACK',f.space,0))/&&size_divider)     FLASHBACK_UnMirroredSize
     , ROUND(SUM(DECODE(f.type, 'OCRFILE',f.space,0))/&&size_divider)       OCRFILE_UnMirroredSize
     , ROUND(SUM(DECODE(f.type, 'AUTOBACKUP',f.space,0))/&&size_divider)    AUTOBACKUP_UnMirroredSize
   --, ROUND(SUM(DECODE(f.type, 'CONTROLFILE',f.space,0))/&&size_divider)   CONTROLFILE_UnMirroredSize
   --, ROUND(SUM(DECODE(f.type, 'PARAMETERFILE',f.space,'ASMPARAMETERFILE',f.space,0))/&&size_divider) PARAMFILE_UnMirroredSize
from  v$asm_file f
    , v$asm_diskgroup_stat dg
where dg.group_number = f.group_number
group by dg.name
ORDER BY dg.name
;
 

@@footer
