MySQL性能监控工具 orzdba python版本

搬瓦工机场JMS

orzdba 是淘宝开源的一款MySQL实时性能监控工具,使用Perl语言开发,最近在github上看到一款python版本的orzdba,功能与Perl版本差不多,试用了一下,总体感觉还不错,也发现了一些问题。
地址:https://github.com/cnlubo/orzdba
监控项:

  • CPU负载
  • 磁盘IO
  • 网络流量
  • swap
  • MySQL QPS
  • MySQL InnoDB
  • MySQL 连接线程
  • MySQL 缓存命中率
  • MySQL 响应时间

1、下载git clone https://github.com/cnlubo/orzdba.git
2、使用cd orzdbapython2.7 orzdba.py -S /mysql/data/mysql.sock -p’123456′  -t -com -c -l -n eth0
输出结果:——– —–load-avg—- —cpu-usage—   —–net(B)—– ———–QPS–TPS———–  time  |  1m    5m   15m |usr sys idl iow|    recv   send |   ins   upd   del    sel   iud|21:39:54| 0.06  0.06  0.64|  0   0 100   0|      0b      0b|     0     0     0      0     0|21:39:55| 0.06  0.06  0.64|  0   0 100   0|      5k      6k|     0     0     0      1     0|21:39:57| 0.05  0.06  0.64|  0   0 100   0|      6k      5k|     0     0     0      1     0|21:39:58| 0.05  0.06  0.64|  0   0 100   0|      6k      5k|     0     0     0      1     0|21:39:59| 0.05  0.06  0.64|  0   0 100   0|      5k      4k|     0     0     0      1     0|21:40:00| 0.05  0.06  0.64|  0   0 100   0|      5k      4k|     0     0     0      1     0|21:40:01| 0.05  0.06  0.64|  0   0 100   0|      9k      8k|     0     0     0      2     0|21:40:02| 0.05  0.06  0.64|  0   0 100   0|      6k      5k|     0     0     0      1     0|21:40:03| 0.05  0.06  0.64|  0   0 100   0|      6k      4k|     0     0     0      1     0|21:40:04| 0.05  0.06  0.64|  0   0 100   0|      6k      5k|     0     0     0      1     0|21:40:05| 0.05  0.06  0.64|  0   0 100   0|      6k      4k|     0     0     0      1     0|21:40:06| 0.05  0.06  0.64|  0   0 100   0|      5k      5k|     0     0     0      1     0|21:40:07| 0.04  0.06  0.63|  0   0 100   0|      6k      5k|     0     0     0      1     0|21:40:08| 0.04  0.06  0.63|  0   0 100   0|      5k      4k|     0     0     0      1     0|21:40:09| 0.04  0.06  0.63|  0   0 100   0|      6k      5k|     0     0     0      1     0|
3、参数
几个重要的参数:

  • -t 显示时间
  • -l 显示cpu负载
  • -c 显示cpu占用
  • -d 显示磁盘IO,如-d vdb
  • -n 显示网络流量,如-n eth0
  • -com 显示MySQL QPS
  • -innodb 显示InnoDB监控信息
  • -T 显示MySQL连接线程信息
  • -B 显示MySQL接收,发送的数据量
  • -rt 显示响应时间
  • -hit 显示MySQL缓存命中率


全部参数,如下:optional arguments:  -h, –help            show this help message and exit  -i INTERVAL, –interval INTERVAL                        Time(second) Interval.  -t, –time            Print The Current Time.  -sys                  print SysInfo (include -l,-c,-s).  -l, –load            Print Load Info.  -c, –cpu             Print Cpu Info.  -d DISK, –disk DISK  Print Disk Info.  -n NET, –net NET     Print Net Info.Time.  -s, –swap            Print The Swap Info.  -com                  print mysql status.  -innodb_rows          Print Innodb Rows Status.  -innodb_pages         Print Innodb Buffer Pool Pages  Status.  -innodb_data          Print Innodb Data Status.  -innodb_log           Print Innodb Log Status.  -innodb_status        Print Innodb Status from Command:  "Show Engine Innodb                        Status".  -innodb               Print Innodb Info.  -T, –threads         Print Threads Status.  -B, –bytes           Print Bytes Status.  -rt                   Print MySQL DB RT.  -hit                  Print Innodb Hit%  -mysql                print SysInfo (Print MySQLInfo  (include                        -t,-com,-hit,-T,-B).  -P PORT, –port PORT  Port number to use for mysql  connection(default 3306).  -S SOCKET, –socket SOCKET                        Socket file to use for mysql  connection.  -p PWD, –pwd PWD     root user password.  -C COUNT, –count COUNT                        Times.  -L LOGFILE, –logfile LOGFILE                        ath of logfile.  -logfile_by_day       one day a logfile.  -lazy                 Print Info (include  -t,-l,-c,-s,-m,-hit).
4、问题

  1. -n 参数监控网络流量,在RedHat 6.3 上流量值不准确。代码中通过周期性读取 /proc/net/dev 中的值来计算网卡流量,不同Linux发行版 /proc/net/dev 读出来的值格式不同,可能源码作者也没有在RedHat 6.3上测试过。
  2. -com 监控MySQL QPS时,有一些SQL无法被监控,比如insert,只取了MySQL状态变量中的Com_insert,而Com_insert_select没有计算在内,导致insert的QPS计算不准确。

未经允许不得转载:搬瓦工VPS_美国VPS » MySQL性能监控工具 orzdba python版本

赞 (0) 打赏

相关推荐

    暂无内容!

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏