Вы находитесь на странице: 1из 6

#!/bin/ksh export DATE_STAMP=`date "+%m%d%Y%H%M"` export ORACLE_SID=prdoem1 export ORACLE_HOME=/u01/app/oracle/product/10.2.0.

4/dbee_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH export PATH=$PATH:$ORACLE_HOME/bin case when command_id like '%FUL%' then 'DB FULL' when command_id like '%INC%' then 'DB INCR' else command_id end b group ( select

================================================================================ === select distinct upper(a.db_name) dbname, b.START_TIME last_bkp_date, b.status last_bkp_status, case when COMMAND_ID like '%FUL%' then 'DB FULL' when COMMAND_ID like '%INC%' then 'DB INCR' end bkp_type from rman.RC_RMAN_BACKUP_JOB_DETAILS a, MGMT$JOB_EXECUTION_HISTORY b where a.db_name=upper(b.target_name) and a.db_name='PRDOLE' and (a.COMMAND_ID like '%FUL%' OR a.COMMAND_ID like '%INC%') and b.status in ('Succeeded','Failed','Error') order by b.start_time

select distinct d.target_name from (select distinct upper(b.target_name) target_name from rman.RC_RMAN_BACKUP_JOB_DETAILS a,MGMT$JOB_EXECUTION_HISTORY b where a.db_name=upper(b.target_name) ) c,mgmt_targets d where upper(d.target_name) = c.target_name (+) and d.target_type in ( 'oracle_database','rac_database') and d.target_name not like '%/_%' escape '/'

select distinct d.target_name,c.START_TIME from (select b.target_name,a.command_id bkp_type,b.status bkp_status,b.start_time from rman.RC_RMAN_BACKUP_JOB_DETAILS a,MGMT$JOB_EXECUTION_HISTORY b where a.db_name=upper(b.target_name) ) c,mgmt_targets d where upper(d.target_name) = c.target_name (+) and d.target_type in ( 'oracle_database','rac_database') and d.target_name not like '%/_%' escape '/' and (c.bkp_type like '%FUL%' OR c.bkp_type like '%INC%' ) and upper(d.target_name)='PRDOLE'

================================================================================ ==========

select distinct upper(c.target_name) target_name from rman.RC_RMAN_BACKUP_JOB_DETAILS a,MGMT$JOB_EXECUTION_HISTORY b,mgmt_targe ts c where upper(c.target_name)=upper(b.target_name (+)) and upper(c.target_name)= upper(a.db_name(+)) and c.target_type in ( 'oracle_database','rac_database') and c.target_name not like '%/_%' escape '/' select upper(target_name) DB_NAME from mgmt_targets where target_type in ( 'oracle_database','rac_database') and target_name not like '%/_%' escape '/' minus select distinct upper(target_name) DB_NAME from mgmt_targets where target_type in ( 'oracle_database','rac_database') and target_name not like '%/_%' escape '/'

select distinct target_name from mgmt_targets where a.db_name=upper(b.target_name)

STATUS ----------------------FAILED COMPLETED WITH ERRORS RUNNING WITH ERRORS COMPLETED WITH WARNINGS RUNNING COMPLETED STATUS

---------------------------------------Succeeded Failed Suspended: Agent Unreacheable 17 Stopped Suspended By User Scheduled 12 20 Running Error Skipped

select status ,target_name,start_time,job_name from MGMT$JOB_EXECUTION_HISTORY where upper(target_name)='PRDOLE' and (JOB_NAME like '%FUL%' OR JOB_NAME like '%INC%') --and to_char(START_TIME,'DD-MON-YY')='27-OCT-10' order by start_time ================================================================================ ============

Why dont you make life easy on yourself and use "nail" or "metasend" -metasend allows HTML attachments and many different encoding options -nail is nice command line based replacement for mail/mailx that will allow you to attach files and it will encode them. you simply do it with swtiches (-a i th ink) nail -s TEST -a db_bckp_info.html santhosh.gopishetty@gmail.com nail -s test -a file1 -a file2 bla@bla.com < /dev/null

Working -----------select dbname, max(last_bkp_date), --last_bkp_status, bkp_type from ( select upper(db_name) dbname, START_TIME last_bkp_date, status last_bkp_status, case when COMMAND_ID like '%FUL%' then 'DB FULL' when COMMAND_ID like '%INC%' then 'DB INCR' else COMMAND_ID end bkp_type from rman.RC_RMAN_BACKUP_JOB_DETAILS UNION

select upper(TARGET_NAME) dbname, START_TIME last_bkp_date, status last_bkp_st atus, case when JOB_NAME like '%FUL%' then 'DB FULL' when JOB_NAME like '%INC%' then 'DB INCR' else JOB_NAME end bkp_type from MGMT$JOB_EXECUTION_HISTORY where START_TIME < sysdate ) where upper(dbname)='PRDOLE' and (bkp_type = 'DB FULL' OR bkp_type = 'DB INCR') group by dbname,bkp_type;

====================================================== DBNAME -------DEV2AGL DEV2MRS DEVASUR DEVGH DEVMGCR1 DEVRPM DEVTWS POC1SWB PRDESB PRDFSCM PRDGSARC PRDINF2 PRDOLE PRDSPQ STG1CCM STGDECO STGDECO STGLSCSP STGVIGN2 LAST_BKP_ --------30-AUG-10 24-JUL-10 03-APR-10 22-NOV-09 16-AUG-09 13-SEP-09 01-MAY-09 29-JUL-07 02-SEP-10 30-AUG-10 29-AUG-10 08-SEP-08 08-AUG-10 06-SEP-10 29-AUG-10 18-JUN-08 20-SEP-08 04-JUL-10 29-AUG-10 LAST_BKP_STATUS ----------------------COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED COMPLETED INPUT_TYPE ------------DB INCR DB FULL DB FULL DB FULL DB INCR DB FULL DB FULL DB FULL DB INCR DB INCR DB INCR DB INCR DB INCR DB INCR DB FULL DB INCR DB INCR DB FULL DB FULL

SQL> desc MGMT$JOB_EXECUTION_HISTORY Name ----------------------------------------JOB_NAME JOB_OWNER JOB_ID JOB_TYPE EXECUTION_ID SCHEDULED_TIME START_TIME END_TIME STATUS TARGET_NAME TARGET_TYPE TARGET_GUID

Null? -------NOT NULL NOT NULL NOT NULL NOT NULL NOT NULL

Type ---------------------------VARCHAR2(64) VARCHAR2(256) RAW(16) VARCHAR2(32) RAW(16) DATE DATE DATE VARCHAR2(40) VARCHAR2(256) VARCHAR2(64) RAW(16)

SQL> desc rman.RC_RMAN_BACKUP_JOB_DETAILS Name Null? ----------------------------------------- -------DB_KEY DB_NAME SESSION_KEY SESSION_RECID SESSION_STAMP COMMAND_ID START_TIME END_TIME INPUT_BYTES OUTPUT_BYTES STATUS_WEIGHT OPTIMIZED_WEIGHT INPUT_TYPE_WEIGHT OUTPUT_DEVICE_TYPE AUTOBACKUP_COUNT BACKED_BY_OSB AUTOBACKUP_DONE STATUS INPUT_TYPE OPTIMIZED ELAPSED_SECONDS COMPRESSION_RATIO INPUT_BYTES_PER_SEC OUTPUT_BYTES_PER_SEC INPUT_BYTES_DISPLAY OUTPUT_BYTES_DISPLAY INPUT_BYTES_PER_SEC_DISPLAY OUTPUT_BYTES_PER_SEC_DISPLAY TIME_TAKEN_DISPLAY SQL> desc mgmt_targets Name ----------------------------------------TARGET_NAME TARGET_TYPE TYPE_META_VER CATEGORY_PROP_1 CATEGORY_PROP_2 CATEGORY_PROP_3 CATEGORY_PROP_4 CATEGORY_PROP_5 TARGET_GUID LOAD_TIMESTAMP TIMEZONE_DELTA TIMEZONE_REGION DISPLAY_NAME OWNER TYPE_DISPLAY_NAME SERVICE_TYPE HOST_NAME EMD_URL LAST_LOAD_TIME IS_GROUP BROKEN_REASON BROKEN_STR

Type ---------------------------NUMBER VARCHAR2(8) NUMBER NUMBER NUMBER VARCHAR2(33) DATE DATE NUMBER NUMBER NUMBER NUMBER NUMBER VARCHAR2(17) NUMBER VARCHAR2(3) VARCHAR2(3) VARCHAR2(23) VARCHAR2(13) VARCHAR2(3) NUMBER NUMBER NUMBER NUMBER VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000)

Null? -------NOT NULL NOT NULL

Type ---------------------------VARCHAR2(256) VARCHAR2(64) VARCHAR2(8) VARCHAR2(64) VARCHAR2(64) VARCHAR2(64) VARCHAR2(64) VARCHAR2(64) NOT NULL RAW(16) DATE NUMBER VARCHAR2(64) VARCHAR2(256) VARCHAR2(256) VARCHAR2(128) VARCHAR2(64) VARCHAR2(256) VARCHAR2(1024) DATE NUMBER(1) NUMBER VARCHAR2(512)

LAST_RT_LOAD_TIME LAST_UPDATED_TIME MONITORING_MODE REP_SIDE_AVAIL LAST_E2E_LOAD_TIME IS_PROPAGATING

DATE DATE NUMBER NUMBER DATE NUMBER(1)