[iyunv@Betty WGET_DIR]# tar czvf tcprstat.tar.gz ./tcprstat
查看相关文件。
[iyunv@Betty WGET_DIR]# cd tcprstat/
[iyunv@Betty tcprstat]# ll
total 72
-rw-r--r-- 1 root root 38 Aug 23 17:18 AUTHORS
-rw-r--r-- 1 root root 35147 Aug 23 17:18 COPYING
-rw-r--r-- 1 root root 0 Aug 23 17:18 ChangeLog
-rw-r--r-- 1 root root 922 Aug 23 17:18 Makefile.am
-rw-r--r-- 1 root root 914 Aug 23 17:18 NEWS
-rw-r--r-- 1 root root 2730 Aug 23 17:18 README
-rw-r--r-- 1 root root 81 Aug 23 17:18 TODO
-rw-r--r-- 1 root root 926 Aug 23 17:18 bootstrap
-rw-r--r-- 1 root root 2643 Aug 23 17:18 configure.ac
drwxr-xr-x 2 root root 4096 Aug 23 17:18 libpcap
drwxr-xr-x 2 root root 4096 Aug 23 17:18 src
[iyunv@Betty tcprstat]#
README 中一句话说明:tcprstat 是一个基于 pcap 提取 TCP 应答时间信息的工具。
[iyunv@Betty tcprstat]# vi README
~ tcprstat ~
tcprstat is a pcap-based tool that extracts information about TCP response
times.
tcprstat 是一个基于 pcap 提取 TCP 应答时间信息的工具。
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.
# 工作原理:嗅探 TCP 的 request 并测量发送 response 所需的事件间隔。适用于一问一答式协议类型
的处理,如 HTTP 和 MySQL 协议。
tcprstat sniffs for a while, and then shows some stats about the sniffed
packets, similar to the way top(1) works.
tcpstat 会嗅探一段时间,然后展现一些统计信息,工作方式类似于 top 。
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
tcpstat 使用 libpcap 来捕获 TCP 包。鉴于许多发行版并不提供 libpcap >= 1.0.0 ,tcpstat
源码包中自带了相关源文件。
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.
构建过程会生成一个 static 版本 -- tcpstat-static ,其不需要依赖任何外部链接,所以可以直接
拷贝其他机器上使用。
tcprstat is released under the GPL, version 2 or 3.
################################################################################
# #
# tcprstat -- Extract stats about TCP response times #
# Copyright (C) 2010 Ignacio Nin #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #
# #
################################################################################
为 bootstrap 增加可执行权限后尝试执行。
[iyunv@Betty tcprstat]# chmod +x bootstrap
[iyunv@Betty tcprstat]# ./bootstrap
./bootstrap: line 23: aclocal: command not found
[iyunv@Betty tcprstat]#
查看 bootstrap 文件内容。
[iyunv@Betty tcprstat]#
[iyunv@Betty tcprstat]# vi bootstrap
#!/bin/sh
#
# tcprstat -- Extract stats about TCP response times
# Copyright (C) 2010 Ignacio Nin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
[iyunv@Betty tcprstat]# yum list|grep automake
automake.noarch 1.9.6-2.3.el5 base
automake14.noarch 1.4p6-13.el5.1 base
automake15.noarch 1.5-16.el5.2 base
automake16.noarch 1.6.3-8.el5.1 base
automake17.noarch 1.7.9-7.el5.2 base
[iyunv@Betty tcprstat]#
[iyunv@Betty tcprstat]#
[iyunv@Betty tcprstat]# yum list|grep autoconf
autoconf.noarch 2.59-12 base
autoconf-archive.noarch 2012.09.08-1.el5 epel
autoconf213.noarch 2.13-12.1 base
ocaml-autoconf.noarch 1.0-4.el5 epe<span></span>l
[iyunv@Betty tcprstat]#
[iyunv@Betty tcprstat]# yum -y install automake
安装成功后,重新执行 bootstrap ,发现不够。
[iyunv@Betty tcprstat]# ./bootstrap
configure.ac:24: error: Autoconf version 2.61 or higher is required
configure.ac:24: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
aclocal: autom4te failed with exit status: 63
[iyunv@Betty tcprstat]#
只能卸载 yum 安装,然后通过源码安装 automake 和 autoconf ,安装成功后,执行 bootstrap 。
[iyunv@Betty tcprstat]# ./bootstrap
configure.ac:80: warning: AC_CONFIG_SUBDIRS: you should use literals
autoconf/status.m4:1106: AC_CONFIG_SUBDIRS is expanded from...
configure.ac:80: the top level
configure.ac:80: warning: AC_CONFIG_SUBDIRS: you should use literals
autoconf/status.m4:1106: AC_CONFIG_SUBDIRS is expanded from...
configure.ac:80: the top level
configure.ac:80: warning: AC_CONFIG_SUBDIRS: you should use literals
autoconf/status.m4:1106: AC_CONFIG_SUBDIRS is expanded from...
configure.ac:80: the top level
configure.ac:30: installing './compile'
configure.ac:26: installing './install-sh'
configure.ac:26: installing './missing'
Makefile.am: installing './INSTALL'
src/Makefile.am: installing './depcomp'
configure.ac:80: warning: AC_CONFIG_SUBDIRS: you should use literals
autoconf/status.m4:1106: AC_CONFIG_SUBDIRS is expanded from...
configure.ac:80: the top level
[iyunv@Betty tcprstat]#
再执行
[iyunv@Betty tcprstat]# ./configure
[iyunv@Betty tcprstat]# make
查看都生成了哪些文件。
[iyunv@Betty tcprstat]# ll
total 484
-rw-r--r-- 1 root root 38 Aug 23 16:02 AUTHORS
-rw-r--r-- 1 root root 35147 Aug 23 16:02 COPYING
-rw-r--r-- 1 root root 0 Aug 23 16:02 ChangeLog
lrwxrwxrwx 1 root root 38 Aug 23 16:57 INSTALL -> /usr/local/share/automake-1.14/INSTALL
-rw-r--r-- 1 root root 25282 Aug 23 16:58 Makefile
-rw-r--r-- 1 root root 922 Aug 23 16:02 Makefile.am
-rw-r--r-- 1 root root 25101 Aug 23 16:57 Makefile.in
-rw-r--r-- 1 root root 914 Aug 23 16:02 NEWS
-rw-r--r-- 1 root root 2730 Aug 23 16:02 README
-rw-r--r-- 1 root root 81 Aug 23 16:02 TODO
-rw-r--r-- 1 root root 41921 Aug 23 16:57 aclocal.m4
drwxr-xr-x 2 root root 4096 Aug 23 16:57 autom4te.cache
-rwxr-xr-x 1 root root 926 Aug 23 16:02 bootstrap
lrwxrwxrwx 1 root root 38 Aug 23 16:57 compile -> /usr/local/share/automake-1.14/compile
-rw-r--r-- 1 root root 3192 Aug 23 16:58 config.h
-rw-r--r-- 1 root root 2940 Aug 23 16:57 config.h.in
-rw-r--r-- 1 root root 62239 Aug 23 16:58 config.log
-rwxr-xr-x 1 root root 33714 Aug 23 16:58 config.status
-rwxr-xr-x 1 root root 191969 Aug 23 16:57 configure
-rw-r--r-- 1 root root 2643 Aug 23 16:02 configure.ac
lrwxrwxrwx 1 root root 38 Aug 23 16:57 depcomp -> /usr/local/share/automake-1.14/depcomp
lrwxrwxrwx 1 root root 41 Aug 23 16:57 install-sh -> /usr/local/share/automake-1.14/install-sh
drwxr-xr-x 3 root root 4096 Aug 23 16:58 libpcap
lrwxrwxrwx 1 root root 38 Aug 23 16:57 missing -> /usr/local/share/automake-1.14/missing
drwxr-xr-x 3 root root 4096 Aug 23 16:59 src
-rw-r--r-- 1 root root 23 Aug 23 16:58 stamp-h1
[iyunv@Betty tcprstat]#
进入 src 目录后可以看到生成了可执行程序。
[iyunv@Betty tcprstat]# cd src/
[iyunv@Betty src]# ll
total 1780
-rw-r--r-- 1 root root 46379 Aug 23 16:58 Makefile
-rw-r--r-- 1 root root 1800 Aug 23 16:02 Makefile.am
-rw-r--r-- 1 root root 52447 Aug 23 16:57 Makefile.in
-rw-r--r-- 1 root root 3006 Aug 23 16:02 capture.c
-rw-r--r-- 1 root root 1057 Aug 23 16:02 capture.h
-rw-r--r-- 1 root root 4015 Aug 23 16:02 functions.c
-rw-r--r-- 1 root root 1019 Aug 23 16:02 functions.h
-rw-r--r-- 1 root root 4325 Aug 23 16:02 local-addresses.c
-rw-r--r-- 1 root root 1065 Aug 23 16:02 local-addresses.h
-rw-r--r-- 1 root root 10157 Aug 23 16:02 output.c
-rw-r--r-- 1 root root 1315 Aug 23 16:02 output.h
-rw-r--r-- 1 root root 3970 Aug 23 16:02 process-packet.c
-rw-r--r-- 1 root root 1139 Aug 23 16:02 process-packet.h
-rw-r--r-- 1 root root 7845 Aug 23 16:02 stats-hash.c
-rw-r--r-- 1 root root 1480 Aug 23 16:02 stats-hash.h
-rw-r--r-- 1 root root 10411 Aug 23 16:02 stats.c
-rw-r--r-- 1 root root 1958 Aug 23 16:02 stats.h
-rwxr-xr-x 1 root root 280074 Aug 23 16:59 tcprstat
-rw-r--r-- 1 root root 10976 Aug 23 16:59 tcprstat-capture.o
-rw-r--r-- 1 root root 10720 Aug 23 16:59 tcprstat-functions.o
-rw-r--r-- 1 root root 13816 Aug 23 16:59 tcprstat-local-addresses.o
-rw-r--r-- 1 root root 23528 Aug 23 16:59 tcprstat-output.o
-rw-r--r-- 1 root root 13776 Aug 23 16:59 tcprstat-process-packet.o
-rwxr-xr-x 1 root root 1019964 Aug 23 16:59 tcprstat-static
-rw-r--r-- 1 root root 16544 Aug 23 16:59 tcprstat-stats-hash.o
-rw-r--r-- 1 root root 27720 Aug 23 16:59 tcprstat-stats.o
-rw-r--r-- 1 root root 19080 Aug 23 16:59 tcprstat-tcprstat.o
-rw-r--r-- 1 root root 5970 Aug 23 16:02 tcprstat.c
-rw-r--r-- 1 root root 1339 Aug 23 16:02 tcprstat.h
-rw-r--r-- 1 root root 10976 Aug 23 16:59 tcprstat_static-capture.o
-rw-r--r-- 1 root root 10720 Aug 23 16:59 tcprstat_static-functions.o
-rw-r--r-- 1 root root 13816 Aug 23 16:59 tcprstat_static-local-addresses.o
-rw-r--r-- 1 root root 23528 Aug 23 16:59 tcprstat_static-output.o
-rw-r--r-- 1 root root 13776 Aug 23 16:59 tcprstat_static-process-packet.o
-rw-r--r-- 1 root root 16544 Aug 23 16:59 tcprstat_static-stats-hash.o
-rw-r--r-- 1 root root 27720 Aug 23 16:59 tcprstat_static-stats.o
-rw-r--r-- 1 root root 19080 Aug 23 16:59 tcprstat_static-tcprstat.o
[iyunv@Betty src]#