tcprstat是percona用来监测mysql响应时间的。不过对于任何运行在TCP协议上的响应时间,均可以用。
下面是一个监控示例,监控分析mysql的3306端口。html

根据上面的信息,咱们能够知道mysql在咱们检测期间,对于客户端查询的最大响应时间是559009(单位微妙),即0.559009秒。mysql
你也能够读取tcpdump的文件进行分析。git
$sudo tcpdump -i eth0 -nn port 80 -w ./tcpdump.log
$sudo tcprstat -l 10.234.9.103 -t 2 -n 5 -r ./tcpdump.log
timestamp count max min avg med stddev 95_max 95_avg 95_std 99_max 99_avg 99_std
1403180482 2 28017 26717 27367 28017 650 26717 26717 0 26717 26717 0
1403180484 0 0 0 0 0 0 0 0 0
安装tcprstatgithub
须要对tcprstat创建软链接(这个的配置路径在161行,我这就以默认为准,不修改)
tcprstat 是本身下载的额
首先,先赋予执行权限
[root@localhost orzdba]# chmod +x tcprstat-static.v0.3.1.x86_64
创建软链接:
[root@localhost orzdba]# ln -sf /root/test/orzdba/tcprstat-static.v0.3.1.x86_64 /usr/bin/tcprstat
[root@localhost orzdba]# chown -R root:root /usr/bin/tcprstat
[root@localhost orzdba]# chmod u+s /usr/bin/tcprstatsql
若是是在64位操做系统中使用,能够直接下载二进制文件使用。步骤以下:
一、下载文件 http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64数据库
二、把下载的文件移动到 /usr/bin
三、把文件名修改成 tcprstat
四、修改文件权限,增长执行权限 chmod +x /usr/bin/tcprstat
若是你想在32位操做系统中使用,那你只能本身编译了。markdown
代码下载地址 https://github.com/Lowercases/tcprstat https://launchpad.net/tcprstat网络

命令行参数 简短形式 类型 描述 默认值
--format -f 字符串 输出格式化字符串 ”%T\t%n\t%M\t%m\t%a\t%h\t%S\t%95M\t%95a\t%95S\t%99M\t%99a\t%99S\n”
--help 显示帮助信息
--interval -t 数字 监控多少秒输出一次统计 10
--iterations -n 数字 共输出几回统计信息 1
--local -l 字符串 本级ip地址列表
--port -p 数字 服务端口
--read -r 字符串 pcap文件路径
--version 显示版本信息
--no-header 字符串 输出不显示头信息
--header 字符串 指定输出的头信息
cprstat工具安装与使用
tcprstat是免费开源tcp分析工具,经过监控网络传输来统计分析请求的响应时间
使用方法:
tcprstat是安装在server端,统计分析本地网卡地址请求的响应时间,能够用于临时分析,也可定时任务作信息收集
下载
# wget http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64
# cp tcprstat-static.v0.3.1.x86_64 tcprstat
# chmod a+x tcprstat
[root@localhost oradisk]# ./tcprstat -p 1588 -t 1 -n 0 -l 172.16.100.87
timestamp count max min avg med stddev 95_max 95_avg 95_std 99_max 99_avg 99_std
1357885445 256 73120 67 746 245 4607 995 349 285 3107 399 405
1357885446 256 2610 84 365 255 317 846 330 266 906 351 281
1357885446 36 968 127 370 278 287 900 336 259 908 353 272
还能够经过以下的方式,不过是统计分析机器的全部ip地址
# ./tcprstat -p 1588 -t 1 -n 0 -l `/sbin/ifconfig | grep 'addr:[^ ]\+' -o | cut -f 2 -d : | xargs echo | sed -e 's/ /,/g'`
以下是一台生产数据库的响应时间
[root@skate01 oradisk]# ./tcprstat -p 1588 -t 1 -n 0 -l `/sbin/ifconfig | grep 'addr:[^ ]\+' -o | cut -f 2 -d : | xargs echo | sed -e 's/ /,/g'`
timestamp count max min avg med stddev 95_max 95_avg 95_std 99_max 99_avg 99_std
1357886048 5840 26133 54 240 163 500 664 184 101 1411 214 183
1357886049 6003 3405 57 227 164 242 660 182 96 1296 211 173
1357886050 6376 27322 29 269 168 689 724 194 117 1643 226 196
1357886051 6524 20489 58 225 167 330 613 182 92 1168 208 160
1357886052 6123 33313 52 231 165 497 627 181 94 1213 209 164
1357886053 6991 66977 55 221 167 822 525 176 80 1120 199 140
1357886054 5876 11483 57 234 162 427 610 177 89 1195 204 160
1357886055 6166 189134 30 526 187 3085 1265 245 202 6366 342 561
1357886056 5678 5913 52 210 161 218 553 172 81 1100 196 142
㈠ 查看MySQL响应时间(rt)
先安装tcprstat
# wget http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64
# ln -sf /root/tcprstat-static.v0.3.1.x86_64 /usr/bin/tcprstat
在源码161行左右把 /usr/bin/tcprstat 加入默认读取的位置
参考:tcp
https://www.xuebuyuan.com/763996.htmlide
http://blog.itpub.net/15480802/viewspace-1453968/
https://github.com/y123456yz/tcprstat
https://blog.csdn.net/weixin_34161029/article/details/85757925
https://blog.csdn.net/dba_waterbin/article/details/12970675