Monday, July 14, 2014

Script to Monitor the RMAN JOBs in Detail

Script to monitor the RMAN running jobs in detail.


$ cat > rman.sql


*********************************************************************
alter session set nls_date_format='dd-mon-rr hh24:mi:ss';

set lines 1500
set pages 100
col CLI_INFO format a10
col spid format a5
col ch format a20
col seconds format 999999.99
col filename format a65
col bfc  format 9
col "% Complete" format 999.99
col event format a40
set numwidth 10

select sysdate from dual;
REM gv$session_longops (channel level)
prompt
prompt Channel progress - gv$session_longops:
prompt
select s.inst_id, o.sid, CLIENT_INFO ch, context, sofar, totalwork,
                    round(sofar/totalwork*100,2) "% Complete"
     FROM gv$session_longops o, gv$session s
     WHERE opname LIKE 'RMAN%'
     AND opname NOT LIKE '%aggregate%'
     AND o.sid=s.sid
     AND totalwork != 0
     AND sofar <> totalwork;

REM Check wait events (RMAN sessions) - this is for CURRENT waits only
REM use the following for 11G+
prompt
prompt Session progess - CURRENT wait events and time in wait so far:
prompt
select inst_id, sid, CLIENT_INFO ch, seq#, event, state, wait_time_micro/1000000 seconds
from gv$session where program like '%rman%' and
wait_time = 0 and
not action is null;

REM gv$backup_async_io
prompt
prompt Disk (file and backuppiece) progress - includes tape backuppiece
prompt if backup_tape_io_slaves=TRUE:
prompt
select s.inst_id, a.sid, CLIENT_INFO Ch, a.STATUS,
open_time, round(BYTES/1024/1024,2) "SOFAR Mb" , round(total_bytes/1024/1024,2)
TotMb, io_count,
round(BYTES/TOTAL_BYTES*100,2) "% Complete" , a.type, filename
from gv$backup_async_io a,  gv$session s
where not a.STATUS in ('UNKNOWN')
and a.sid=s.sid and open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss') order by 2,7;

REM gv$backup_sync_io
prompt
prompt Tape backuppiece progress (only if backup_tape_io_slaves=FALSE):
prompt
col FILENAME for a50
set line 400 pagesize 100
select s.inst_id, a.sid, CLIENT_INFO Ch, filename, a.type, a.status, buffer_size bsz, buffer_count bfc,
open_time open, io_count
from gv$backup_sync_io a, gv$session s
where
a.sid=s.sid and
open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss') ;

*******************************************************************************



O/p of the script.


SQL> select to_char(sysdate,'dd-mon-yy hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'D

------------------

14-jul-14 15:19:57

SQL> @rman.sql '14-jul-14 15:19:57'

Session altered.

 

SYSDATE

------------------

14-jul-14 15:21:58

 

Channel progress - gv$session_longops:

 

INST_ID SID CH CONTEXT SOFAR TOTALWORK % Complete

---------- ---------- -------------------- ---------- ---------- ---------- ----------

1 54 rman channel=ORA_DIS 1 142524 236800 60.19

K_1

 

 

Session progess - CURRENT wait events and time in wait so far:

 

INST_ID SID CH SEQ# EVENT STATE SECONDS

---------- ---------- -------------------- ---------- ---------------------------------------- ------------------- ----------

1 42 1407 SQL*Net message from client WAITING 34.21

1 54 rman channel=ORA_DIS 2654 RMAN backup & recovery I/O WAITING .02

K_1

 

 

Disk (file and backuppiece) progress - includes tape backuppiece

if backup_tape_io_slaves=TRUE:

old 7: and a.sid=s.sid and open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss') order by 2,7

new 7: and a.sid=s.sid and open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss') order by 2,7

INST_ID SID CH STATUS OPEN_TIME SOFAR Mb TOTMB IO_COUNT % Complete TYPE FILENAME

---------- ---------- -------------------- ----------- ------------------ ---------- ---------- ---------- ---------- --------- -----------------------------------------------------------------

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 1.5 5 5 30.00 INPUT /u01/app/oracle/oradata/db1/users01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 55 55 112 100.00 INPUT /u01/app/oracle/oradata/db1/undotbs01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 10 500 22 2.00 INPUT /u01/app/oracle/oradata/db1/test01.dbf

K_1

1 54 rman channel=ORA_DIS IN PROGRESS 14-jul-14 15:21:25 276.99 580 554 47.76 INPUT /u01/app/oracle/oradata/db1/sysaux01.dbf

K_1

1 54 rman channel=ORA_DIS IN PROGRESS 14-jul-14 15:21:25 276.99 710 554 39.01 INPUT /u01/app/oracle/oradata/db1/system01.dbf

K_1

1 54 rman channel=ORA_DIS IN PROGRESS 14-jul-14 15:21:24 462.99 464 OUTPUT/u01/app/oracle/fast_recovery_area/DB1/backupset/2014_07_14/o1_mf

K_1 _nnndf_TAG20140714T152124_9w7b0wwj_.bkp

 

6 rows selected.

 

Tape backuppiece progress (only if backup_tape_io_slaves=FALSE):

old 6: open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss')

new 6: open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss')

no rows selected

SQL> /

old 6: open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss')

new 6: open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss')

no rows selected

SQL> @rman.sql '14-jul-14 15:19:57'

Session altered.

 

SYSDATE

------------------

14-jul-14 15:22:42

 

Channel progress - gv$session_longops:

 

INST_ID SID CH CONTEXT SOFAR TOTALWORK % Complete

---------- ---------- -------------------- ---------- ---------- ---------- ----------

1 54 rman channel=ORA_DIS 1 236158 236800 99.73

K_1

 

 

Session progess - CURRENT wait events and time in wait so far:

 

INST_ID SID CH SEQ# EVENT STATE SECONDS

---------- ---------- -------------------- ---------- ---------------------------------------- ------------------- ----------

1 42 1407 SQL*Net message from client WAITING 77.77

 

Disk (file and backuppiece) progress - includes tape backuppiece

if backup_tape_io_slaves=TRUE:

old 7: and a.sid=s.sid and open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss') order by 2,7

new 7: and a.sid=s.sid and open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss') order by 2,7

INST_ID SID CH STATUS OPEN_TIME SOFAR Mb TOTMB IO_COUNT % Complete TYPE FILENAME

---------- ---------- -------------------- ----------- ------------------ ---------- ---------- ---------- ---------- --------- -----------------------------------------------------------------

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 1.5 5 5 30.00 INPUT /u01/app/oracle/oradata/db1/users01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 55 55 112 100.00 INPUT /u01/app/oracle/oradata/db1/undotbs01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 10 500 22 2.00 INPUT /u01/app/oracle/oradata/db1/test01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 536 580 1074 92.41 INPUT /u01/app/oracle/oradata/db1/sysaux01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 704.5 710 1411 99.23 INPUT /u01/app/oracle/oradata/db1/system01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:24 1077.8 1078 OUTPUT/u01/app/oracle/fast_recovery_area/DB1/backupset/2014_07_14/o1_mf

K_1 _nnndf_TAG20140714T152124_9w7b0wwj_.bkp

 

6 rows selected.

 

Tape backuppiece progress (only if backup_tape_io_slaves=FALSE):

old 6: open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss')

new 6: open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss')

no rows selected





References. OTN DOC


SQL> select to_char(sysdate,'dd-mon-yy hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'D

------------------

14-jul-14 15:19:57

SQL> @rman.sql '14-jul-14 15:19:57'

Session altered.

 

SYSDATE

------------------

14-jul-14 15:21:58

 

Channel progress - gv$session_longops:

 

INST_ID SID CH CONTEXT SOFAR TOTALWORK % Complete

---------- ---------- -------------------- ---------- ---------- ---------- ----------

1 54 rman channel=ORA_DIS 1 142524 236800 60.19

K_1

 

 

Session progess - CURRENT wait events and time in wait so far:

 

INST_ID SID CH SEQ# EVENT STATE SECONDS

---------- ---------- -------------------- ---------- ---------------------------------------- ------------------- ----------

1 42 1407 SQL*Net message from client WAITING 34.21

1 54 rman channel=ORA_DIS 2654 RMAN backup & recovery I/O WAITING .02

K_1

 

 

Disk (file and backuppiece) progress - includes tape backuppiece

if backup_tape_io_slaves=TRUE:

old 7: and a.sid=s.sid and open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss') order by 2,7

new 7: and a.sid=s.sid and open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss') order by 2,7

INST_ID SID CH STATUS OPEN_TIME SOFAR Mb TOTMB IO_COUNT % Complete TYPE FILENAME

---------- ---------- -------------------- ----------- ------------------ ---------- ---------- ---------- ---------- --------- -----------------------------------------------------------------

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 1.5 5 5 30.00 INPUT /u01/app/oracle/oradata/db1/users01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 55 55 112 100.00 INPUT /u01/app/oracle/oradata/db1/undotbs01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 10 500 22 2.00 INPUT /u01/app/oracle/oradata/db1/test01.dbf

K_1

1 54 rman channel=ORA_DIS IN PROGRESS 14-jul-14 15:21:25 276.99 580 554 47.76 INPUT /u01/app/oracle/oradata/db1/sysaux01.dbf

K_1

1 54 rman channel=ORA_DIS IN PROGRESS 14-jul-14 15:21:25 276.99 710 554 39.01 INPUT /u01/app/oracle/oradata/db1/system01.dbf

K_1

1 54 rman channel=ORA_DIS IN PROGRESS 14-jul-14 15:21:24 462.99 464 OUTPUT/u01/app/oracle/fast_recovery_area/DB1/backupset/2014_07_14/o1_mf

K_1 _nnndf_TAG20140714T152124_9w7b0wwj_.bkp

 

6 rows selected.

 

Tape backuppiece progress (only if backup_tape_io_slaves=FALSE):

old 6: open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss')

new 6: open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss')

no rows selected

SQL> /

old 6: open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss')

new 6: open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss')

no rows selected

SQL> @rman.sql '14-jul-14 15:19:57'

Session altered.

 

SYSDATE

------------------

14-jul-14 15:22:42

 

Channel progress - gv$session_longops:

 

INST_ID SID CH CONTEXT SOFAR TOTALWORK % Complete

---------- ---------- -------------------- ---------- ---------- ---------- ----------

1 54 rman channel=ORA_DIS 1 236158 236800 99.73

K_1

 

 

Session progess - CURRENT wait events and time in wait so far:

 

INST_ID SID CH SEQ# EVENT STATE SECONDS

---------- ---------- -------------------- ---------- ---------------------------------------- ------------------- ----------

1 42 1407 SQL*Net message from client WAITING 77.77

 

Disk (file and backuppiece) progress - includes tape backuppiece

if backup_tape_io_slaves=TRUE:

old 7: and a.sid=s.sid and open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss') order by 2,7

new 7: and a.sid=s.sid and open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss') order by 2,7

INST_ID SID CH STATUS OPEN_TIME SOFAR Mb TOTMB IO_COUNT % Complete TYPE FILENAME

---------- ---------- -------------------- ----------- ------------------ ---------- ---------- ---------- ---------- --------- -----------------------------------------------------------------

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 1.5 5 5 30.00 INPUT /u01/app/oracle/oradata/db1/users01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 55 55 112 100.00 INPUT /u01/app/oracle/oradata/db1/undotbs01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 10 500 22 2.00 INPUT /u01/app/oracle/oradata/db1/test01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 536 580 1074 92.41 INPUT /u01/app/oracle/oradata/db1/sysaux01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:25 704.5 710 1411 99.23 INPUT /u01/app/oracle/oradata/db1/system01.dbf

K_1

1 54 rman channel=ORA_DIS FINISHED 14-jul-14 15:21:24 1077.8 1078 OUTPUT/u01/app/oracle/fast_recovery_area/DB1/backupset/2014_07_14/o1_mf

K_1 _nnndf_TAG20140714T152124_9w7b0wwj_.bkp

 

6 rows selected.

 

Tape backuppiece progress (only if backup_tape_io_slaves=FALSE):

old 6: open_time > to_date('&1', 'dd-mon-rr hh24:mi:ss')

new 6: open_time > to_date('14-jul-14 15:19:57', 'dd-mon-rr hh24:mi:ss')

no rows selected

References. OTN DOC ID.1487262.1



No comments:

Post a Comment