在数据库遇到性能问题的时候,可能从io,cpu等角度能够下手找到性能瓶颈,日志的切换也是影响性能的一个因素,如果日志切换台频繁,等待时间就会在日志相关的事件上,从数据库的角度来说,肯定是io的瓶颈。

可以通过如下的shell脚本来得到一个简单的报告。

脚本如下:

sqlplus -s $DB_CONN_STR@$SH_DB_SID<

set linesize    150

set pages       100

set feedback    off

set verify      off

col dbname      new_value dbname

col time_stamp  new_value time_stamp

col timestamp_np        noprint

col year_np             noprint

col month_np            noprint

col mon                 for a3

col day                 for a2

ttitle off

SELECT name dbname, substr(to_char(sysdate,'YYYY-Mon-DD HH24:MI:SS'),1,20)

time_stamp

FROM v\$database

/

col bytes format 9,999,999,999,999

col member format a60

select group#,thread#,sequence#,members,bytes/1024/1024 size_MB,archived,status

from v\$log order by 1,2;

ttitle left "Redo Switch times per hour" center "&dbname" right "&time_stamp"

set term on

col tps00 for 999 head "00"

col tps01 for 999 head "01"

col tps02 for 999 head "02"

col tps03 for 999 head "03"

col tps04 for 999 head "04"

col tps05 for 999 head "05"

col tps06 for 999 head "06"

col tps07 for 999 head "07"

col tps08 for 999 head "08"

col tps09 for 999 head "09"

col tps10 for 999 head "10"

col tps11 for 999 head "11"

col tps12 for 999 head "12"

col tps13 for 999 head "13"

col tps14 for 999 head "14"

col tps15 for 999 head "15"

col tps16 for 999 head "16"

col tps17 for 999 head "17"

col tps18 for 999 head "18"

col tps19 for 999 head "19"

col tps20 for 999 head "20"

col tps21 for 999 head "21"

col tps22 for 999 head "22"

col tps23 for 999 head "23"

SELECT *

FROM

( SELECT substr(year_np,1,8)  timestamp_np,

substr(year_np,5,2) Mon, substr(year_np,7,2) Day,

sum(decode(substr(year_np,9,2),'00',cnt,0))   tps00,

sum(decode(substr(year_np,9,2),'01',cnt,0))   tps01,

sum(decode(substr(year_np,9,2),'02',cnt,0))   tps02,

sum(decode(substr(year_np,9,2),'03',cnt,0))   tps03,

sum(decode(substr(year_np,9,2),'04',cnt,0))   tps04,

sum(decode(substr(year_np,9,2),'05',cnt,0))   tps05,

sum(decode(substr(year_np,9,2),'06',cnt,0))   tps06,

sum(decode(substr(year_np,9,2),'07',cnt,0))   tps07,

sum(decode(substr(year_np,9,2),'08',cnt,0))   tps08,

sum(decode(substr(year_np,9,2),'09',cnt,0))   tps09,

sum(decode(substr(year_np,9,2),'10',cnt,0))   tps10,

sum(decode(substr(year_np,9,2),'11',cnt,0))   tps11,

sum(decode(substr(year_np,9,2),'12',cnt,0))   tps12,

sum(decode(substr(year_np,9,2),'13',cnt,0))   tps13,

sum(decode(substr(year_np,9,2),'14',cnt,0))   tps14,

sum(decode(substr(year_np,9,2),'15',cnt,0))   tps15,

sum(decode(substr(year_np,9,2),'16',cnt,0))   tps16,

sum(decode(substr(year_np,9,2),'17',cnt,0))   tps17,

sum(decode(substr(year_np,9,2),'18',cnt,0))   tps18,

sum(decode(substr(year_np,9,2),'19',cnt,0))   tps19,

sum(decode(substr(year_np,9,2),'20',cnt,0))   tps20,

sum(decode(substr(year_np,9,3),'21',cnt,0))   tps21,

sum(decode(substr(year_np,9,3),'22',cnt,0))   tps22,

sum(decode(substr(year_np,9,2),'23',cnt,0))   tps23

FROM (SELECT to_char(first_time,'YYYYMMDDHH24') year_np,count(*) cnt

FROM v\$log_history where first_time>sysdate -15

GROUP BY to_char(first_time,'YYYYMMDDHH24')

)

GROUP BY substr(year_np,1,8), substr(year_np,5,2), substr(year_np,7,2)

)

ORDER BY timestamp_np

/

<

exit;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23718752/viewspace-1176479/,如需转载,请注明出处,否则将追究法律责任。

linux如何脚本监控tps,通过shell脚本监控日志切换频率相关推荐

  1. Linux服务器监控cpu数据shell脚本

    Linux服务器监控cpu数据shell脚本 背景: 一种简易的监控进程的CPU.内存.线程数.句柄数的办法,使用shell脚本实现监控,Excel实现数据分析. #!/bin/bash#过滤出需要的 ...

  2. linux脚本监控网卡流量,Shell脚本实现linux监控网卡实时流量[带宽]的方法

    今天分享一个Linux网卡实时流量查看的shell脚本. 以下是脚本: #!/bin/bash if [ -z "$1" ]; then echo echo usage: $0 n ...

  3. linux怎么测试一个脚本,一个Linux中用于监控的简易shell脚本

    系统管理员的任务真的很艰难,因为他/她必须监控服务器.用户.日志,还得创建备份,等等等等.对于大多数重复性的任务,大多数管理员都会写一个自动化脚本来日复一日地重复这些任务.这里,我们已经写了一个she ...

  4. 一个Linux中用于监控的简易shell脚本

    系统管理员的任务真的很艰难,因为他/她必须监控服务器.用户.日志,还得创建备份,等等等等.对于大多数重复性的任务,大多数管理员都会写一个自动化脚本来日复一日地重复这些任务.这里,我们已经写了一个she ...

  5. 监控mysql的shell脚本_监控MySQL主从状态的shell脚本

    分享一个Linux下,监控MySQL主从状态及配合企业微信机器人报警的Shell脚本 SLAVE_IP:为监控的主机IP USER:为msyql用户 PASSWORD:为mysql密码 WHEREIS ...

  6. linux编写复制脚本程,常用的Shell脚本

    1.通过位置变量创建linux系统账户及密码 $1 是执行脚本的第一个参数,$2 是执行脚本的第二个参数 1 #!/bin/bash 2 #Author: Peter zh 3 #Blog: http ...

  7. linux 脚本实现物理备份,shell脚本实现系统监视统计与数据备份

    知识内容:*管理统计信息*执行备份*管理用户对于linux SA来说,没啥比shell脚本编程更有用的了.linux系统每天都有很多任务需要做好,从监视系统 磁盘空间.系统用户到备份系统重要文件.通过 ...

  8. linux 查重脚本,Linux脚本学习必经之路:Shell脚本实例分享

    写shell脚本还是一样,思路第一,语法其次,下面分享几个脚本实例,大家主要是理解一下里面的思路,语法稍微注意一下. 1. 观察数字,输出包含前6个数字在内的16个数字 观察以下数字,看有什么规律: ...

  9. linux 脚本中=$4,shell脚本实例,通向shell脚本大师的必经之路

    概述 读书百遍其义自见,shell脚本也是,只要例子看得多了,自然就知道怎么写了.这里主要整理了20几个例子,因为内容比较多,所以分了几次来做介绍了.下面的实例最好先自己思考怎么去实现,然后再看下实现 ...

最新文章

  1. 4一20ma电流有源与无源区别_4-20 mA电流环的工作原理是怎么样的
  2. 语义分割--Full-Resolution Residual Networks for Semantic Segmentation in Street Scenes
  3. AutoCAD .NET API二次开发学习指南
  4. 【风控】团伙挖掘中的14大关系类型
  5. 解决/WEB-INF目录下的jsp页面引入webRoot下的Js、css和图片的问题
  6. 【SQL】找出行数与自增标识值不相等的表(即有缺行)
  7. 在linux centos 7上安装maven
  8. 如何在Python中获取周数?
  9. 安装oracle11g未找到文件WFMLRSVCApp.ear文件
  10. [leetcode]01.04. 回文排列
  11. 理解最小生成树与权值最小边无关
  12. Servlet实现一个登陆界面
  13. 使用easypoi导出excel设置表头样式
  14. openGauss 训练营第三期结营啦!PPT 85个FAQ大放送!文末附51位结营学员名单
  15. #从焦虑到从容,不吼不叫养出好孩子-02做懂得沟通的父母-带着爱与慈悲来表达需求
  16. 数据传输加密——非对称加密算法RSA+对称算法AES(适用于java,android和Web)
  17. 鸡和兔子若干只,头有35个,脚有94个,求兔子和鸭个多少只
  18. [web效果实现-3] 拼音排序通讯录实现
  19. Jenkins2.249-自定义插件安装(十一)
  20. 24时区,GMT,UTC,DST,CST时间详解 ISO8601

热门文章

  1. 【转载】生机勃勃的秋菊freeeim
  2. qq音乐2012绿色版
  3. 一般是一个较为复杂的 飞鸽传书 对象
  4. C++中的文件输入/输出(6):一些有用的函数
  5. 普通程序员,光靠GitHub打赏就年入70万,要不你也试试
  6. 再谈要不要成为全栈工程师
  7. mysql union_Mysql union和union all用法
  8. Nature子刊 | 通过多组学手段系统解析儿童肝母细胞瘤分子特征,为临床诊断提供精确参考...
  9. 国际千人基因组计划数据库怎么用起来?
  10. Omni Recover for Mac版 - 一站式iPhone数据恢复