mysqlreport 工具是一个perl 的脚本,为了能够正常运行该脚本,需要安装DBI 和DBD-mysql 等库。
现在的版本为3.5版本。
以下讲解选项的应用:
--user USER 连接mysql 的用户名
--password PASS 连接mysql 的密码
--host ADDRESS 连接mysql 的数据库ip地址,如果连接的是本机,则可以省略
--port PORT mysql 的端口
--socket SOCKET 连接mysql的socket 文件,如果有host,用户名和密码等,可以省略该参数
--no-mycnf 告诉mysqlreport 不需要读取my.cnf配置文件,默认情况会从my.cnf中读取配置
--infile FILE 从文件中读取状态资料,通常为使用show status 后输出的结果
--outfile FILE 把结果写入到一个文件中
--email ADDRESS 把报告的内容发送到指定的邮件地址中,主要是调用sendmail 程序来完成邮件的发送(doesn't work on Windows)
--flush-status 显示完报告后,执行 "FLUSH STATUS;" 语句,但需要有该权限
--relative X 间隔多少秒后再产生一份报告,每次的结果都是基于上一次的结果的差异。
--report-count N 合计采集多少份报告,只有设置了relative 后方生效(default 1)
--detach 后台运行(run in background)
--help Prints this
--debug Print debugging information
应用举例:
./mysqlreport -r 3600 -detach -email host@local --outfile /home/report.log host.com
一个小时后再产生一份系统报告,写入文件的同时发送email。
./mysqlreport 的结果如下:
MySQL 5.1.22-log uptime 47 18:44:29 Mon May 3 17:14:12 2010
__ Key _________________________________________________________________
Buffer used 14.16M of 16.00M %Used: 88.48
Current 9.57M %Usage: 59.82
Write hit 98.68%
Read hit 99.77%
__ Questions ___________________________________________________________
Total 29.30M 7.1/s
DMS 27.56M 6.7/s %Total: 94.05
Com_ 1.39M 0.3/s 4.76
COM_QUIT 347.22k 0.1/s 1.18
+Unknown 434 0.0/s 0.00
Slow 10 s 10 0.0/s 0.00 %DMS: 0.00 Log: OFF
DMS 27.56M 6.7/s 94.05
DELETE 17.67M 4.3/s 60.31 64.13
UPDATE 8.84M 2.1/s 30.16 32.07
SELECT 898.65k 0.2/s 3.07 3.26
INSERT 150.31k 0.0/s 0.51 0.55
REPLACE 0 0/s 0.00 0.00
Com_ 1.39M 0.3/s 4.76
change_db 963.51k 0.2/s 3.29
set_option 347.70k 0.1/s 1.19
show_create 23.12k 0.0/s 0.08
__ SELECT and Sort _____________________________________________________
Scan 146.59k 0.0/s %SELECT: 16.31
Range 68.85k 0.0/s 7.66
Full join 0 0/s 0.00
Range check 0 0/s 0.00
Full rng join 0 0/s 0.00
Sort scan 30 0.0/s
Sort range 82 0.0/s
Sort mrg pass 0 0/s
__ Table Locks _________________________________________________________
Waited 121.95k 0.0/s %Total: 0.44
Immediate 27.45M 6.6/s
__ Tables ______________________________________________________________
Open 64 of 64 %Cache: 100.00
Opened 50.67k 0.0/s
__ Connections _________________________________________________________
Max used 12 of 100 %Max: 12.00
Total 347.25k 0.1/s
__ Created Temp ________________________________________________________
Disk table 7.86k 0.0/s
Table 77.82k 0.0/s Size: 32.0M
File 32 0.0/s
__ Threads _____________________________________________________________
Running 1 of 3
Cached 0 of 0 %Hit: 0
Created 347.25k 0.1/s
Slow 0 0/s
__ Aborted _____________________________________________________________
Clients 56 0.0/s
Connects 1 0.0/s
__ Bytes _______________________________________________________________
Sent 553.34M 134.0/s
Received 892.11M 216.1/s
__ InnoDB Buffer Pool __________________________________________________
Usage 8.00M of 8.00M %Used: 100.00
Read hit 99.99%
Pages
Free 0 %Total: 0.00
Data 508 99.22 %Drty: 0.00
Misc 4 0.78
Latched 0 0.00
Reads 555.12M 134.5/s
From file 46.30k 0.0/s 0.01
Ahead Rnd 455 0.0/s
Ahead Sql 141 0.0/s
Writes 124.86M 30.2/s
Flushes 273.15k 0.1/s
Wait Free 0 0/s
__ InnoDB Lock _________________________________________________________
Waits 0 0/s
Current 0
Time acquiring
Total 0 ms
Average 0 ms
Max 0 ms
__ InnoDB Data, Pages, Rows ____________________________________________
Data
Reads 51.85k 0.0/s
Writes 112.45k 0.0/s
fsync 40.80k 0.0/s
Pending
Reads 0
Writes 0
fsync 0
Pages
Created 195.73k 0.0/s
Read 55.60k 0.0/s
Written 273.15k 0.1/s
Rows
Deleted 0 0/s
Inserted 31.16M 7.5/s
Read 57.86M 14.0/s
Updated 0 0/s
报表解读:
MySQL 5.0.22-log uptime 47 18:49:16 Mon May 3 17:18:59 2010
显示了mysql 的版本,运行时间,当前服务器时间
__ Key _________________________________________________________________
Buffer used 14.16M of 16.00M %Used: 88.48
Current 9.57M %Usage: 59.82
Write hit 98.68%
Read hit 99.77%
显示缓冲区的使用情况。读和写的命中率信息
__ Questions ___________________________________________________________
Total 29.30M 7.1/s ---总共进行的查询及查询的频率
DMS 27.56M 6.7/s %Total: 94.05 --进行DMS 操作的总量和操作频率及DMS占用整个查询的百分比
Com_ 1.39M 0.3/s 4.76 --所有 MySQL 所执行过的指令,如果值比较高表示 MySQL 正忙碌于无关紧要的事情上
COM_QUIT 347.24k 0.1/s 1.18
+Unknown 434 0.0/s 0.00
Slow 10 s 10 0.0/s 0.00 %DMS: 0.00 Log: OFF 记录慢查询的执行总次数,频率,占用比列,是否开启慢查询log。
DMS 27.56M 6.7/s 94.05 ---统计DMS 操作的各项的详细汇总
DELETE 17.67M 4.3/s 60.31 64.13
UPDATE 8.84M 2.1/s 30.16 32.07
SELECT 898.71k 0.2/s 3.07 3.26
INSERT 150.32k 0.0/s 0.51 0.55
REPLACE 0 0/s 0.00 0.00
Com_ 1.39M 0.3/s 4.76
change_db 963.56k 0.2/s 3.29
set_option 347.72k 0.1/s 1.19
show_create 23.12k 0.0/s 0.08