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 ...
随机推荐
- Oracle基础 04 归档日志 archivelog
--查看归档模式archive log list select log_mode from v$database; --修改为归档模式(mount下)alter database archivelog ...
- 2.kafka单节点broker的安装与启动
下载kafka,http://kafka.apache.org/downloads kafka下面的文件结构如下: 进入bin目录,启动kafka之前要先启动zookeeper ./zookeeper ...
- [ 总结 ] 删除通过find查找到的文件
[root@cloud abc]# touch test{,,,} [root@cloud abc]# ls shadow test test1 test2 test3 test5 [root@clo ...
- ie 下input光标位置垂直不居中问题
input输入框用一个背景图模拟,设置height和line-height一样的高度,使里面的输入文字能够居中, 在FF下出现的情况是:点击input时,输入光标其实上跟input的height一样高 ...
- 架构妄想:AJAX + REST
William Vambenepe的最新文章,AJAX + REST是最新的架构妄想,让我们回想起了一个具有15年历史的架构,它曾被寄期望对Web产生革命性的影响. 在该架构里,Web服务器将返回包含 ...
- sublime text3中使用Emmet部分标签无法闭合
转载自:http://geek100.com/2490/ 不过很早就发现br,input, img在sublime text中是没有闭合标签 / 的. 我一般都是手动补上的, 今天突然想起这个问题, ...
- (十二)MySQL逻辑备份mysqldump
(1)简介 语法 mysqldump -h服务器 -u用户名 -p密码 [-P端口号] [参数] 数据库名 >备份文件.sql 关于数据库: -A,--all-databases 所有库,会生成 ...
- [thinkphp] 公共头部底部如何传递数据
分组底下有一个公共模板文件夹 Modules/Index/Tpl/public/ 如何传递数据给模板呢? 在 入口文件/Lib/Action/ 中创建类CommonAction.class.php ...
- CF 1005A Tanya and Stairways 【STL】
Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairw ...
- 【ZOJ】3785 What day is that day? ——KMP 暴力打表找规律
转自:http://www.cnblogs.com/kevince/p/3887827.html 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这么一说大家心里肯定有数了吧,“不就是nex ...