下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
MysqL
-- 查询超时记录 select * from visit_record t where t.accesstime>to_date('2013-09-1','yyyy-MM-dd') and t.username is not null and t.result='成功' and t.totaltimecost>5000 and t.clientip <> '192.168.112.53' and t.clientip <> '192.168.112.200' and t.clientip <> '192.168.112.245' order by t.totaltimecost desc ; -- 导出日期范围内的日志信息(已xml格式导出为stat.xml,使用navicat工具导入进stat表) select t.username,t.accesstime,t.totaltimecost,t.accessurl from visit_record t where t.accesstime>to_date('2013-09-1','yyyy-MM-dd') and t.username is not null and t.result='成功' and t.clientip <> '192.168.112.53' and t.clientip <> '192.168.112.200' and t.clientip <> '192.168.112.245' and (t.accessurl='/newOA/m_flow/navPage.do' or t.accessurl='/newOA/m_commWorkflow/submitNode_2p0.do' or t.accessurl='/newOA/user/showDaiBanxiangJsp.do' or t.accessurl='/newOA/user/showDaiBanXiangList.do' ) order by t.totaltimecost desc ; -- 统计超时率(myql库中) select t.ACCESSURL as url,COUNT(t.ACCESSURL) as 发生次数,COUNT(IF(t.TOTALTIMECOST>5000,t.TOTALTIMECOST,null)) as 超时次数,null))/COUNT(t.ACCESSURL) as 超时率,ROUND(avg(t.TOTALTIMECOST)) as 平均耗时,max(t.TOTALTIMECOST) as 最大耗时 from stat t group by t.ACCESSURL order by 平均耗时 desc; -- 时间分布(异常统计) select t.ACCESSURL as url,null)) as 超时次数,COUNT(IF(t.TOTALTIMECOST>5000 and time(t.ACCEsstIME) between '09:00:00' and '10:00:00',null)) as '9',COUNT(IF(t.TOTALTIMECOST>5000 and time(t.ACCEsstIME) between '10:00:00' and '11:00:00',null)) as '10',COUNT(IF(t.TOTALTIMECOST>5000 and time(t.ACCEsstIME) between '11:00:00' and '12:00:00',null)) as '11',COUNT(IF(t.TOTALTIMECOST>5000 and time(t.ACCEsstIME) between '12:00:00' and '13:00:00',null)) as '12',COUNT(IF(t.TOTALTIMECOST>5000 and time(t.ACCEsstIME) between '13:00:00' and '14:00:00',null)) as '13',COUNT(IF(t.TOTALTIMECOST>5000 and time(t.ACCEsstIME) between '14:00:00' and '15:00:00',null)) as '14',COUNT(IF(t.TOTALTIMECOST>5000 and time(t.ACCEsstIME) between '15:00:00' and '16:00:00',null)) as '15',COUNT(IF(t.TOTALTIMECOST>5000 and time(t.ACCEsstIME) between '16:00:00' and '17:00:00',null)) as '16',COUNT(IF(t.TOTALTIMECOST>5000 and time(t.ACCEsstIME) between '17:00:00' and '18:00:00',null)) as '17' from stat t group by t.ACCESSURL with ROLLUP; select t.ACCESSURL as url,COUNT(IF( time(t.ACCEsstIME) between '09:00:00' and '10:00:00',COUNT(IF( time(t.ACCEsstIME) between '10:00:00' and '11:00:00',COUNT(IF( time(t.ACCEsstIME) between '11:00:00' and '12:00:00',COUNT(IF( time(t.ACCEsstIME) between '12:00:00' and '13:00:00',COUNT(IF( time(t.ACCEsstIME) between '13:00:00' and '14:00:00',COUNT(IF( time(t.ACCEsstIME) between '14:00:00' and '15:00:00',COUNT(IF( time(t.ACCEsstIME) between '15:00:00' and '16:00:00',COUNT(IF( time(t.ACCEsstIME) between '16:00:00' and '17:00:00',COUNT(IF( time(t.ACCEsstIME) between '17:00:00' and '18:00:00',null)) as '17' from stat t group by t.ACCESSURL with ROLLUP; -- 日期分布(正常统计) select t.ACCESSURL as url,COUNT(IF( WEEKDAY(t.ACCEsstIME)=0,t.ACCEsstIME,null)) as '星期1',COUNT(IF( WEEKDAY(t.ACCEsstIME)=1,null)) as '星期2',COUNT(IF( WEEKDAY(t.ACCEsstIME)=2,null)) as '星期3',COUNT(IF( WEEKDAY(t.ACCEsstIME)=3,null)) as '星期4',COUNT(IF( WEEKDAY(t.ACCEsstIME)=4,null)) as '星期5',COUNT(IF( WEEKDAY(t.ACCEsstIME)=5,null)) as '星期6',COUNT(IF( WEEKDAY(t.ACCEsstIME)=6,null)) as '日' from stat t group by t.ACCESSURL select t.ACCESSURL as url,COUNT(IF( t.TOTALTIMECOST>5000 and WEEKDAY(t.ACCEsstIME)=0,COUNT(IF( t.TOTALTIMECOST>5000 and WEEKDAY(t.ACCEsstIME)=1,COUNT(IF( t.TOTALTIMECOST>5000 and WEEKDAY(t.ACCEsstIME)=2,COUNT(IF( t.TOTALTIMECOST>5000 and WEEKDAY(t.ACCEsstIME)=3,COUNT(IF( t.TOTALTIMECOST>5000 and WEEKDAY(t.ACCEsstIME)=4,COUNT(IF( t.TOTALTIMECOST>5000 and WEEKDAY(t.ACCEsstIME)=5,COUNT(IF( t.TOTALTIMECOST>5000 and WEEKDAY(t.ACCEsstIME)=6,null)) as '日' from stat t group by t.ACCESSURL
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。