• 灵活好用的sql monitoring 脚本 part6


    71.Script: jobs.sql

    -- Description  : Displays information about all scheduled jobs.

    1. [oracle@MaxwellDBA monitoring]$ cat jobs.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/jobs.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information about all scheduled jobs.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @jobs
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 1000 PAGESIZE 1000
    11. COLUMN log_user FORMAT A15
    12. COLUMN priv_user FORMAT A15
    13. COLUMN schema_user FORMAT A15
    14. COLUMN interval FORMAT A40
    15. COLUMN what FORMAT A50
    16. COLUMN nls_env FORMAT A50
    17. COLUMN misc_env FORMAT A50
    18. SELECT a.job,
    19. a.log_user,
    20. a.priv_user,
    21. a.schema_user,
    22. To_Char(a.last_date,'DD-MON-YYYY HH24:MI:SS') AS last_date,
    23. --To_Char(a.this_date,'DD-MON-YYYY HH24:MI:SS') AS this_date,
    24. To_Char(a.next_date,'DD-MON-YYYY HH24:MI:SS') AS next_date,
    25. a.broken,
    26. a.interval,
    27. a.failures,
    28. a.what,
    29. a.total_time,
    30. a.nls_env,
    31. a.misc_env
    32. FROM dba_jobs a;
    33. SET LINESIZE 80 PAGESIZE 14
    34. [oracle@MaxwellDBA monitoring]$

    72.Script: jobs_running.sql

    -- Description  : Displays information about all jobs currently running.

    1. [oracle@MaxwellDBA monitoring]$ cat jobs_running.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/jobs_running.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information about all jobs currently running.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @jobs_running
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 500
    11. SET PAGESIZE 1000
    12. SET VERIFY OFF
    13. SELECT a.job "Job",
    14. a.sid,
    15. a.failures "Failures",
    16. Substr(To_Char(a.last_date,'DD-Mon-YYYY HH24:MI:SS'),1,20) "Last Date",
    17. Substr(To_Char(a.this_date,'DD-Mon-YYYY HH24:MI:SS'),1,20) "This Date"
    18. FROM dba_jobs_running a;
    19. SET PAGESIZE 14
    20. SET VERIFY ON
    21. [oracle@MaxwellDBA monitoring]$

    73.Script: jobs_lob_segments.sql

    -- Description  : Displays size of large LOB segments.

    1. [oracle@MaxwellDBA monitoring]$ cat large_lob_segments.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/large_lob_segments.sql
    4. -- Author : Maxwell
    5. -- Description : Displays size of large LOB segments.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @large_lob_segments (rows)
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 500 VERIFY OFF
    11. COLUMN owner FORMAT A30
    12. COLUMN table_name FORMAT A30
    13. COLUMN column_name FORMAT A30
    14. COLUMN segment_name FORMAT A30
    15. COLUMN tablespace_name FORMAT A30
    16. COLUMN size_mb FORMAT 99999999.00
    17. SELECT *
    18. FROM (SELECT l.owner,
    19. l.table_name,
    20. l.column_name,
    21. l.segment_name,
    22. l.tablespace_name,
    23. ROUND(s.bytes/1024/1024,2) size_mb
    24. FROM dba_lobs l
    25. JOIN dba_segments s ON s.owner = l.owner AND s.segment_name = l.segment_name
    26. ORDER BY 6 DESC)
    27. WHERE ROWNUM <= &1;
    28. SET VERIFY ON
    29. [oracle@MaxwellDBA monitoring]$

    74.Script: large_segements.sql

    -- Description  : Displays size of large segments.

    1. [oracle@MaxwellDBA monitoring]$ cat large_segements.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/large_segments.sql
    4. -- Author : Maxwell
    5. -- Description : Displays size of large segments.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @large_segments (rows)
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 500 VERIFY OFF
    11. COLUMN owner FORMAT A30
    12. COLUMN segment_name FORMAT A30
    13. COLUMN tablespace_name FORMAT A30
    14. COLUMN size_mb FORMAT 99999999.00
    15. SELECT *
    16. FROM (SELECT owner,
    17. segment_name,
    18. segment_type,
    19. tablespace_name,
    20. ROUND(bytes/1024/1024,2) size_mb
    21. FROM dba_segments
    22. ORDER BY 5 DESC)
    23. WHERE ROWNUM <= &1;
    24. SET VERIFY ON
    25. [oracle@MaxwellDBA monitoring]$

    75.Script: latch_hit_ratios.sql

    -- Description  : Displays current latch hit ratios.

    1. [oracle@MaxwellDBA monitoring]$ cat latch_hit_ratios.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/latch_hit_ratios.sql
    4. -- Author : Maxwell
    5. -- Description : Displays current latch hit ratios.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @latch_hit_ratios
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 200
    11. COLUMN latch_hit_ratio FORMAT 990.00
    12. SELECT l.name,
    13. l.gets,
    14. l.misses,
    15. ((1 - (l.misses / l.gets)) * 100) AS latch_hit_ratio
    16. FROM v$latch l
    17. WHERE l.gets != 0
    18. UNION
    19. SELECT l.name,
    20. l.gets,
    21. l.misses,
    22. 100 AS latch_hit_ratio
    23. FROM v$latch l
    24. WHERE l.gets = 0
    25. ORDER BY 4 DESC;
    26. [oracle@MaxwellDBA monitoring]$

    76.Script: latch_holders.sql

    -- Description  : Displays information about all current latch holders.

    1. [oracle@MaxwellDBA monitoring]$ cat latch_holder.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/latch_holders.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information about all current latch holders.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @latch_holders
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 200
    11. SELECT l.name "Latch Name",
    12. lh.pid "PID",
    13. lh.sid "SID",
    14. l.gets "Gets (Wait)",
    15. l.misses "Misses (Wait)",
    16. l.sleeps "Sleeps (Wait)",
    17. l.immediate_gets "Gets (No Wait)",
    18. l.immediate_misses "Misses (Wait)"
    19. FROM v$latch l,
    20. v$latchholder lh
    21. WHERE l.addr = lh.laddr
    22. ORDER BY l.name;
    23. [oracle@MaxwellDBA monitoring]$

    77.Script: latches.sql

    -- Description  : Displays information about all current latches.

    1. [oracle@MaxwellDBA monitoring]$ cat latches.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/latches.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information about all current latches.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @latches
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 200
    11. SELECT l.latch#,
    12. l.name,
    13. l.gets,
    14. l.misses,
    15. l.sleeps,
    16. l.immediate_gets,
    17. l.immediate_misses,
    18. l.spin_gets
    19. FROM v$latch l
    20. ORDER BY l.name;
    21. [oracle@MaxwellDBA monitoring]$

     

    78.Script: library_cache.sql

    -- Description  : Displays library cache statistics.

    1. [oracle@MaxwellDBA monitoring]$ cat library_cache.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/library_cache.sql
    4. -- Author : Maxwell
    5. -- Description : Displays library cache statistics.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @library_cache
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 500
    11. SET PAGESIZE 1000
    12. SET VERIFY OFF
    13. SELECT a.namespace "Name Space",
    14. a.gets "Get Requests",
    15. a.gethits "Get Hits",
    16. Round(a.gethitratio,2) "Get Ratio",
    17. a.pins "Pin Requests",
    18. a.pinhits "Pin Hits",
    19. Round(a.pinhitratio,2) "Pin Ratio",
    20. a.reloads "Reloads",
    21. a.invalidations "Invalidations"
    22. FROM v$librarycache a
    23. ORDER BY 1;
    24. SET PAGESIZE 14
    25. SET VERIFY ON
    26. [oracle@MaxwellDBA monitoring]$

    79.Script: license.sql

    -- Description  : Displays session usage for licensing purposes.

    1. [oracle@MaxwellDBA monitoring]$ cat license.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/license.sql
    4. -- Author : Maxwell
    5. -- Description : Displays session usage for licensing purposes.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @license
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SELECT *
    11. FROM v$license;
    12. [oracle@MaxwellDBA monitoring]$

     

    80.Script: locked_objects.sql

    -- Description  : Lists all locked objects.

    1. [oracle@MaxwellDBA monitoring]$ cat locked_objects.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/locked_objects.sql
    4. -- Author : Maxwell
    5. -- Description : Lists all locked objects.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @locked_objects
    8. -- Last Modified: 07-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 500
    11. SET PAGESIZE 1000
    12. SET VERIFY OFF
    13. COLUMN owner FORMAT A20
    14. COLUMN username FORMAT A20
    15. COLUMN object_owner FORMAT A20
    16. COLUMN object_name FORMAT A30
    17. COLUMN locked_mode FORMAT A15
    18. SELECT lo.session_id AS sid,
    19. s.serial#,
    20. NVL(lo.oracle_username, '(oracle)') AS username,
    21. o.owner AS object_owner,
    22. o.object_name,
    23. Decode(lo.locked_mode, 0, 'None',
    24. 1, 'Null (NULL)',
    25. 2, 'Row-S (SS)',
    26. 3, 'Row-X (SX)',
    27. 4, 'Share (S)',
    28. 5, 'S/Row-X (SSX)',
    29. 6, 'Exclusive (X)', lo.locked_mode) locked_mode,
    30. lo.os_user_name
    31. FROM v$locked_object lo
    32. JOIN dba_objects o ON o.object_id = lo.object_id
    33. JOIN v$session s ON lo.session_id = s.sid
    34. ORDER BY 1, 2, 3, 4;
    35. SET PAGESIZE 14
    36. SET VERIFY ON
    37. [oracle@MaxwellDBA monitoring]$

  • 相关阅读:
    Android 开发学习(二)
    CTF/AWD竞赛标准参考书+实战指南:《AWD特训营》
    OC高仿iOS网易云音乐AFNetworking+SDWebImage+MJRefresh+MVC+MVVM
    当我们做后仿时我们究竟在仿些什么(二)
    文章解读与仿真程序复现思路——电网技术EI\CSCD\北大核心《基于相似日聚类及模态分解的短期光伏发电功率组合预测研究》
    Docker:Elasticsearch安装配置IK分词器
    TCP通信实现:多发多收消息、实现可以同时接收多个客户端
    基于Matlab的超像素图像分割
    Linux的Jdk安装教程
    Windows与网络基础-26-IP地址概述
  • 原文地址:https://blog.csdn.net/u011868279/article/details/126199221