zoukankan      html  css  js  c++  java
  • tcprstat和tcpstat性能监控

    tcprstat分析服务的响应速度利器

     
    tcprstat是percona用来监测mysql响应时间的。不过对于任何运行在TCP协议上的响应时间,都可以用。

    下面是一个监控示例,监控分析mysql的3306端口。

    根据上面的信息,我们可以知道mysql在我们检测期间,对于客户端查询的最大响应时间是559009(单位微妙),即0.559009秒。

    你也可以读取tcpdump的文件进行分析。

    $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

    安装tcprstat

    需要对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/tcprstat


    如果是在64位操作系统中使用,可以直接下载二进制文件使用。步骤如下:
    1、下载文件 http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64

    2、把下载的文件移动到 /usr/bin
    3、把文件名修改为 tcprstat
    4、修改文件权限,增加执行权限 chmod +x /usr/bin/tcprstat
    如果你想在32位操作系统中使用,那你只能自己编译了。

    代码下载地址 https://github.com/Lowercases/tcprstat https://launchpad.net/tcprstat

    命令行参数    简短形式   类型      描述                    默认值
    --format    -f        字符串     输出格式化字符串  ”%T	%n	%M	%m	%a	%h	%S	%95M	%95a	%95S	%99M	%99a	%99S
    ” 
    --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 加入默认读取的位置

    参考:

    https://www.xuebuyuan.com/763996.html

    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

  • 相关阅读:
    BETA版使用说明
    项目冲刺第二阶段Fifth Day
    第二阶段 项目冲刺Forth Day
    项目冲刺第二阶段Third Day
    项目冲刺第二阶段Second Day
    “渴了么”使用说明(供用户发表评论)
    项目冲刺第二阶段 每日站立会议First Day
    Alpha版总结会议
    alpha版使用说明书
    绩效考核
  • 原文地址:https://www.cnblogs.com/qmfsun/p/11726702.html
Copyright © 2011-2022 走看看