cat awr.sql ######EXEC P_AWR_REPORT('201604251000', '201604251100', 'D_OUTPUT', '', FALSE); FALSE为rac生成awr

EXEC P_AWR_REPORT('201604251000', '201604251100', 'D_OUTPUT', '', FALSE);
CREATE DIRECTORY D_OUTPUT AS '/oracle/products/11.2/db/scripts/mon/log';
CREATE DIRECTORY D_OUTPUT AS '/oracle/db/scripts/mon/log';
############sqlplus下新建DIRECTORY后在sqlplus下执行一下存储过程执行完毕后执行EXEC P_AWR_REPORT('201604251000', '201604251100', 'D_OUTPUT', '', FALSE);测试####################
CREATE OR REPLACE PROCEDURE P_AWR_REPORT (
P_BEGIN IN VARCHAR2,
P_END IN VARCHAR2,
P_DIR IN VARCHAR2,
P_DBNAME IN VARCHAR2 DEFAULT '',
P_PERINTERVAL IN BOOLEAN DEFAULT FALSE) AS
TYPE T_VARCHAR IS TABLE OF VARCHAR2(1500 CHAR) INDEX BY BINARY_INTEGER;
V_REPORT T_VARCHAR;
V_FILE UTL_FILE.FILE_TYPE;
TYPE T_NUM IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
TYPE T_DATE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
V_INSTANCE T_NUM;
V_SNAP_BEG T_NUM;
V_SNAP_END T_NUM;
V_BEGIN_DATE T_DATE;
V_END_DATE T_DATE;
V_BEGIN NUMBER;
V_END NUMBER;
V_DBID NUMBER;
V_DBNAME V$DATABASE.NAME%TYPE;
BEGIN

IF P_DBNAME IS NOT NULL THEN
SELECT DISTINCT DBID, DB_NAME
INTO V_DBID, V_DBNAME
FROM DBA_HIST_DATABASE_INSTANCE
WHERE DB_NAME = P_DBNAME;
ELSE
SELECT DBID, NAME
INTO V_DBID, V_DBNAME
FROM V$DATABASE;
END IF;

SELECT DISTINCT INSTANCE_NUMBER,
FIRST_VALUE(SNAP_ID) OVER(PARTITION BY INSTANCE_NUMBER ORDER BY ABS(CAST (END_INTERVAL_TIME AS DATE) - TO_DATE(P_BEGIN, 'YYYYMMDDHH24MISS'))),
FIRST_VALUE(END_INTERVAL_TIME) OVER(PARTITION BY INSTANCE_NUMBER ORDER BY ABS(CAST (END_INTERVAL_TIME AS DATE) - TO_DATE(P_BEGIN, 'YYYYMMDDHH24MISS')))
BULK COLLECT INTO V_INSTANCE, V_SNAP_BEG, V_BEGIN_DATE
FROM DBA_HIST_SNAPSHOT
WHERE DBID = V_DBID
ORDER BY INSTANCE_NUMBER;

FOR I IN V_INSTANCE.FIRST..V_INSTANCE.LAST LOOP
BEGIN
SELECT DISTINCT FIRST_VALUE(SNAP_ID) OVER(ORDER BY ABS(CAST (END_INTERVAL_TIME AS DATE) - TO_DATE(P_END, 'YYYYMMDDHH24MISS'))),
FIRST_VALUE(END_INTERVAL_TIME) OVER(ORDER BY ABS(CAST (END_INTERVAL_TIME AS DATE) - TO_DATE(P_END, 'YYYYMMDDHH24MISS')))
INTO V_SNAP_END(I), V_END_DATE(I)
FROM DBA_HIST_SNAPSHOT
WHERE SNAP_ID > V_SNAP_BEG(I)
AND DBID = V_DBID
AND INSTANCE_NUMBER = V_INSTANCE(I);
EXCEPTION
WHEN NO_DATA_FOUND THEN
V_INSTANCE.DELETE(I);
END;
END LOOP;

IF V_INSTANCE.COUNT = 1
THEN
V_BEGIN := V_SNAP_BEG(1);
IF P_PERINTERVAL = FALSE
THEN
V_END := V_SNAP_END(1);
ELSE
V_END := V_SNAP_BEG(1) + 1;
SELECT END_INTERVAL_TIME
INTO V_END_DATE(1)
FROM DBA_HIST_SNAPSHOT
WHERE DBID = V_DBID
AND INSTANCE_NUMBER = 1
AND SNAP_ID = V_END;
END IF;
WHILE(V_END <= V_SNAP_END(1)) LOOP
V_FILE := UTL_FILE.FOPEN(
P_DIR,
'awrrpt_' || V_DBNAME || '_' || V_INSTANCE(1) || '_'
|| TO_CHAR(V_BEGIN_DATE(1), 'YYYYMMDDHH24MI') || '_'
|| TO_CHAR(V_END_DATE(1), 'YYYYMMDDHH24MI') || '.html',
'w',
32767);

SELECT OUTPUT
BULK COLLECT INTO V_REPORT
FROM TABLE(
DBMS_WORKLOAD_REPOSITORY.AWR_REPORT_HTML(
V_DBID,
V_INSTANCE(1),
V_BEGIN,
V_END,
0));
FOR I IN 1..V_REPORT.COUNT LOOP
UTL_FILE.PUT_LINE(V_FILE, V_REPORT(I));
END LOOP;
UTL_FILE.FCLOSE(V_FILE);
V_BEGIN := V_BEGIN + 1;
V_END := V_END + 1;
V_BEGIN_DATE(1) := V_END_DATE(1);
SELECT END_INTERVAL_TIME
INTO V_END_DATE(1)
FROM DBA_HIST_SNAPSHOT
WHERE DBID = V_DBID
AND INSTANCE_NUMBER = 1
AND SNAP_ID = V_END;
END LOOP;
ELSE
FOR I IN V_INSTANCE.FIRST..V_INSTANCE.LAST LOOP
V_BEGIN := V_SNAP_BEG(I);
IF P_PERINTERVAL = FALSE
THEN
V_END := V_SNAP_END(I);
ELSE
V_END := V_SNAP_BEG(I) + 1;
SELECT END_INTERVAL_TIME
INTO V_END_DATE(I)
FROM DBA_HIST_SNAPSHOT
WHERE DBID = V_DBID
AND INSTANCE_NUMBER = V_INSTANCE(I)
AND SNAP_ID = V_END;
END IF;
WHILE(V_END <= V_SNAP_END(I)) LOOP
V_FILE := UTL_FILE.FOPEN(
P_DIR,
'awrrpt_' || V_DBNAME || '_' || V_INSTANCE(I) || '_'
|| TO_CHAR(V_BEGIN_DATE(I), 'YYYYMMDDHH24MI') || '_'
|| TO_CHAR(V_END_DATE(I), 'YYYYMMDDHH24MI') || '.html',
'w',
32767);

SELECT OUTPUT
BULK COLLECT INTO V_REPORT
FROM TABLE(
DBMS_WORKLOAD_REPOSITORY.AWR_REPORT_HTML(
V_DBID,
V_INSTANCE(I),
V_BEGIN,
V_END,
0));
FOR I IN 1..V_REPORT.COUNT LOOP
UTL_FILE.PUT_LINE(V_FILE, V_REPORT(I));
END LOOP;
UTL_FILE.FCLOSE(V_FILE);
V_BEGIN := V_BEGIN + 1;
V_END := V_END + 1;
V_BEGIN_DATE(I) := V_END_DATE(I);
SELECT END_INTERVAL_TIME
INTO V_END_DATE(I)
FROM DBA_HIST_SNAPSHOT
WHERE DBID = V_DBID
AND INSTANCE_NUMBER = V_INSTANCE(I)
AND SNAP_ID = V_END;
END LOOP;
END LOOP;
END IF;
END;
/

cat awr.sh#!/usr/bin/ksh

#. ~/.profile #AIX小机使用 linux下注释掉即可
#DATE=`date +'%Y%m%d'`
TZ=BEIST-8
DATE=`TZ=$TZ+12;date +%Y%m%d`
#一下脚本没半个小时生成一次,awr ash addm
sqlplus / as sysdba<<eof
purge dba_recyclebin;
set serveroutput on
set timing on
set time on
begin
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0000', to_char(sysdate-1,'YYYYMMDD')||'0030', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0030', to_char(sysdate-1,'YYYYMMDD')||'0100', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0100', to_char(sysdate-1,'YYYYMMDD')||'0130', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0130', to_char(sysdate-1,'YYYYMMDD')||'0200', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0200', to_char(sysdate-1,'YYYYMMDD')||'0230', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0230', to_char(sysdate-1,'YYYYMMDD')||'0300', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0300', to_char(sysdate-1,'YYYYMMDD')||'0330', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0330', to_char(sysdate-1,'YYYYMMDD')||'0400', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0400', to_char(sysdate-1,'YYYYMMDD')||'0430', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0430', to_char(sysdate-1,'YYYYMMDD')||'0500', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0500', to_char(sysdate-1,'YYYYMMDD')||'0530', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0530', to_char(sysdate-1,'YYYYMMDD')||'0600', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0600', to_char(sysdate-1,'YYYYMMDD')||'0630', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0630', to_char(sysdate-1,'YYYYMMDD')||'0700', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0700', to_char(sysdate-1,'YYYYMMDD')||'0730', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0730', to_char(sysdate-1,'YYYYMMDD')||'0800', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0800', to_char(sysdate-1,'YYYYMMDD')||'0830', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0830', to_char(sysdate-1,'YYYYMMDD')||'0900', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0900', to_char(sysdate-1,'YYYYMMDD')||'0930', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'0930', to_char(sysdate-1,'YYYYMMDD')||'1000', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1000', to_char(sysdate-1,'YYYYMMDD')||'1030', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1030', to_char(sysdate-1,'YYYYMMDD')||'1100', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1100', to_char(sysdate-1,'YYYYMMDD')||'1130', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1130', to_char(sysdate-1,'YYYYMMDD')||'1200', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1200', to_char(sysdate-1,'YYYYMMDD')||'1230', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1230', to_char(sysdate-1,'YYYYMMDD')||'1300', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1300', to_char(sysdate-1,'YYYYMMDD')||'1330', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1330', to_char(sysdate-1,'YYYYMMDD')||'1400', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1400', to_char(sysdate-1,'YYYYMMDD')||'1430', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1430', to_char(sysdate-1,'YYYYMMDD')||'1500', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1500', to_char(sysdate-1,'YYYYMMDD')||'1530', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1530', to_char(sysdate-1,'YYYYMMDD')||'1600', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1600', to_char(sysdate-1,'YYYYMMDD')||'1630', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1630', to_char(sysdate-1,'YYYYMMDD')||'1700', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1700', to_char(sysdate-1,'YYYYMMDD')||'1730', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1730', to_char(sysdate-1,'YYYYMMDD')||'1800', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1800', to_char(sysdate-1,'YYYYMMDD')||'1830', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1830', to_char(sysdate-1,'YYYYMMDD')||'1900', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1900', to_char(sysdate-1,'YYYYMMDD')||'1930', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'1930', to_char(sysdate-1,'YYYYMMDD')||'2000', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'2000', to_char(sysdate-1,'YYYYMMDD')||'2030', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'2030', to_char(sysdate-1,'YYYYMMDD')||'2100', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'2100', to_char(sysdate-1,'YYYYMMDD')||'2130', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'2130', to_char(sysdate-1,'YYYYMMDD')||'2200', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'2200', to_char(sysdate-1,'YYYYMMDD')||'2230', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'2230', to_char(sysdate-1,'YYYYMMDD')||'2300', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'2300', to_char(sysdate-1,'YYYYMMDD')||'2330', 'D_OUTPUT', '', false);
p_awr_report(to_char(sysdate-1,'YYYYMMDD')||'2330', to_char(sysdate-1,'YYYYMMDD')||'0000', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0000', to_char(sysdate-1,'YYYYMMDD')||'0030', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0030', to_char(sysdate-1,'YYYYMMDD')||'0100', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0100', to_char(sysdate-1,'YYYYMMDD')||'0130', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0130', to_char(sysdate-1,'YYYYMMDD')||'0200', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0200', to_char(sysdate-1,'YYYYMMDD')||'0230', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0230', to_char(sysdate-1,'YYYYMMDD')||'0300', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0300', to_char(sysdate-1,'YYYYMMDD')||'0330', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0330', to_char(sysdate-1,'YYYYMMDD')||'0400', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0400', to_char(sysdate-1,'YYYYMMDD')||'0430', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0430', to_char(sysdate-1,'YYYYMMDD')||'0500', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0500', to_char(sysdate-1,'YYYYMMDD')||'0530', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0530', to_char(sysdate-1,'YYYYMMDD')||'0600', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0600', to_char(sysdate-1,'YYYYMMDD')||'0630', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0630', to_char(sysdate-1,'YYYYMMDD')||'0700', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0700', to_char(sysdate-1,'YYYYMMDD')||'0730', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0730', to_char(sysdate-1,'YYYYMMDD')||'0800', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0800', to_char(sysdate-1,'YYYYMMDD')||'0830', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0830', to_char(sysdate-1,'YYYYMMDD')||'0900', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0900', to_char(sysdate-1,'YYYYMMDD')||'0930', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'0930', to_char(sysdate-1,'YYYYMMDD')||'1000', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1000', to_char(sysdate-1,'YYYYMMDD')||'1030', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1030', to_char(sysdate-1,'YYYYMMDD')||'1100', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1100', to_char(sysdate-1,'YYYYMMDD')||'1130', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1130', to_char(sysdate-1,'YYYYMMDD')||'1200', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1200', to_char(sysdate-1,'YYYYMMDD')||'1230', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1230', to_char(sysdate-1,'YYYYMMDD')||'1300', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1300', to_char(sysdate-1,'YYYYMMDD')||'1330', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1330', to_char(sysdate-1,'YYYYMMDD')||'1400', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1400', to_char(sysdate-1,'YYYYMMDD')||'1430', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1430', to_char(sysdate-1,'YYYYMMDD')||'1500', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1500', to_char(sysdate-1,'YYYYMMDD')||'1530', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1530', to_char(sysdate-1,'YYYYMMDD')||'1600', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1600', to_char(sysdate-1,'YYYYMMDD')||'1630', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1630', to_char(sysdate-1,'YYYYMMDD')||'1700', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1700', to_char(sysdate-1,'YYYYMMDD')||'1730', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1730', to_char(sysdate-1,'YYYYMMDD')||'1800', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1800', to_char(sysdate-1,'YYYYMMDD')||'1830', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1830', to_char(sysdate-1,'YYYYMMDD')||'1900', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1900', to_char(sysdate-1,'YYYYMMDD')||'1930', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'1930', to_char(sysdate-1,'YYYYMMDD')||'2000', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'2000', to_char(sysdate-1,'YYYYMMDD')||'2030', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'2030', to_char(sysdate-1,'YYYYMMDD')||'2100', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'2100', to_char(sysdate-1,'YYYYMMDD')||'2130', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'2130', to_char(sysdate-1,'YYYYMMDD')||'2200', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'2200', to_char(sysdate-1,'YYYYMMDD')||'2230', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'2230', to_char(sysdate-1,'YYYYMMDD')||'2300', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'2300', to_char(sysdate-1,'YYYYMMDD')||'2330', 'D_OUTPUT', '', false);
p_ash_report(to_char(sysdate-1,'YYYYMMDD')||'2330', to_char(sysdate-1,'YYYYMMDD')||'0000', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0000', to_char(sysdate-1,'YYYYMMDD')||'0030', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0030', to_char(sysdate-1,'YYYYMMDD')||'0100', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0100', to_char(sysdate-1,'YYYYMMDD')||'0130', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0130', to_char(sysdate-1,'YYYYMMDD')||'0200', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0200', to_char(sysdate-1,'YYYYMMDD')||'0230', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0230', to_char(sysdate-1,'YYYYMMDD')||'0300', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0300', to_char(sysdate-1,'YYYYMMDD')||'0330', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0330', to_char(sysdate-1,'YYYYMMDD')||'0400', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0400', to_char(sysdate-1,'YYYYMMDD')||'0430', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0430', to_char(sysdate-1,'YYYYMMDD')||'0500', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0500', to_char(sysdate-1,'YYYYMMDD')||'0530', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0530', to_char(sysdate-1,'YYYYMMDD')||'0600', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0600', to_char(sysdate-1,'YYYYMMDD')||'0630', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0630', to_char(sysdate-1,'YYYYMMDD')||'0700', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0700', to_char(sysdate-1,'YYYYMMDD')||'0730', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0730', to_char(sysdate-1,'YYYYMMDD')||'0800', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0800', to_char(sysdate-1,'YYYYMMDD')||'0830', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0830', to_char(sysdate-1,'YYYYMMDD')||'0900', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0900', to_char(sysdate-1,'YYYYMMDD')||'0930', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'0930', to_char(sysdate-1,'YYYYMMDD')||'1000', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1000', to_char(sysdate-1,'YYYYMMDD')||'1030', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1030', to_char(sysdate-1,'YYYYMMDD')||'1100', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1100', to_char(sysdate-1,'YYYYMMDD')||'1130', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1130', to_char(sysdate-1,'YYYYMMDD')||'1200', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1200', to_char(sysdate-1,'YYYYMMDD')||'1230', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1230', to_char(sysdate-1,'YYYYMMDD')||'1300', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1300', to_char(sysdate-1,'YYYYMMDD')||'1330', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1330', to_char(sysdate-1,'YYYYMMDD')||'1400', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1400', to_char(sysdate-1,'YYYYMMDD')||'1430', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1430', to_char(sysdate-1,'YYYYMMDD')||'1500', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1500', to_char(sysdate-1,'YYYYMMDD')||'1530', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1530', to_char(sysdate-1,'YYYYMMDD')||'1600', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1600', to_char(sysdate-1,'YYYYMMDD')||'1630', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1630', to_char(sysdate-1,'YYYYMMDD')||'1700', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1700', to_char(sysdate-1,'YYYYMMDD')||'1730', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1730', to_char(sysdate-1,'YYYYMMDD')||'1800', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1800', to_char(sysdate-1,'YYYYMMDD')||'1830', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1830', to_char(sysdate-1,'YYYYMMDD')||'1900', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1900', to_char(sysdate-1,'YYYYMMDD')||'1930', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'1930', to_char(sysdate-1,'YYYYMMDD')||'2000', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'2000', to_char(sysdate-1,'YYYYMMDD')||'2030', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'2030', to_char(sysdate-1,'YYYYMMDD')||'2100', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'2100', to_char(sysdate-1,'YYYYMMDD')||'2130', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'2130', to_char(sysdate-1,'YYYYMMDD')||'2200', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'2200', to_char(sysdate-1,'YYYYMMDD')||'2230', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'2230', to_char(sysdate-1,'YYYYMMDD')||'2300', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'2300', to_char(sysdate-1,'YYYYMMDD')||'2330', 'D_OUTPUT', '', false);
p_addm_report(to_char(sysdate-1,'YYYYMMDD')||'2330', to_char(sysdate-1,'YYYYMMDD')||'0000', 'D_OUTPUT', '', false);
end;
/
exit;
eof

cd $ORACLE_HOME/scripts/mon/log
find . -name "*rpt_ORCLDB_*$DATE*" -print|xargs tar -cvf $ORACLE_HOME/scripts/report/report_ORCLDB_${DATE}.tar
find . -name "*rpt_ORCLDB_*$DATE*" -print|xargs rm -f
gzip -f $ORACLE_HOME/scripts/report/report_ORCLDB_${DATE}.tar

HOST_IP=xxxxx
USRNM="ftp"
PWD="xxxx"
LOCAL_DIR=$ORACLE_HOME/scripts/report
REMOTE_DIR=/sys_xj/ftp

ftp -inv $HOST_IP<<!
user ${USRNM} ${PWD}
bin
prompt
lcd ${LOCAL_DIR}
cd ${REMOTE_DIR}
mput report_ORCLDB_${DATE}.tar.gz
bye
!
exit

oracle rac自动生成awr的更多相关文章

  1. Oracle 每天自动生成AWR报告

    经验丰富的老员工希望能够每天为数据库生成1个AWR报告,以便于后期分析数据库的性能变化,手动生成太麻烦,查了一下资料,发现可以自动生成,过程如下. 数据库环境:11gR2 RAC(双节点) AWR报告 ...

  2. SHELL脚本学习-自动生成AWR报告

    自动生成AWR报告,每个小时生成一次. #编辑脚本:vim awr_auto.sh #oracle用户下执行 #!/bin/bash # 每个小时执行一次,自动生成AWR报告 source ~/.ba ...

  3. 自动生成AWR报告

    --自动生成AWR报告 -------------------2013/09/23   脚本代码:   #!/bin/bash   AWR_FORMAT=html NUM_DAYS=1   MAX_S ...

  4. oracle中如何生成awr报告

    oracle中如何生成awr报告   1.进入数据库 sqlplus / as sysdba 2.查看用户 show parameter db_name 3.开始压测后执行 exec DBMS_WOR ...

  5. Oracle 函数 “自动生成订单号”

    create or replace function get_request_code return varchar2 AS --函数的作用:自动生成订单号 v_mca_no mcode_apply_ ...

  6. 一个自动生成awr报告的shell脚本

    最近在学习shell编程,搞一点点小工具自动完成awr报告的收集工作,方便系统出现问题时问题排查.脚本内容如下,系统收集每天开始时间6点结束时间20点的awr报告并存储在/u01/shell_t/aw ...

  7. oracle中如何生成awr【性能调优】报告

    1.进入数据库 sqlplus / as sysdba 2.查看用户 show parameter db_name 3.开始压测后执行 exec DBMS_WORKLOAD_REPOSITORY.CR ...

  8. oracle数据库自动生成数据库表结构文档(亲测有效)

    import java.awt.Color; import java.io.FileOutputStream; import java.sql.Connection; import java.sql. ...

  9. 转: Oracle AWR 报告 每天自动生成并发送邮箱

    原贴地址:http://www.cnblogs.com/vigarbuaa/archive/2012/09/05/2671794.html Oracle AWR 介绍http://blog.csdn. ...

随机推荐

  1. PAT (Advanced Level) Practise:1002. A+B for Polynomials

    [题目链接] This time, you are supposed to find A+B where A and B are two polynomials. Input Each input f ...

  2. 十分钟让你的javascript登峰造极

    javascipt被称作前端的灵魂,没法灵活运用它,你的前端就只是一具行死走肉.大多初学者能顺利度过div+css,然后倒在了js怀抱,即时跨过了这一关,也只是会用,其底层原理一概不知.小编这就带大家 ...

  3. java中常见的几种Runtimeexception

    转自http://blog.csdn.net/qq635785620/article/details/7781026 一般面试中java Exception(runtimeException )是必会 ...

  4. IOS开发网络数据---- AFNetworking的使用

    http网络库是集XML解析,Json解析,网络图片下载,plist解析,数据流请求操作,上传,下载,缓存等网络众多功能于一身的强大的类库.最新版本支持session,xctool单元测试.网络获取数 ...

  5. HttpURlconntiuon获取网络数据

    package Network; import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream ...

  6. 如何在Mac OS系统下配置Java服务器开发环境

    1.http://www.oracle.com/technetwork/Java/javase/downloads/index-jsp-138363.html 安装JDK(可通过java -versi ...

  7. 【转载】App.config/Web.config 中特殊字符的处理

    写一个网站,遇到一个问题,发布以后,提示错误,但是即使打开错误提示(在web.config中打开),还是只提示错误,没提示什么地方错误,这让我知道了:是webconfig本身的错误,经过排除,是链接字 ...

  8. windows 下 webstorm 使用SVN

    1.安装了webstorm之后,用了很久都没有配置SVN 现在想配置svn,结果发现一般的svn程序不好用. 经指导,发现需要安装一个专用于webstorm的SVN 2.在file->setti ...

  9. 简谈ashx

    是一般处理程序, 是asp.net web 组件的一种,ashx是其扩展名. 实现IHttpHandler接口,接收并处理http请求.这个接口有一个IsReusable成员,一个待实现的方法Proc ...

  10. Codeforces Round #361 Jul.6th A题 ☺译

    A.迈克和手机 当迈克在沙滩上游泳的时候,他意外的把他的手机扔进了水里.不过你甭担心因为他立马买了个便宜些的代替品,这个代替品是老款九键键盘,这个键盘只有十个等大的数字按键,按以下方式排列: 1 2 ...