oracle 11g&12c(pdb&cdb)系统巡检
--脚本用法
sh performance_check.sh
--脚本生成
vi performance_check.sh --添加如下
Ip=``
sqlplus -S "sys/oracle@pdborclall as sysdba" << EOF
-- |--------------------------------------------------------------------------------------|
-- | Copyright (c) 1991-2013 oracle. All rights reserved. |
-- | PURPOSE : This SQL script provides a detailed report (in HTML format) on |
-- | all database metrics including installed options, storage, |
-- | performance data, and security. |
-- | VERSION : This script was designed for Oracle Database 11g and 12c. |
-- | USAGE : |
-- | sqlplus -s <dba>/<password>@<TNS string> @performance_report_for_oracle.sql |
-- | TESTING : This script has been successfully tested on the following |
-- | platforms: |
-- | Linux : Oracle Database 11.2.0.1.0 12.1.0.1.0 |
-- | Windows server2008 sp1 : Oracle Database 10.2.0.4.0 |
-- | NOTE : As with any code, ensure to test this script in a development |
-- | environment before attempting to run it in production. |
-- +--------------------------------------------------------------------------------------+
prompt Creating database report.
prompt This script must be run as a user with SYSDBA privileges.
prompt This process can take several minutes to complete.
COLUMN version NEW_VALUE _version NOPRINT
SELECT case when substr(t.VERSION,1,2)<=11 then substr(t.VERSION,1,2)||'g' else substr(t.VERSION,1,2)||'c' end
version FROM v\$instance t;
define reportHeader="<center><font size=+3 color=darkgreen><b>Performance Report for Database &_version<i></i>($Ip)</b></font><hr>Copyright (c) 1991-2013 oracle. All rights reserved.<p></center>"
-- +----------------------------------------------------------------------------+
-- | SCRIPT SETTINGS |
-- +----------------------------------------------------------------------------+
set termout off
set echo off
set feedback off
set heading off
set verify off
set wrap on
set trimspool on
set serveroutput on
set escape on
set pagesize 50000
set linesize 175
set long 2000000000
clear buffer computes columns breaks
define FileName=TEST_CHECK
define versionNumber=6.0.0
-- +----------------------------------------------------------------------------+
-- | GATHER DATABASE REPORT INFORMATION |
-- +----------------------------------------------------------------------------+
COLUMN dbname NEW_VALUE _dbname NOPRINT
COLUMN spool_time NEW_VALUE _spool_time NOPRINT
SELECT name dbname FROM v\$database;
SELECT TO_CHAR(SYSDATE,'YYYYMMDD') spool_time FROM dual;
-- +----------------------------------------------------------------------------+
-- | GATHER DATABASE REPORT INFORMATION |
-- +----------------------------------------------------------------------------+
set heading on
set markup html on spool on preformat off entmap on -
head ' -
<title>Database Report</title> -
<style type="text/css"> -
body {font:9pt Arial,Helvetica,sans-serif; color:black; background:White;} -
p {font:9pt Arial,Helvetica,sans-serif; color:black; background:White;} -
table,tr,td {font:9pt Arial,Helvetica,sans-serif; color:Black; background:#C0C0C0; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;} -
th {font:bold 9pt Arial,Helvetica,sans-serif; color:#336699; background:#cccc99; padding:0px 0px 0px 0px;} -
h1 {font:bold 12pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; border-bottom:1px solid #cccc99; margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;} -
h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; margin-top:4pt; margin-bottom:0pt;} -
a {font:9pt Arial,Helvetica,sans-serif; color:#663300; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
a.link {font:9pt Arial,Helvetica,sans-serif; color:#663300; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
a.noLink {font:9pt Arial,Helvetica,sans-serif; color:#663300; text-decoration: none; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
a.noLinkBlue {font:9pt Arial,Helvetica,sans-serif; color:#0000ff; text-decoration: none; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
a.noLinkDarkBlue {font:9pt Arial,Helvetica,sans-serif; color:#000099; text-decoration: none; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
a.noLinkRed {font:9pt Arial,Helvetica,sans-serif; color:#ff0000; text-decoration: none; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
a.noLinkDarkRed {font:9pt Arial,Helvetica,sans-serif; color:#990000; text-decoration: none; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
a.noLinkGreen {font:9pt Arial,Helvetica,sans-serif; color:#00ff00; text-decoration: none; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
a.noLinkDarkGreen {font:9pt Arial,Helvetica,sans-serif; color:#009900; text-decoration: none; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
</style>' -
body 'BGCOLOR="#C0C0C0"' -
table 'WIDTH="90%" BORDER="1"'
spool &FileName._&_version._&_dbname._&_spool_time..html
set markup html on entmap off
-- +----------------------------------------------------------------------------+
-- | - REPORT HEADER - |
-- +----------------------------------------------------------------------------+
prompt <a name=top></a>
prompt &reportHeader
-- +----------------------------------------------------------------------------+
-- | - REPORT INDEX - |
-- +----------------------------------------------------------------------------+
prompt <a name="report_index"></a>
prompt <center><font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>Report Index</b></font><hr align="center" width="300"></center> -
<table width="90%" border="1"> -
<tr><th colspan="4">Application Regulation</th></tr> -
<tr> -
<td nowrap align="center" width="25%"><a class="link" href="#SCHEDULER_JOB">SCHEDULER JOB DETAILS</a></td> -
<td nowrap align="center" width="25%"><a class="link" href="#Parameter_name">Parameter name</a></td> -
<td nowrap align="center" width="25%"><a class="link" href="#Timezone">Timezone of db and session</a></td> -
<td nowrap align="center" width="25%"><a class="link" href="#SCHEDULER_STIME">SCHEDULER JOB STIME</a></td> -
</tr> -
<tr> -
<td nowrap align="center" width="25%"><a class="link" href="#Component_name">Component name</a></td> -
<td nowrap align="center" width="25%"><a class="link" href="#DBA_SCHEDULER_GLOBAL_ATTRIBUTE">DBA SCHEDULER GLOBAL ATTRIBUTE FOR OFF OR ON</a></td> -
<td nowrap align="center" width="25%"><a class="link" href="#"></a></td> -
<td nowrap align="center" width="25%"><a class="link" href="#"></a></td> -
<td nowrap align="center" width="25%"><a class="link" href="#"></a></td> -
</tr> -
</table>
prompt <p>
prompt <center><font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#663300"><b><u>Application regulation</u></b></font></center>
prompt <a name="SCHEDULER_JOB"></a>
prompt <font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>SCHEDULER JOB DETAILS</b></font><hr align="left" width="460">
SELECT T.ENABLED,T.STATE,T.JOB_NAME,T.START_DATE,T.END_DATE,T.LAST_RUN_DURATION,T.NEXT_RUN_DATE FROM DBA_SCHEDULER_JOBS T
WHERE T.OWNER='SSDBSP_001_000_000';
SELECT T.enabled,T.owner,T.program_name,T.program_type,T.program_action FROM DBA_SCHEDULER_PROGRAMS T WHERE T.OWNER='SSDBSP_001_000_000';
SELECT T.owner,T.schedule_name,T.schedule_type,T.repeat_interval FROM DBA_SCHEDULER_SCHEDULES T WHERE T.OWNER='SSDBSP_001_000_000';
SELECT T.owner,T.job_name,T.job_subname,T.ERROR#,T.STATUS,T.REQ_START_DATE,T.ACTUAL_START_DATE,T.RUN_DURATION FROM DBA_SCHEDULER_JOB_RUN_DETAILS T
WHERE T.OWNER='SSDBSP_001_000_000' and rownum<=20 ORDER BY T.ACTUAL_START_DATE DESC;
prompt <center>[<a class="noLink" href="#top">Top</a>]</center><p>
prompt <a name="Parameter_name"></a>
prompt <font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>Parameter name</b></font><hr align="left" width="460">
select count(*) as process_count from v\$process;
select count(*) as session_count from v\$session;
select count(*) num_curs from v\$open_cursor o, v\$session s where o.sid=s.sid;
show parameter process;
show parameter session;
show parameter open_cursors;
prompt <center>[<a class="noLink" href="#top">Top</a>]</center><p>
prompt <a name="Timezone"></a>
prompt <font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>Timezone of db and session</b></font><hr align="left" width="460">
select dbtimezone from dual;
select sessiontimezone from dual;
prompt <center>[<a class="noLink" href="#top">Top</a>]</center><p>
prompt <a name="SCHEDULER_STIME"></a>
prompt <font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>SCHEDULER JOB STIME</b></font><hr align="left" width="460">
select DBMS_SCHEDULER.STIME from dual;
prompt <center>[<a class="noLink" href="#top">Top</a>]</center><p>
prompt <a name="Component_name"></a>
prompt <font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>Component name</b></font><hr align="left" width="460">
SELECT t.comp_id,t.comp_name,t.status,t.schema,t.procedure,t.modified FROM dba_registry t;
prompt <center>[<a class="noLink" href="#top">Top</a>]</center><p>
conn / as sysdba
prompt <a name="DBA_SCHEDULER_GLOBAL_ATTRIBUTE"></a>
prompt <font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>DBA SCHEDULER GLOBAL ATTRIBUTE FOR OFF OR ON</b></font><hr align="left" width="460">
select T.attribute_name, T.value from DBA_SCHEDULER_GLOBAL_ATTRIBUTE T;
prompt <center>[<a class="noLink" href="#top">Top</a>]</center><p>
SPOOL OFF
SET MARKUP HTML OFF
SET TERMOUT ON
prompt
prompt Output written to: &FileName._&_dbname._&_spool_time..html
disconnect
EXIT;
EOF