前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >关于抓取session信息的一个脚本(r3笔记第8天)

关于抓取session信息的一个脚本(r3笔记第8天)

作者头像
jeanron100
发布2018-03-14 17:44:08
5780
发布2018-03-14 17:44:08
举报

关于session的诊断,可以基于动态性能视图,ash,awr.. 自己也写过一些简单的脚本,在平时的工作中也能够完成一些基本的工作。今天在看taner分享的脚本snapper的时候,让自己眼前一亮,也发现自己存在着很多的不足的地方。 可以从脚本中看到他孜孜不倦的分享着自己的心得,而且自己也写了一些更加深入的一些工具集来解析oracle的技术细节。 脚本的功能很多,林林总总下来代码有近2000多行,功能点很多,自己看文档也简单尝试了几个。发现还不错。可以在平时的工作中也基于自己的需求来做一些修改。 taner也提供了一些其它脚本的下载链接。http://blog.tanelpoder.com/中可以看到有很多的技术博客,自己最近也是心浮气躁,没能静下心来好好总结,自己也需要更加努力。 简单示范几个脚本的使用例子。 比如我想多次抓取session的细节,可以通过如下的参数来辅助,下面的例子就是示范抓取所有的session信心,没5秒抓取一次,一共抓取2次

代码语言:javascript
复制
SQL>  @snapper  ash=sid+event+wait_class+sql_id,ash1=sql_id 5 2 all
Sampling SID all  with interval 5 seconds, taking 2 snapshots...
-- Session Snapper v4.12 BETA - by Tanel Poder ( http://blog.tanelpoder.com ) - Enjoy the  Most Advanced Oracle Troubleshooting Script on the Planet! :)

------------------------------------------------------------------------------------------
Active%  |    SID | EVENT                               | WAIT_CLASS      |  SQL_ID
------------------------------------------------------------------------------------------
      2% |      6 | control file parallel write         | System I/O      |
-------------------------
Active% |  SQL_ID
-------------------------
     2% |
--  End of ASH snap 1, end=2014-09-27 07:39:44, seconds=5, samples_taken=41
  <No active sessions captured during the sampling period>
     <No active sessions captured during the sampling period>
--  End of ASH snap 2, end=2014-09-27 07:39:49, seconds=5, samples_taken=45

PL/SQL procedure successfully completed.

下面还有一些作者提供的例子。

代码语言:javascript
复制

 @snapper  ash,stats 1 1 515
--      (Output one 1-second snapshot of session 515 using  dbms_output and exit
--       Wait, gv$sesstat and gv$sess_time_model  statistics are reported by default
--       Starting from V3 the ASH style  session activity report is shown as well)
--
--      @snapper  stats,gather=w 1 1 515
--      (Output one 1-second snapshot of session 515  using dbms_output and exit
--       only Wait event statistics are reported,  no ASH)
--
--      @snapper ash,gather=st 1 1 515
--      (Output one  1-second snapshot of session 515 using dbms_output and exit
--       only  gv$sesstat and gv$sess_Time_model statistics are gathered +  ASH)
--
--      @snapper trace,ash,gather=stw,pagesize=0 10 90  117,210,313
--      (Write 90 10-second snapshots into tracefile for session  IDs 117,210,313
--       all statistics are reported, do not print any  headers)
--
--      @snapper trace,ash 900 999999999 "select sid from  v$session"
--      (Take a snapshot of ALL sessions every 15 minutes and  write the output to trace,
--       loop (almost) forever )
--
--       @snapper out,trace 300 12 "select sid from v$session where  username='APPS'"
--      (Take 12 5-minute snapshots of all sessions  belonging to APPS user, write
--       output to both dbms_output and  tracefile)

感兴趣的可以从技术blog中下载附件:http://blog.itpub.net/23718752/viewspace-1283050/

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2014-09-27,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 杨建荣的学习笔记 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档