14.蛤蟆的Oracle杂记——Oracle SQL监控脚本
根据第上一篇描述的,需要dbsqlmon.exe脚本来监控SQL语句。
长时间运行的SQL(超过6秒)可以通过监控V$SESSION_LONGOPS来观察。(包括很多备份、恢复函数,静态统计收集,查询执行等)
而监控数据被记录在V$SQL_MONITOR视图中。V$SQL_MONITOR收集的信息每秒刷新一次。当SQL执行完毕后 ,至少会保留一分钟。
当前实现的功能如下:
$ sh dbsqlmon.sh
Invalid Arguments!
pls use like this : ./dbsqlmon.exe [ NUMBER]
the NUMBER can be from 1 to 100
[1] show the instance's sql monitor status
[2] report sql monitor
[3] tuning sql recommendations with exactly SQL_ID
[4] get the session's execuing SQL TEXT ,need the SESSION_ID
[5] get the sql's explain,need the "SQLTEXT"
[6] get the sql's explain which cause session to wait. but you need input thewaitevent name
[7] get the last Mins's busiest sql, you can define how minuts
[8] get sid,sqltext,sql's waitevent of the executing sql
现在主要8个功能
1 显示实例SQL监控状态
2 获取SQL 监控 报告
3 获取SQL ID 的调优建议
4 获取会话的当前正在执行的SQL 文本
5 获取SQL执行计划,需要输入SQL文本(相关即可)
6 导致会话具体等待的SQL执行计划,需要输入等待事件名字
7 获取最后几分钟最繁忙的SQL
8 获取当前正在执行SQL的SID,SQLTEXT,等待事件
程序名字如下:dbsqlmon.exe