当前位置: 首页 > 工具软件 > tcprstat > 使用案例 >

mysql tookit之tcprstat

祝宏放
2023-12-01

1.安装

wget http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64

cp tcprstat-static.v0.3.1.x86_64 /usr/bin/tcprstat
chmod +x /usr/bin/tcprstat

2.使用:

tcprstat -p 3306 -t 1 -n 5

bonding模式 虚拟网卡情况下需要

如果运行的时候提示 pcap: SIOCGIFFLAGS: bonding_masters: No such device。那说明没能自动提取服务器ip。需要使用-l参数手动指定。

tcprstat -p 3306 -n 0 -t 1 -l ip

原理:

基于libpcap捕获数据包,根据源ip+端口, 目标ip+端口 ,计算其最后1个入包和第1个出包的时间差 来计算响应耗时;

具体可以看下readme:
tcprstat ~

tcprstat is a pcap-based tool that extracts information about TCP response
times.

It works by sniffing for TCP “requests” (inbound packets) and measures the time
that it takes for sending a “response” (next outbound packet). While this
approach might seem too simple, it works for simple protocols that are based in
such request/response system, like HTTP and the MySQL protocol. In the future,
we may write more complex protocol decoding.

tcprstat sniffs for a while, and then shows some stats about the sniffed
packets, similar to the way top(1) works.

tcprstat uses libpcap to capture TCP. Due to many distros not shipping
libpcap >= 1.0.0, tcprstat ships libpcap 1.1.1 and uses it if it can’t find a
suitable version

The build process delivers a static version, tcprstat-static, with no external
linking (some castration is needed at libpcap) so it can be copied directly to
a server with no need for compilation tools.

tcprstat is released under the GPL, version 2 or 3.

总:

可以作为 redis ,mongo,mysql等真实耗时的工具,排除数据库RT高的怀疑。DBA可以甩锅了。

 类似资料: