SHELL SCRIPT TO MONITOR RMAN RESTORE PROGRESS IN REALTIME ORACLE
Sample output:

Use this shell script to monitor the RMAN restore progress in realtime. You will not regret using this script when you have a need to immediately monitor the restore and report the percentage to client.
You have to modify certain parameters ,redirection and filtering of output as per your requirement. I had researched a lot to prepare the script.This script worked well for me however ! Hope you like this article.
#!/bin/bash
#Set the environment
_env(){
RESTORE_PROGRESS=/tmp/restore_progress.log
export PATH=/apps01/product/12.1.0/dbhome_1/bin:/usr/sbin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/oracle/.local/bin:/home/oracle/bin
export ORACLE_HOME=/apps01/product/12.1.0/dbhome_1
export ORACLE_SID=orcl19x
touch dfsize
export SIZELOG=dfsize
}
#RMAN restore progress monitor in percentage from database
_restore_pct(){
while sleep 0.5;do
date_is=$(date "+%F-%H-%M-%S")
#ela_s=$(date +%s)
#echo "============================================================"+
#echo " ----->$ORACLE_SID<----- |"|tr 'a-z' 'A-Z';echo " Restore progress ($date_is) |"
#echo "============================================================"+
$ORACLE_HOME/bin/sqlplus -S "/ as sysdba" << EOF > dbsz.txt
set feedback off
set lines 200
set pages 1000
set termout off
col INPUT_BYTES/1024/1024 format 9999999
col OUTPUT_BYTES/1024/1024 format 9999999
col OBJECT_TYPE format a10
set serveroutput off
spool dbsz.out
variable s_num number;
BEGIN
select sum((datafile_blocks)*8/1024) into :s_num from v\$BACKUP_DATAFILE;
dbms_output.put_line(:s_num);
END;
/
set feedback on
select INPUT_BYTES/1024/1024 as inp_byte,OUTPUT_BYTES/1024/1024 as out_byte,OBJECT_TYPE,100*(MBYTES_PROCESSED/:s_num) as pctdone from v\$rman_status where status like '%RUNNING%';
spool off
EOF
#Realtime monitoring of RMAN restore which shows date and percentage of completion
pct="$(cat dbsz.txt|grep -v 'row'|tail -3|grep -v '^$'|awk '{print $5}')"
clear;
echo "$date_is|Current restore progress for $ORACLE_SID:[$pct]"
#cat $SIZELOG|grep -v 'PL'
#cat /dev/null > $SIZELOG
done
}
#ela_e=$(date +%s)
#echo "elapsed_time: $($ela_e - $ela_s)
_env
_restore_pct