oracle 巡检脚本(自动化)

简介: vi /scripts/check/xunjian.sql set heading off select '一、数据库的基本情况' from dual; set heading off select '1、数据库版本' from dual; set head...
vi  /scripts/check/xunjian.sql

set heading off
select '一、数据库的基本情况' from dual;

set heading off
select '1、数据库版本' from dual;
set heading on
select * from v$version;

set heading off
select '2、查看数据库基本信息' from dual;
set heading on
set linesize 500
col host_name for a20
select dbid,name,instance_name,instance_name,version,parallel rac,host_name from v$database,v$instance;


set heading off
select '3、实例状态' from dual;
set heading on
select instance_number,instance_name ,status from gv$instance;

set heading off
select '4、数据库运行时间' from dual;
set heading on
select to_char(startup_time,'DD-MON-YYYY HH24:MI:SS') 启动时间,
TRUNC(sysdate - (startup_time))||'天 '||TRUNC(24*((sysdate-startup_time) -TRUNC(sysdate-startup_time)))
||'小时 '||MOD(TRUNC(1440*((SYSDATE-startup_time)-
TRUNC(sysdate-startup_time))),60)
||'分 '||MOD(TRUNC(86400*((SYSDATE-STARTUP_TIME)-
TRUNC(SYSDATE-startup_time))),60)
||'秒' 运行时间
from v$instance;

set heading off
select '5、内存情况' from dual;
set heading on
select * from v$sgainfo;

set heading off
select '6、cpu情况' from dual;
set heading on
col STAT_NAME for a20
col COMMENTS for a50
Select stat_name,value,comments from v$osstat where stat_name in ('NUM_CPUS','IDLE_TIME','BUSY_TIME','USER_TIME','SYS_TIME','IOWAIT_TIME');

set heading off
select '二、检查Oracle对象状态' from  dual;


set heading off
select '1、查看参数文件位置' from dual;
show parameter spfile



set heading off
col NAME for a50
select '2、查看控制文件' from dual;
set heading on
select status,name from v$controlfile;


set heading off
select '3、查看在线日志' from dual;
set heading on
col MEMBER for a50
select group#,status,type,member from v$logfile;


set heading off
select '4、检查日志切换频率' from dual;
set heading on
select sequence#,to_char(first_time,'yyyymmdd_hh24:mi:ss') firsttime,round((first_time-lag(first_time) over(order by first_time))*24*60,2) minutes from v$log_history where first_time > sysdate - 1 order by first_time ,minutes;


set heading off
select '5、查看数据文件' from dual;
set heading on
col NAME  for a50
select name,status from v$datafile;


set heading off
select '6、查看无效的对象' from dual;
set heading on
set linesize 500
select owner,object_name,object_type from dba_objects where status!='VALID' and owner!='SYS' and owner!='SYSTEM';



set heading off
select '7、查看回滚段状态' from dual;
set heading on
select segment_name,status from dba_rollback_segs;


set heading off
select '8、检查是否有禁用约束' from dual;
set heading on
set linesize 1000
SELECT owner, constraint_name, table_name, constraint_type, status
     FROM dba_constraints
    WHERE status ='DISABLE' and constraint_type='P';


set heading off
select '9、检查是否有禁用触发器' from dual;
set heading on
col owner for a10
col taigger_name for a10
col table_name for a30
col table_name for a30
 SELECT owner, trigger_name, table_name, status FROM dba_triggers WHERE status = 'DISABLED';

set heading off
select '10、Oracle Job是否有失败' from dual;
set heading on
select job,what,last_date,next_date,failures,broken from dba_jobs Where schema_user='CAIKE';

set heading off
select '11、检查失效的索引' from dual;
set heading on
select index_name,table_name,tablespace_name,status From dba_indexes Where owner='CTAIS2' And status<>'VALID';


set heading off
select '三、检查Oracle相关资源的使用情况' from dual;


set heading off
select '1、查看表空间的使用情况' from dual;
set heading on
set linesize 1000
SELECT UPPER(F.TABLESPACE_NAME) "tablespace_name",    
D.TOT_GROOTTE_MB "tablesapce_size(M)",    
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "used_tablespace_size(M)",    
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') "used%",    
F.TOTAL_BYTES "free_size(M)",    
F.MAX_BYTES "max_byte(M)"  
FROM (SELECT TABLESPACE_NAME,    
ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,    
ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES    
FROM SYS.DBA_FREE_SPACE    
GROUP BY TABLESPACE_NAME) F,    
(SELECT DD.TABLESPACE_NAME,    
ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB    
FROM SYS.DBA_DATA_FILES DD    
GROUP BY DD.TABLESPACE_NAME) D    
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME    
ORDER BY 4 DESC;


set heading off
select '2、查看临时表空间使用情况' from dual;
set heading on
select tablespace_name , sum(bytes)/1024/1024 from dba_temp_files group by tablespace_name;

set heading off
select '3、查看临时段使用的情况' from dual;
set heading on
COL username FORMAT a10;
COL segtype FORMAT a10;
SELECT username, segtype, extents "Extents Allocated"
,blocks "Blocks Allocated"
FROM v$tempseg_usage;


set heading off
select '4、查看所有数据文件i/o情况' from dual;
set heading on
SELECT ts.name AS ts, fs.phyrds "Reads", fs.phywrts "Writes"
,fs.phyblkrd AS br, fs.phyblkwrt AS bw
,fs.readtim "RTime", fs.writetim "WTime"
FROM v$tablespace ts, v$datafile df, v$filestat fs
WHERE ts.ts# = df.ts# AND df.file# = fs.file#
UNION
SELECT ts.name AS ts, ts.phyrds "Reads", ts.phywrts "Writes"
,ts.phyblkrd AS br, ts.phyblkwrt AS bw
,ts.readtim "RTime", ts.writetim "WTime"
FROM v$tablespace ts, v$tempfile tf, v$tempstat ts
WHERE ts.ts# = tf.ts# AND tf.file# = ts.file# ORDER BY 1;


set heading off
select '5、查看top 10 热segment' from dual;
set heading on
col objct_name for a30
col OWNER  for a20
select * from
(select
 ob.owner, ob.object_name, sum(b.tch) Touchs
from x$bh b , dba_objects ob
where b.obj = ob.data_object_id
 and b.ts# > 0
group by ob.owner, ob.object_name
order by sum(tch) desc)
where rownum <=10;

set heading off
select '6、查看物理读最多的object' from dual;
set heading on
select * from (select owner,object_name,value from  v$segment_statistics where statistic_name='physical reads' order by value desc) where rownum<=10;


set heading off
select '7、查看热点数据文件(从单块读取时间判断)' from dual;
set heading on
SELECT t.file_name,
          t.tablespace_name,
          round(s.singleblkrdtim / s.singleblkrds, 2) AS CS,  
          s.READTIM,
          s.WRITETIM
     FROM v$filestat s, dba_data_files t
    WHERE s.file# = t.file_id and rownum<=10 order by cs desc;


set heading off
select '8、检查Oracle初始化文件中相关参数值' from dual;
set heading on
select resource_name,max_utilization,initial_allocation,
    limit_value from v$resource_limit;
set heading off
select '注:若LIMIT_VALU - MAX_UTILIZATION<=5,则表明与RESOURCE_NAME相关的Oracle初始化参数需要调整。可以通过参数文件调整。' from dual;



set heading off
select '9、检查数据库连接情况' from dual;
set heading on
select sid,serial#,username,program,machine,status from v$session;
set heading off
select "(注:杀掉会话的语句alter system kill session 'SID,SERIAL#')" from dual;


set heading off
select '10、查看热点数据文件' from dual;
set heading on
SELECT t.file_name,
          t.tablespace_name,
          round(s.singleblkrdtim / s.singleblkrds, 2) AS CS,  
          s.READTIM,
          s.WRITETIM
     FROM v$filestat s, dba_data_files t
    WHERE s.file# = t.file_id and rownum<=10 order by cs desc;
   
   
 
set heading off
select ' 11、检查一些扩展异常的对象 ' from dual;
set heading on

select Segment_Name, Segment_Type, TableSpace_Name,
(Extents/Max_extents)*100 Percent
From sys.DBA_Segments
Where Max_Extents != 0 and (Extents/Max_extents)*100>=95
order By Percent;


set heading off
select ' 12、检查system表空间内的内容 ' from dual;
set heading on
select distinct(owner) from dba_tables
where tablespace_name='SYSTEM' and
owner!='SYS' and owner!='SYSTEM'
union
select distinct(owner) from dba_indexes
where tablespace_name='SYSTEM' and
owner!='SYS' and owner!='SYSTEM';



set heading off
select ' 13、检查对象的下一扩展与表空间的最大扩展值 ' from dual;
set heading on
select a.table_name, a.next_extent, a.tablespace_name
from all_tables a,
(select tablespace_name, max(bytes) as big_chunk
from dba_free_space
group by tablespace_name ) f
where f.tablespace_name = a.tablespace_name
and a.next_extent > f.big_chunk
union
select a.index_name, a.next_extent, a.tablespace_name
from all_indexes a,
(select tablespace_name, max(bytes) as big_chunk
from dba_free_space
group by tablespace_name ) f
where f.tablespace_name = a.tablespace_name
and a.next_extent > f.big_chunk;

set heading off
select '四、内存的具体查看' from dual;

 set heading off
select '  1、查看内存占用各个池子大小' from dual;
set heading on
COL name FORMAT a32;
SELECT pool, name, bytes FROM v$sgastat
WHERE pool IS NULL
OR pool != 'shared pool' OR (pool = 'shared pool'
AND (name IN('dictionary cache','enqueue','library
cache','parameters',
'processes','sessions','free memory')))
ORDER BY pool DESC NULLS FIRST, name;


set heading off
select '  2、检查shered pool  free  space ' from dual;
set heading on
SELECT * FROM V$SGASTAT
WHERE NAME = 'free memory'
  AND POOL = 'shared pool';


set heading off
select '  3、检查shared pool中library cach ' from dual;
set heading on
select namespace,pinhitratio from v$librarycache;


set heading off
select '  4、检查整体命中率(library cache)' from dual;
set heading on
 select sum(pins) "hits",
            sum(reloads) "misses",
            sum(pins)/(sum(pins)+sum(reloads)) "Hits Ratio"
    from v$librarycache;

set heading off
select '  5、library cache中详细比率信息' from dual;
set heading on
SELECT 'Library Lock Requests' "Ratio"                                                            
, ROUND(AVG(gethitratio) * 100, 2)                          
||'%' "Percentage" FROM V$LIBRARYCACHE                      
UNION                                                        
SELECT 'Library Pin Requests' "Ratio", ROUND(AVG(pinhitratio)
* 100, 2)                                                    
||'%' "Percentage" FROM V$LIBRARYCACHE                      
UNION                                                        
SELECT 'Library I/O Reloads' "Ratio"                        
, ROUND((SUM(reloads) / SUM(pins)) * 100, 2)                
||'%' "Percentage" FROM V$LIBRARYCACHE                      
UNION                                                        
SELECT 'Library Reparses' "Ratio"                            
, ROUND((SUM(reloads) / SUM(pins)) * 100, 2)                
||'%' "Percentage" FROM V$LIBRARYCACHE;




set heading off
select '  6、检查数据字典的命中率' from dual;
set heading on
SELECT (SUM(GETS - GETMISSES - FIXED)) / SUM(GETS) "ROW CACHE" FROM V$ROWCACHE;
set heading off
select '注:row cache的命中率至少小于90%' from dual;




set heading off
select '  7、每个子shared pool由 单独的shared pool latch保护 查看 他们的命中率 ' from dual;
set heading on
col name format a15
select addr,name,gets,misses,1-misses/gets from v$latch_children where name='shared pool';

set heading off
select ' 8、查看shared pool建议' from dual;
set heading on
column c1     heading 'Pool |Size(M)'
  column c2     heading 'Size|Factor'
  column c3     heading 'Est|LC(M)  '
  column c4     heading 'Est LC|Mem. Obj.'
  column c5     heading 'Est|Time|Saved|(sec)'
  column c6     heading 'Est|Parse|Saved|Factor'
 column c7     heading 'Est|Object Hits'   format 999,999,999
  SELECT shared_pool_size_for_estimate c1,shared_pool_size_factor c2,
          estd_lc_size c3,estd_lc_memory_objects c4,estd_lc_time_saved c5,
           estd_lc_time_saved_factor c6,to_char(estd_lc_memory_object_hits,99999999999) c7 FROM V$SHARED_POOL_ADVICE;


set heading off
select ' 9、查看shared pool中 各种类型的chunk的大小数量' from dual;
set heading on
SELECT KSMCHCLS CLASS, COUNT(KSMCHCLS) NUM, SUM(KSMCHSIZ) SIZ,
    To_char( ((SUM(KSMCHSIZ)/COUNT(KSMCHCLS)/1024)),'999,999.00')||'k' "AVG SIzE"
     FROM X$KSMSP GROUP BY KSMCHCLS;

set heading off
select ' 10、查看使用shard_pool保留池情况' from dual;
set heading on
SELECT request_misses, request_failures, free_space
FROM v$shared_pool_reserved;



set heading off
select '11、 pga 建议' from dual;
set heading on
SELECT (SELECT ROUND(value/1024/1024,0) FROM v$parameter
WHERE name = 'pga_aggregate_target') "Current Mb"
, ROUND(pga_target_for_estimate/1024/1024,0) "Projected Mb"
, ROUND(estd_pga_cache_hit_percentage) "%"
FROM v$pga_target_advice
ORDER BY 2;


set heading off
select ' 12、查看buffer cache 命中率' from dual;
set heading on

select 1-(sum(decode(name, 'physical reads', value, 0))/
    (sum(decode(name, 'db block gets', value, 0))+
     (sum(decode(name, 'consistent gets', value, 0))))) "Buffer Hit Ratio"
    from v$sysstat;


set heading off
select ' 13、查看buffer cache设置大小建议' from dual;
set heading on
select size_for_estimate, estd_physical_read_factor, to_char(estd_physical_reads,99999999999999999999999) as"estd_physical_reads" from v$db_cache_advice  where name = 'DEFAULT';

set heading off
select '14、查看buffer cache中defalut pool 命中率' from dual;
set heading on
select name,1-(physical_reads)/(consistent_gets+db_block_gets)
     from v$buffer_pool_statistics;
     set heading off
select '注:default池命中率至少要大于90%' from dual;

set heading off
select '15、检查lgwr i/o性能' from dual;
set heading on
select total_waits,time_waited,average_wait,time_waited/total_waits as avg from v$system_event where event = 'log file parallel write';


set heading off
select '16、检查与redo相关性能指标' from dual;
set heading on
set linesize 500
select name,value from v$sysstat where name like '%redo%';

set heading off
select ' 17、查询redo block size' from dual;
set heading on
select max(lebsz) from x$kccle;


 set heading off
select '18、  计算出每个事务平均处理多少个redo block' from dual;
set heading on
select a.redoblocks/b.trancount from (select value redoblocks from v$sysstat where name='redo blocks written') a ,(select value trancount from v$sysstat where name='user commits') b;


 set heading off
select ' 19、 检查undo rollback segment 使用情况' from dual;
set heading on
col name for a60
select name ,rssize,extents,latch,xacts,writes,gets,waits from v$rollstat a,v$rollname b where a.usn=b.usn order by waits desc;




 set heading off
select '  20、计算每秒钟产生的undoblk数量' from dual;
set heading on
select sum(undoblks)/sum((end_time-begin_time)*24*60*60) from v$undostat;


 set heading off
select ' 21、查询undo具体信息' from dual;
set heading on

COL undob FORMAT 99990;
COL trans FORMAT 99990;
COL snapshot2old FORMAT 9999999990;
SELECT undoblks "UndoB", txncount "Trans"
,maxquerylen "LongestQuery", maxconcurrency "MaxConcurrency"
,ssolderrcnt "Snapshot2Old", nospaceerrcnt "FreeSpaceWait"
FROM v$undostat;

 set heading off
select ' 22、查询rollback 段详细信息(收缩次数,扩展次数,平均活动事务等)' from dual;
set heading on

COL RBS FORMAT a50;

SELECT n.name "RBS", s.extends "Extends", s.shrinks
"Shrinks"
,s.wraps "Wraps", s.aveshrink "AveShrink"
,s.aveactive "AveActive"
FROM v$rollname n JOIN v$rollstat s USING(usn)
WHERE n.name != 'SYSTEM';


 set heading off
select ' 23、查询当前rollback segment使用情况' from dual;
set heading on

COL RBS FORMAT a50;
SELECT n.name "RBS", s.status, s.waits, s.gets, to_char(s.writes,'9999999999999')
,s.xacts "Active Trans"
FROM v$rollname n JOIN v$rollstat s USING(usn)
WHERE n.name != 'SYSTEM';





set heading off
select '24、查询使用rollback segment时等待比率' from dual;
set heading on
SELECT ROUND(SUM(waits/gets)*100,2)||'%' "Contention" FROM
v$rollstat;


set heading off
select '25、查询使用rollback segment时等待比率及其平局活动事务数' from dual;
set heading on
COL contention FORMAT 9999999990;
SELECT AVG(xacts) "Trans per RBS"
,ROUND(SUM(waits/gets)*100,2)||'%' "Contention"
FROM v$rollstat;

set heading off
select '五、检查Oracle数据库性能' from dual;




set heading off
select '1、检查数据库的等待事件' from dual;
set heading on
set pages 80
set lines 120
col event for a40
select sid,event,p1,p2,p3,WAIT_TIME,SECONDS_IN_WAIT from v$session_wait where event not like 'SQL%' and event not like 'rdbms%';


set heading off
select '2、查看与redo相关等待事件' from dual;
set heading on
col event format a40
   select event,total_waits,total_timeouts,average_wait from v$system_event where upper(event) like'%REDO%';

set heading off
select '3、查看session redo event' from dual;
set heading on
select event,total_waits,total_timeouts,average_wait from v$session_event where upper(event) like'%REDO%';

set heading off
select '4、Disk Read最高的SQL语句的获取' from dual;
set heading on
SELECT SQL_TEXT FROM (SELECT * FROM V$SQLAREA ORDER BY DISK_READS) WHERE ROWNUM<=5  order  by SQL_TEXT desc


set heading off
select '5、查找前十条性能差的sql' from dual;
set heading on
SELECT * FROM (SELECT PARSING_USER_ID
EXECUTIONS,SORTS,COMMAND_TYPE,DISK_READS,
SQL_TEXT FROM V$SQLAREA ORDER BY DISK_READS DESC)
WHERE ROWNUM<10 ;


set heading off
select '6、等待时间最多的5个系统等待事件的获取' from dual;
set heading on
SELECT * FROM (SELECT * FROM V$SYSTEM_EVENT WHERE EVENT NOT LIKE 'SQL%' ORDER BY TOTAL_WAITS DESC) WHERE ROWNUM<=5;


set heading off
select '7、检查运行很久的SQL' from dual;
set heading on
COLUMN USERNAME FORMAT A12
COLUMN OPNAME FORMAT A16
COLUMN PROGRESS FORMAT A8
SELECT USERNAME,SID,OPNAME,ROUND(SOFAR*100 / TOTALWORK,0) || '%' AS PROGRESS,TIME_REMAINING,SQL_TEXT FROM V$SESSION_LONGOPS , V$SQL WHERE TIME_REMAINING <> 0 AND SQL_ADDRESS=ADDRESS AND SQL_HASH_VALUE = HASH_VALUE;





set heading off
select '9、检查碎片程度高的表' from dual;
set heading on
SELECT segment_name table_name,COUNT(*) extents FROM dba_segments WHERE owner NOT IN
('SYS', 'SYSTEM') GROUP BY segment_name HAVING COUNT(*)=(SELECT MAX(COUNT(*))
FROM dba_segments GROUP BY segment_name);



set heading off
select '10、检查死锁及处理' from dual;
set heading on

col sid for 999999
col username for a10
col schemaname for a10
col osuser for a16
col machine for a16
col terminal for a20
col owner for a10
col object_name for a30
col object_type for a10
select sid,serial#,username,SCHEMANAME,osuser,MACHINE,
terminal,PROGRAM,owner,object_name,object_type,o.object_id
from dba_objects o,v$locked_object l,v$session s
where o.object_id=l.object_id and s.sid=l.session_id;



set heading off
select '11、查看数据库中行chain' from dual;
set heading on
SELECT 'Chained Rows ' "Ratio"
, ROUND(
(SELECT SUM(value) FROM V$SYSSTAT
 WHERE name = 'table fetch continued row')
/ (SELECT SUM(value) FROM V$SYSSTAT
   WHERE name IN ('table scan rows gotten', 'table fetch by
rowid'))
* 100, 3)||'%' "Percentage"
FROM DUAL;



set heading off
select '12、查询解析比率' from dual;
set heading on

SELECT 'Soft Parses ' "Ratio"
, ROUND(
((SELECT SUM(value) FROM V$SYSSTAT WHERE name = 'parse count (total)')
- (SELECT SUM(value) FROM V$SYSSTAT WHERE name = 'parse count (hard)'))
/ (SELECT SUM(value) FROM V$SYSSTAT WHERE name = 'execute count')
* 100, 2)||'%' "Percentage"
FROM DUAL
UNION
SELECT 'Hard Parses ' "Ratio"
, ROUND((SELECT SUM(value) FROM V$SYSSTAT WHERE name = 'parse count (hard)')
/ (SELECT SUM(value) FROM V$SYSSTAT WHERE name = 'execute count') * 100, 2)||'%' "Percentage"
FROM DUAL
UNION
SELECT 'Parse Failures ' "Ratio"
, ROUND((SELECT SUM(value) FROM V$SYSSTAT
 WHERE name = 'parse count (failures)')
/ (SELECT SUM(value) FROM V$SYSSTAT WHERE name = 'parse count (total)')* 100, 5)||'%' "Percentage"   FROM DUAL;



set heading off
select '13、查看与latch有关的event信息' from dual;
set heading on
COL event FORMAT a20;
COL waits FORMAT 9999990;
COL timeouts FORMAT 99999990;
COL average FORMAT 99999990;
SELECT event "Event", time_waited "Total Time", total_waits
"Waits"
,average_wait "Average", total_timeouts "Timeouts"
FROM V$SYSTEM_EVENT
WHERE event = 'latch free'
ORDER BY EVENT;




set heading off
select '14、查看大表小表扫描对应的值' from dual;
set heading on

SELECT value, name FROM V$SYSSTAT WHERE name IN
('table fetch by rowid', 'table scans (short tables)'
, 'table scans (long tables)');

SELECT 'Short to Long Full Table Scans' "Ratio"
, ROUND(
(SELECT SUM(value) FROM V$SYSSTAT
WHERE name = 'table scans (short tables)')
/ (SELECT SUM(value) FROM V$SYSSTAT WHERE name IN
('table scans (short tables)', 'table scans (long tables)'))
* 100, 2)||'%' "Percentage"
FROM DUAL
UNION
SELECT 'Short Table Scans ' "Ratio"
, ROUND(
(SELECT SUM(value) FROM V$SYSSTAT
WHERE name = 'table scans (short tables)')
/ (SELECT SUM(value) FROM V$SYSSTAT WHERE name IN
('table scans (short tables)', 'table scans (long tables)', 'table fetch by rowid'))
* 100, 2)||'%' "Percentage"
FROM DUAL
UNION
SELECT 'Long Table Scans ' "Ratio"
, ROUND(
(SELECT SUM(value) FROM V$SYSSTAT
WHERE name = 'table scans (long tables)')
/ (SELECT SUM(value) FROM V$SYSSTAT WHERE name
IN ('table scans (short tables)', 'table scans (long tables)', 'table fetch by rowid'))
* 100, 2)||'%' "Percentage"
FROM DUAL
UNION
SELECT 'Table by Index ' "Ratio"
, ROUND(
(SELECT SUM(value) FROM V$SYSSTAT WHERE name = 'table fetch by rowid')
/ (SELECT SUM(value) FROM V$SYSSTAT WHERE name
IN ('table scans (short tables)', 'table scans (long tables)'
, 'table fetch by rowid'))
* 100, 2)||'%' "Percentage"
FROM DUAL
UNION
SELECT 'Efficient Table Access ' "Ratio"
, ROUND(
(SELECT SUM(value) FROM V$SYSSTAT WHERE name
IN ('table scans (short tables)','table fetch by rowid'))
/ (SELECT SUM(value) FROM V$SYSSTAT WHERE name
IN ('table scans (short tables)', 'table scans (long tables)'
, 'table fetch by rowid'))
* 100, 2)||'%' "Percentage"
FROM DUAL;





set heading off
select '15、index使用比率' from dual;
set heading on

col name for a30
SELECT to_char(value,'999999999999999999999'), name FROM V$SYSSTAT WHERE name IN
('table fetch by rowid', 'table scans (short tables)'
, 'table scans (long tables)')
OR name LIKE 'index fast full%' OR name = 'index fetch by
key';
       
SELECT 'Index to Table Ratio ' "Ratio" , ROUND(                  
(SELECT SUM(value) FROM V$SYSSTAT                          
WHERE name LIKE 'index fast full%'                        
OR name = 'index fetch by key'                            
OR name = 'table fetch by rowid')                          
/ (SELECT SUM(value) FROM V$SYSSTAT WHERE name IN          
('table scans (short tables)', 'table scans (long tables)')
),0)||':1' "Result"                                        
FROM DUAL;



set heading off
select '16、等待class' from dual;
set heading on
col wait_class for a30                                  
SELECT wait_class, COUNT(wait_class) FROM v$system_event
GROUP BY wait_class ORDER BY 1;


vi xunjian.sh

sqlplus / as sysdba <<eof
spool /scripts/check/xunjian.doc
@/scripts/check/xunjian.sql
spool off
EOF













</eof
相关文章
|
27天前
|
数据采集 监控 数据挖掘
Python自动化脚本:高效办公新助手###
本文将带你走进Python自动化脚本的奇妙世界,探索其在提升办公效率中的强大潜力。随着信息技术的飞速发展,重复性工作逐渐被自动化工具取代。Python作为一门简洁而强大的编程语言,凭借其丰富的库支持和易学易用的特点,成为编写自动化脚本的首选。无论是数据处理、文件管理还是网页爬虫,Python都能游刃有余地完成任务,极大地减轻了人工操作的负担。接下来,让我们一起领略Python自动化脚本的魅力,开启高效办公的新篇章。 ###
|
20天前
|
Android开发 开发者 Python
通过标签清理微信好友:Python自动化脚本解析
微信已成为日常生活中的重要社交工具,但随着使用时间增长,好友列表可能变得臃肿。本文介绍了一个基于 Python 的自动化脚本,利用 `uiautomator2` 库,通过模拟用户操作实现根据标签批量清理微信好友的功能。脚本包括环境准备、类定义、方法实现等部分,详细解析了如何通过标签筛选并删除好友,适合需要批量管理微信好友的用户。
26 7
|
18天前
|
运维 Kubernetes Devops
自动化运维:从脚本到工具的演进之旅
在数字化浪潮中,自动化运维成为提升效率、保障系统稳定的关键。本文将探索自动化运维的发展脉络,从基础的Shell脚本编写到复杂的自动化工具应用,揭示这一技术变革如何重塑IT运维领域。我们将通过实际案例,展示自动化运维在简化工作流程、提高响应速度和降低人为错误中的重要作用。无论你是初学者还是资深专家,这篇文章都将为你提供宝贵的洞见和实用的技巧。
|
26天前
|
SQL 测试技术 API
如何编写API接口的自动化测试脚本
本文详细介绍了编写API自动化测试脚本的方法和最佳实践,涵盖确定测试需求、选择测试框架、编写测试脚本(如使用Postman和Python Requests库)、参数化和数据驱动测试、断言和验证、集成CI/CD、生成测试报告及维护更新等内容,旨在帮助开发者构建高效可靠的API测试体系。
|
23天前
|
运维 Devops
自动化运维:从脚本到DevOps的进化之旅
在数字化时代,自动化运维不仅是提高生产效率的关键,更是企业竞争力的象征。本文将带领读者穿越自动化运维的发展历程,从最初的脚本编写到现代DevOps文化的形成,揭示这一演变如何重塑IT行业的工作模式。通过具体案例,我们将展示自动化工具和实践如何简化复杂任务,优化流程,并促进团队协作。你将发现,自动化运维不仅关乎技术的进步,更体现了人、流程和技术三者之间协同增效的深层逻辑。
|
24天前
|
监控 数据挖掘 数据安全/隐私保护
Python脚本:自动化下载视频的日志记录
Python脚本:自动化下载视频的日志记录
|
28天前
|
机器学习/深度学习 人工智能 运维
自动化运维之路:从脚本到工具的演进
在IT运维领域,效率和准确性是衡量工作成效的关键指标。随着技术的发展,自动化运维逐渐成为提升这两个指标的重要手段。本文将带领读者了解自动化运维的演变历程,从最初的简单脚本编写到现今复杂的自动化工具应用,展示如何通过技术提升运维效率。文章不仅介绍理论和实践案例,还提供了代码示例,帮助读者理解自动化运维的实际应用场景。
|
1月前
|
运维 监控 网络安全
自动化运维的崛起:如何利用Python脚本简化日常任务
【10月更文挑战第43天】在数字化时代的浪潮中,运维工作已从繁琐的手工操作转变为高效的自动化流程。本文将引导您了解如何运用Python编写脚本,以实现日常运维任务的自动化,从而提升工作效率和准确性。我们将通过一个实际案例,展示如何使用Python来自动部署应用、监控服务器状态并生成报告。文章不仅适合运维新手入门,也能为有经验的运维工程师提供新的视角和灵感。
|
1月前
|
存储 Python
Python自动化脚本编写指南
【10月更文挑战第38天】本文旨在为初学者提供一条清晰的路径,通过Python实现日常任务的自动化。我们将从基础语法讲起,逐步引导读者理解如何将代码块组合成有效脚本,并探讨常见错误及调试技巧。文章不仅涉及理论知识,还包括实际案例分析,帮助读者快速入门并提升编程能力。
66 2
|
1月前
|
运维 监控 Python
自动化运维:使用Python脚本简化日常任务
【10月更文挑战第36天】在数字化时代,运维工作的效率和准确性成为企业竞争力的关键。本文将介绍如何通过编写Python脚本来自动化日常的运维任务,不仅提高工作效率,还能降低人为错误的风险。从基础的文件操作到进阶的网络管理,我们将一步步展示Python在自动化运维中的应用,并分享实用的代码示例,帮助读者快速掌握自动化运维的核心技能。
82 3

推荐镜像

更多
下一篇
DataWorks