JAMon监控SQL执行时间
JAMon监控web工程方法的调用性能 http://www.cnblogs.com/zfc2201/p/3786365.html
这往往篇文章主要告诉大家如何监控web方法调用时间,在这个基础这上,如果我们想要监控sql的执行时间,需要增加如下的配置:
1.增加一个类,假设是com.allen.bookshop.common.MonitorDataSource
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException; import javax.sql.DataSource; import com.jamonapi.proxy.MonProxyFactory; public class MonitorDataSource implements DataSource
{
private DataSource realDataSource; public void setRealDataSource( DataSource realDataSource )
{
this.realDataSource = realDataSource;
} public DataSource getRealDataSource()
{
return realDataSource;
} public Connection getConnection() throws SQLException
{
// 表示由jamon来代理realDataSource返回的Connection
return MonProxyFactory.monitor( realDataSource.getConnection() );
} public Connection getConnection( String username, String password )
throws SQLException
{
// 表示由jamon来代理realDataSource返回的Connection return MonProxyFactory.monitor( realDataSource.getConnection( username,
password ) );
} public PrintWriter getLogWriter() throws SQLException
{
return realDataSource.getLogWriter();
} public int getLoginTimeout() throws SQLException
{
return realDataSource.getLoginTimeout();
} public void setLogWriter( PrintWriter out ) throws SQLException
{
realDataSource.setLogWriter( out );
} public void setLoginTimeout( int seconds ) throws SQLException
{
realDataSource.setLoginTimeout( seconds );
}
}
2.对数据源进行配置:
<bean id="dataSource" class="com.allen.bookshop.common.MonitorDataSource" destroy-method="close">
<property name="realDataSource" ref="basicDataSource"/>
</bean>
<bean id="basicDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@192.168.0.11:1521:orcl" />
<property name="username" value="orcl" />
<property name="password" value="orcl" />
<property name="initialSize" value="20" />
<property name="maxActive" value="50" />
<property name="defaultAutoCommit" value="true" />
</bean>
至此,配置完成,现在可以访问:http://localhost:8080/bookshop/jamon/sql.jsp查看sql的执行时间了。
JAMon监控SQL执行时间的更多相关文章
- 用脚本定时监控SQL Server主从一致性
用脚本定时监控SQL Server主从一致性 首先说一下我们的环境 我们使用的是事务复制,复制是单向的,主服务器和从服务器都在同一个机房,当然不同机房也可以,只需要改一下IP和端口 下面的脚本在我们的 ...
- DBA 需要知道N种对数据库性能的监控SQL语句
--DBA 需要知道N种对数据库性能的监控SQL语句 -- IO问题的SQL内部分析 下面的DMV查询可以来检查当前所有的等待累积值. Select wait_type, waiting_tasks_ ...
- 监控SQL:执行表中所有sql语句、记录每个语句运行时间(3)
原文:监控SQL:执行表中所有sql语句.记录每个语句运行时间(3) 通过执行一个 带参数的存储过程 exec OpreateTB('OpreateUser','IsRun') 更新表的数据 表 ...
- 监控SQL:通过SQL Server的DDL触发器来监控数据库结构的变化(1)
原文:监控SQL:通过SQL Server的DDL触发器来监控数据库结构的变化(1) 如果你要同步不同数据库之间的数据,首先会想到的是数据库复制技术,但如果让你同步数据库的结构,你会想到什么呢? 下面 ...
- 监控 SQL Server (2005/2008) 的运行状况
Microsoft SQL Server 2005 提供了一些工具来监控数据库.方法之一是动态管理视图.动态管理视图 (DMV) 和动态管理函数 (DMF) 返回的服务器状态信息可用于监控服务器实例的 ...
- Performance Monitor3:监控SQL Server的内存压力
SQL Server 使用的资源受到操作系统的调度,同时,SQL Server在内部实现了一套调度算法,用于管理从操作系统获取的资源,主要是对内存和CPU资源的调度.一个好的数据库系统,必定在内存中缓 ...
- JavaMelody监控SQL
前言 前面讲过了Javamelody的基本配置,这里简单的介绍下,如何使用Javamelody来监控JDBC以及SQL. 手码不易,转载请注明:xingoo 在网上搜索很多资料,仅有开源社区上的两篇帖 ...
- 第三篇——第二部分——第六文 监控SQL Server镜像
原文:第三篇--第二部分--第六文 监控SQL Server镜像 原文出处:http://blog.csdn.net/dba_huangzj/article/details/26846203 要优化, ...
- java监控函数执行时间
java监控函数执行时间 http://blog.csdn.net/ycg01/article/details/1467542 java监控函数执行时间 标签: javathreadclassstri ...
随机推荐
- certbot 免费httos证书申请
https://keelii.com/2016/06/12/free-https-cert-lets-encrypt-apply-install/
- wxpython学习资源
http://www.cnblogs.com/dyx1024/archive/2012/07/15/2592202.html wxPython:布局管理器sizer介绍 ogs.com/dyx1024 ...
- PHP文件环境搭建—EcShop环境搭建
1 rpm -qa|grep yum|xargs rpm -e --nodeps 2 ls 3 rpm -ivh python-iniparse-0.3.1-2.1.el6.noar ...
- xshell连接虚拟机CentOS出现eth0 device not found的解决方法
昨天用xshell连接虚拟机上的centOS老是连接不上,ifconfig eth0 命令显示 device not found.不知道是什么原因... 折腾了好久 网上是各种搜啊 终于找到解决方法了 ...
- python2.7安装Twisted报Microsoft Visual C++9.0 required
环境: 操作系统:Windows 7 32位 语言:Python 2.7.9 Twisted: Twisted 安装,执行如下命令: pip install Twisted 报错如下: error:M ...
- [BZOJ3027][Ceoi2004]Sweet 容斥+组合数
3027: [Ceoi2004]Sweet Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 135 Solved: 66[Submit][Status] ...
- Jest+Enzyme React js/typescript测试环境配置案例
本文案例github:https://github.com/axel10/react-jest-typescript-demo 配置jest的react测试环境时我们可以参考官方的配置教程: http ...
- ubuntu14.04 安装 pyv8
1. $sudo pip install -v pyv8 Error: pip unicodedecodeerror ‘ascii’ codec can’t decode byte 0xe2 in p ...
- (1) Flutter android studio安装
Flutter由两部分组成 Flutter引擎和Flutter框架 Flutter引擎由C++编写,在android上通过NDK编译,在ios上通过llvm编译 Flutter框架由dart编写 1. ...
- CF 1003D Coins and Queries【位运算/硬币值都为2的幂/贪心】
Polycarp has n coins, the value of the i-th coin is ai. It is guaranteed that all the values are int ...