Home >Database >Mysql Tutorial >MySQL运行状态监控(pt-mysql-summary)

MySQL运行状态监控(pt-mysql-summary)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:50:471421browse

pt-mysql-summary也是percona-toolkit-2.2.8-1.noarch.rpm工具集的一部分。

pt-mysql-summary也是percona-toolkit-2.2.8-1.noarch.rpm工具集的一部分。
 
安装工具集请参考:
 
MySQL的show status命令 仅仅是一个状态的计数器。
 通常情况下,需要采集一个间隔的show status命令,然后分析它的趋势。
 
一定时间间隔的采集可以使用mysqladmin extended-status
 但是更简单的方法是使用pt-mysql-summary工具。
 
关于pt-mysql-summary工具的介绍请参考:
 
下面的脚本通过一个时间间隔的状态采集,
 得到这个间隔的增、删、改、查、提交、回滚的总数,然后通过gnuplot画图工具,绘制出图形。
 
脚本如下(Probe.sh):
 
#!/bin/bash
 #采集间隔时间,单位s
 asleep=10
 user=root
 password=root
 probe_file=probe.log
 output_image=/tmp/probe.png
 while [ 1 ] ; do
    a=$(pt-mysql-summary --user $user --password $password | grep -i "com_insert\|com_delete\|com_update\|com_select\|com_commit\|com_rollback" | awk    '{if(length($4)==0) print 0 ;else print $4}' | tr -t '\n' ' '); echo $(date "+%Y-%m-%d_%H:%M:%S") $a >> $probe_file
 
    gnuplot -e "set terminal png size 3000,1000 ; set size ratio 0.9 ; set output '$output_image' ; set xtic rotate by 90 ; set xdata time ; set grid;set    timefmt '%Y-%m-%d_%H:%M:%S' ; plot 'probe.log' using 1:2 with line title 'Commit', 'probe.log' using 1:3 with line title 'Delete', 'probe.log' using    1:4 with line title 'insert','probe.log' using 1:5 with line title 'rollback','probe.log' using 1:6 with line title 'select','probe.log' using 1:7 with    line title 'update' ; "
 done;
 

运行脚本,并且使用TPCC-MySQL基准测试工具开始测试(加一些流量容易看出效果)
 
TPCC-MySQL

 
关于Gnuplot画图工具的简单使用

 
查看绘图的结果:

 

Gnuplot
 set size ratio 0.9        Y轴:X轴 的比值
 set xtic rotate by 90    X轴的文字旋转90度

本文永久更新链接地址:

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn