Tcprstat测试mysql响应时间

一、tcprstat工具安装与使用

tcprstat 是一个基于 pcap 提取 TCP 应答时间信息的工具,通过监控网络传输来统计分析请求的响应时间。

  • 使用方法:
    tcprstat是安装在server端,统计分析本地网卡地址请求的响应时间,可以用于临时分析,也可定时任务做信息收集

1、 下载安装tcprstat

  • x86_64位操作系统可以直接下载二进制文件使用。
  1. 步骤如下:
  2. 1、下载文件 http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64
  3. 2、把下载的文件移动到 /usr/bin
  4. 3、把文件名修改为 tcprstat
  5. 4、修改文件权限,增加执行权限 chmod +x /usr/bin/tcprstat
  • i686操作系统只能自己编译。

源码下载

2、tcprestat 使用

  1. [root@sql ~]# tcprstat -p 3306 -t 1 -n 5 -I em1
  2. tcprstat: invalid option -- 'I'
  3. Usage: tcprstat [--port <port>] [--format=<format>] [--interval=<sec>]
  4. [--header[=<header>] | --no-header] [--iterations=<it>]
  5. [--read=<file>]
  6. tcprstat --version | --help
  7. --read <file>, -r Capture from pcap file <file>, not live.
  8. --local <addresses>, -l
  9. <addresses> is a comma-separated list of ip
  10. addresses, which are used as the local list of
  11. addresses instead of pcap getting the list.
  12. This is useful when working with a pcap file got
  13. from another host with different addresses.
  14. --port <port>, -p Capture traffic only for tcp/<port>.
  15. --format <format>, -f
  16. Output format. Argument is a string detailing
  17. how the information is presented. Accepted codes:
  18. %n - Response time count
  19. %a - Response time media in microseconds
  20. %s - Response time sum
  21. %x - Response time squares sum
  22. %m - Minimum value
  23. %M - Maximum value
  24. %h - Median value
  25. %S - Standard deviation
  26. %v - Variance (square stddev)
  27. %I - Iteration number
  28. %t - Timestamp since iteration zero
  29. %T - Unix timestamp
  30. %% - A literal %
  31. Default is:
  32. "%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".
  33. Statistics may contain a percentile between
  34. the percentage sign and the code: %99n, %95a.
  35. --header[=<header>], --no-header
  36. Whether to output a header. If not supplied, a
  37. header is created out of the format. By default,
  38. the header is shown.
  39. --interval <seconds>, -t
  40. Output interval. Default is 10.
  41. --iterations <n>, -n
  42. Output iterations. Default is 1, 0 is infinity
  43. --help Shows program information and usage.
  44. --version Shows version information.
  • 参数说明
  1. 命令行参数 简短形式 类型 描述 默认值
  2. --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
  3. --help 显示帮助信息
  4. --interval -t 数字 监控多少秒输出一次统计 10
  5. --iterations -n 数字 迭代执行的次数 0 意味着无限循环
  6. --local -l 字符串 本级ip地址列表
  7. --port -p 数字 端口
  8. --read -r 字符串 pcap文件路径
  9. --no-header 字符串 输出不显示头信息
  10. --header 字符串 指定输出的头信息
  11. --version 显示版本信息

3、执行tcprtat

  • 运行 tcpstat 需要 root 权限。
  1. [root@sqlmaster ~]# ifconfig -a
  2. bond0: flags=5122<BROADCAST,MASTER,MULTICAST> mtu 1500
  3. ether c6:81:ba:27:41:22 txqueuelen 1000 (Ethernet)
  4. RX packets 0 bytes 0 (0.0 B)
  5. RX errors 0 dropped 0 overruns 0 frame 0
  6. TX packets 0 bytes 0 (0.0 B)
  7. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  8. bond2: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500
  9. inet 192.168.106.156 netmask 255.255.255.0 broadcast 192.168.106.255
  10. inet6 fe80::266e:96ff:fe7a:2530 prefixlen 64 scopeid 0x20<link>
  11. ether 24:6e:96:7a:25:30 txqueuelen 1000 (Ethernet)
  12. RX packets 841045952 bytes 140694028836 (131.0 GiB)
  13. RX errors 0 dropped 9 overruns 0 frame 0
  14. TX packets 879251828 bytes 315328775843 (293.6 GiB)
  15. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  16. em1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
  17. ether 24:6e:96:7a:25:30 txqueuelen 1000 (Ethernet)
  18. RX packets 229601719 bytes 41718497150 (38.8 GiB)
  19. RX errors 0 dropped 0 overruns 0 frame 0
  20. TX packets 216881448 bytes 77518470229 (72.1 GiB)
  21. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  22. em2: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
  23. ether 24:6e:96:7a:25:30 txqueuelen 1000 (Ethernet)
  24. RX packets 233564715 bytes 33185099691 (30.9 GiB)
  25. RX errors 0 dropped 0 overruns 0 frame 0
  26. TX packets 284092875 bytes 114906661329 (107.0 GiB)
  27. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  28. em3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  29. inet 192.168.48.156 netmask 255.255.255.0 broadcast 192.168.48.255
  30. inet6 fe80::266e:96ff:fe7a:2534 prefixlen 64 scopeid 0x20<link>
  31. ether 24:6e:96:7a:25:34 txqueuelen 1000 (Ethernet)
  32. RX packets 24855939 bytes 2219201978 (2.0 GiB)
  33. RX errors 0 dropped 161 overruns 0 frame 0
  34. TX packets 27211500 bytes 30274496459 (28.1 GiB)
  35. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  36. device memory 0x91a80000-91afffff
  37. em4: flags=4098<BROADCAST,MULTICAST> mtu 1500
  38. ether 24:6e:96:7a:25:35 txqueuelen 1000 (Ethernet)
  39. RX packets 0 bytes 0 (0.0 B)
  40. RX errors 0 dropped 0 overruns 0 frame 0
  41. TX packets 0 bytes 0 (0.0 B)
  42. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  43. device memory 0x91a00000-91a7ffff
  44. lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
  45. inet 127.0.0.1 netmask 255.0.0.0
  46. inet6 ::1 prefixlen 128 scopeid 0x10<host>
  47. loop txqueuelen 1 (Local Loopback)
  48. RX packets 74096282 bytes 26484813440 (24.6 GiB)
  49. RX errors 0 dropped 0 overruns 0 frame 0
  50. TX packets 74096282 bytes 26484813440 (24.6 GiB)
  51. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  52. [root@sqlmaster ~]#
  53. [root@sqlmaster ~]# tcprstat -p 3306 -t 1 -n 5
  54. pcap: SIOCGIFFLAGS: bonding_masters: No such device --那说明没自动获取服务器ip。需要使用-l参数手动指定IP
  55. [root@sqlmaster ~]# tcprstat -p 3306 -t 1 -n 5 -l 192.168.106.156 --指定ip、指定端口
  56. timestamp count max min avg med stddev 95_max 95_avg 95_std 99_max 99_avg 99_std
  57. 1541410855 9 412 35 121 86 108 132 84 38 132 84 38
  58. 1541410856 11 432 24 136 84 135 332 107 102 332 107 102
  59. 1541410857 3 506 173 360 401 139 401 287 114 401 287 114
  60. 1541410858 7 516 73 270 234 140 360 229 105 360 229 105
  61. 1541410859 8 177 23 77 78 50 107 63 34 107 63 34
  • 通过如下的方式,不过是统计分析机器的所有ip地址

Centos6 统计分析机器的所有ip地址

  1. [root@master(36.100) ~]# tcprstat -p 3306 -t 1 -n 0 -l `/sbin/ifconfig | grep 'addr:[^ ]\+' -o | cut -f 2 -d : | xargs echo | sed -e 's/ /,/g'`
  2. timestamp count max min avg med stddev 95_max 95_avg 95_std 99_max 99_avg 99_std
  3. 1541412023 186 69239 26 922 450 5152 675 423 171 10490 489 760
  4. 1541412024 122 59761 65 2050 481 7520 2758 526 247 34144 1288 4441
  5. 1541412025 134 72180 126 1343 562 6337 838 527 123 10543 733 1289
  6. 1541412026 151 49829 39 1088 543 4340 792 513 122 10413 647 1016
  7. 1541412027 130 62064 83 1150 573 5513 741 527 128 5134 571 427
  8. 1541412028 130 34246 363 814 450 2989 691 480 92 3045 514 256
  9. 1541412029 125 55868 52 1287 593 5430 782 552 108 12540 659 1082
  10. 1541412030 129 49267 117 837 434 4281 653 446 79 737 456 93
  11. 1541412031 131 83227 57 1171 580 7197 683 529 123 755 537 123
  12. 1541412032 135 58226 55 1019 599 4947 813 559 123 1667 577 162
  13. 1541412033 149 46590 386 977 609 3820 712 600 69 912 609 79
  14. 1541412034 67 56254 55 1656 614 6976 701 575 119 15967 829 1886
  • Centos7 统计分析机器的所有ip地址
  1. [root@sqlmaster ~]# tcprstat -p 3306 -t 1 -n 0 -l `/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
  2. timestamp count max min avg med stddev 95_max 95_avg 95_std 99_max 99_avg 99_std
  3. 1541412404 0 0 0 0 0 0 0 0 0 0 0 0
  4. 1541412405 0 0 0 0 0 0 0 0 0 0 0 0
  5. 1541412406 17 754 26 134 73 178 395 95 91 395 95 91
  6. 1541412407 98 467 22 62 57 59 97 52 23 402 58 42
  7. 1541412408 10 1020 72 234 130 286 479 147 120 479 147 120
  8. 1541412409 8 126 26 61 64 34 90 52 25 90 52 25
  9. 1541412410 2 515 490 502 515 25 490 490 0 490 490 0
  10. 1541412411 1 380 380 380 380 0 0 0 0 0 0 0
  11. 1541412412 49 436 19 101 67 105 360 80 67 435 94 95
  12. 1541412413 1 435 435 435 435 0 0 0 0 0 0 0
  13. 1541412414 0 0 0 0 0 0 0 0 0 0 0 0
  14. 1541412415 9 444 26 112 54 124 175 70 44 175 70 44
  15. 1541412416 29 446 21 148 77 134 399 127 111 435 138 123
  16. 1541412417 58 403 18 91 60 96 332 74 66 398 85 88
  17. 1541412418 10 306 23 98 76 78 159 75 37 159 75 37
  18. 1541412419 0 0 0 0 0 0 0 0 0 0 0 0
  19. [root@sqlmaster ~]#

Tcprstat测试mysql响应时间的更多相关文章

  1. mysql响应时间超时排查

    背景: 数据库运营环境,zabbix mysql响应时间告警,响应时间超时 zabbix监控 tcprstart 直接抓包响应时间看到每5秒钟就一次,与zabbix监控一致 [root@slave1( ...

  2. ubuntu下安装与测试mysql

    1.在决定安装mysql之前,要先确定系统是否已经安装mysql. 输入: 1 mysql 结果:说明尚未安装mysql The program 'mysql' is currently notins ...

  3. 测试MySQL事务管理

    1.MySQL 版本 mysql> select version(); +------------+ | version() | +------------+ -log | +--------- ...

  4. php测试mysql数据库连通性并且在浏览器每一秒输出一次结果

    有时候网络环境不稳定,需要测试mysql数据库的连接是否畅通,我们可以通过php脚本实现,具体代码如下,在360浏览器测试通过: <?php /* 循环打印出mysql连接测试 */ heade ...

  5. 测试mysql

    sysbench 测试mysql TODO emacs

  6. 5.JMeter测试mysql数据库

    1.使用jmeter测试mysql数据库时,需要导入jar包,jar包网盘地址为:链接: https://pan.baidu.com/s/1-5-s7HccudT4GirpmBVn6Q 密码: bea ...

  7. python测试mysql写入性能完整实例

    这篇文章主要介绍了python测试mysql写入性能完整实例,具有一定借鉴价值,需要的朋友可以参考下 本文主要研究的是python测试mysql写入性能,分享了一则完整代码,具体介绍如下. 测试环境: ...

  8. 【MySQL】测试MySQL表中安全删除重复数据只保留一条的相关方法

    第二篇文章测试说明 开发测试中,难免会存在一些重复行数据,因此常常会造成一些测试异常. 下面简单测试mysql表删除重复数据行的相关操作. 主要通过一下三个大标题来测试说明: 02.尝试删除dept_ ...

  9. SQL注入之DVWA平台测试mysql注入

    今天主要针对mysql常用注入语句进行测试. 测试环境与工具: 测试平台:DVWA,下载地址:http://down.51cto.com/data/875088,也可下载metaspolit-tabl ...

随机推荐

  1. 接收一条音频(系统音频)彩信,点菜单键选择View slideshow,不能播放,提示是否导入vCard

    [前提条件]: [操作步骤]:接收一条音频(系统音频,格式为ogg),点菜单键选择View slideshow [测试结果]:不能播放,提示是否导入vCard [预期结果]:可以播放 [备注]:附lo ...

  2. 一款经典的 jQuery Lightbox 灯箱效果

    一个灯箱效果的图片展示插件. 版本: jQuery v1.2.3+ jQuery Lightbox v2.7.1 github 实例预览 使用方法 载入 CSS 文件 <link rel=&qu ...

  3. Vue 之axios获取Http响应头

    服务器端:Access-Control-Expose-Headers : 'Authorization' 客户端:res.headers.Authorization 引用链接:https://segm ...

  4. C# 历史曲线控件 基于时间的曲线控件 可交互的高级曲线控件 HslControls曲线控件使用教程

    本篇博客主要对 HslControls 中的曲线控件做一个详细的教程说明,大家可以根据下面的教程开发出高质量的曲线控件 Prepare 先从nuget下载到组件,然后就可以使用组件里的各种组件信息了. ...

  5. HDU 4185

    http://acm.hdu.edu.cn/showproblem.php?pid=4185 两个挨着的'#'可以配成一对,求最多能配成几对 挨着的'#'就连边,然后求一次最大匹配,答案是最大匹配除以 ...

  6. 【opencv基础】cv::Point类型与行列的关系

    关系 row == height == Point.y col == width == Point.x Mat::at(Point(x, y)) == Mat::at(y,x) 参考 1.博客: 完

  7. linux shell终端打开方式

    前言 Linux操作系统没有Window操作系统界面友好,使用者需要使用命令与系统进行交互,交互媒介为shell终端. 有三种方式可以打开终端: 方法一: 打开新的窗口并打开shell终端,快捷键:c ...

  8. 如何从github上clone项目源码-linux

    前言 github是目前较为流行的代码托管网站,linux系统是目前开发人员较为常用的操作系统.项目实现的过程中用到一些经典好用的源代码,可以从github上clone,本文主要介绍linux系统命令 ...

  9. Windows-CreateProcess-fdwCreate

    DEBUG_PROCESS: DEBUG_ONLY_THIS_PROCESS: CREATE_SUSPENDED: DETACHED_PROCESS: CREATE_NEW_CONSOLE: CREA ...

  10. make: *** No rule to make target `/thread_native.h', needed by `ossl.o'. Stop

    修改 Makefile 增加 top_srcdir = ../.. 即可 该文件大多存于ruby源文件下 PS:有时也可能是makefile文件多了空格所致