首页 > 技术文章 > tcprstat 很不错的服务器时延统计工具

rongfengliang 2020-09-20 09:35 原文

tcprstat 是一个很不错的网络通信检测,可以支持多种应用协议的处理

安装

git clone https://github.com/y123456yz/tcprstat.git
yum -y install bison yacc flex  glibc-static  libcap-devel
./configure
make &&  make  install
  • 支持的命令
./tcprstat --help
tcprstat 0.3.1, libpcap version 1.1.1.
Usage: tcprstat [--port <port>] [--format=<format>] [--interval=<sec>]
             [--header[=<header>] | --no-header] [--iterations=<it>]
             [--read=<file>]
       tcprstat --version | --help
    --read <file>, -r    Capture from pcap file <file>, not live.
    --time <ms>, -T     time delay > -T(time) count stastic.
    --log  <file>, -o   if time dealy > -T(time), timestamp record to log file.
    --local <addresses>, -l
                         <addresses> is a comma-separated list of ip
                         addresses, which are used as the local list of
                         addresses instead of pcap getting the list.
                         This is useful when working with a pcap file got
                         from another host with different addresses.
    --port <port>, -p    Capture traffic only for tcp/<port>.
    --format <format>, -f
                         Output format. Argument is a string detailing
                         how the information is presented. Accepted codes:
                             %n - Response time count
                             %a - Response time media in microseconds
                             %s - Response time sum
                             %x - Response time squares sum
                             %m - Minimum value
                             %M - Maximum value
                             %T - counts that package delay time(default 40ms)
                             %h - Median value
                             %S - Standard deviation
                             %v - Variance (square stddev)
                             %I - Iteration number
                             %t - Timestamp since iteration zero
                             %T - Unix timestamp
                             %% - A literal %
                         Default is:
    "%T\t%n\t%M\t%m\t%a\t%h\t%S\t%C\t%95M\t%95a\t%95S\t%99M\t%99a\t%99S\n".
                         Statistics may contain a percentile between
                         the percentage sign and the code: %99n, %95a.
    --header[=<header>], --no-header
                         Whether to output a header. If not supplied, a
                         header is created out of the format. By default,
                         the header is shown.
    --interval <seconds>, -t
                         Output interval. Default is 10.
    --iterations <n>, -n
                         Output iterations. Default is 1, 0 is infinity
    --help               Shows program information and usage.
    --version            Shows version information.

试用

测试一个redis 服务的

  • 安装redis
yum install -y redis
  • 运行命令
./tcprstat -p 6379 -t 1  -n 0
  • 运行压测
redis-benchmark

说明

tcprstat 是一个很不错的工具,但是目前基本没看到维护了,实际上bcc是一个更好的性能分析套件,可以放到我们日常的开发以及性能
分析的工具包中

参考资料

https://github.com/y123456yz/tcprstat
https://github.com/Lowercases/tcprstat

推荐阅读