tcprstat和tcpstat性能監控

tcprstat分析服務的響應速度利器

 
tcprstat是percona用來監測mysql響應時間的。不過對於任何運行在TCP協議上的響應時間,均可以用。

下面是一個監控示例,監控分析mysql的3306端口。html

 

根據上面的信息,咱們能夠知道mysql在咱們檢測期間,對於客戶端查詢的最大響應時間是559009(單位微妙),即0.559009秒。mysql

你也能夠讀取tcpdump的文件進行分析。git

$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

安裝tcprstatgithub

須要對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
sql


若是是在64位操做系統中使用,能夠直接下載二進制文件使用。步驟以下:
一、下載文件 http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64
數據庫

二、把下載的文件移動到 /usr/bin
三、把文件名修改成 tcprstat
四、修改文件權限,增長執行權限 chmod +x /usr/bin/tcprstat
若是你想在32位操做系統中使用,那你只能本身編譯了。
markdown

代碼下載地址 https://github.com/Lowercases/tcprstat https://launchpad.net/tcprstat網絡

 

 

 

命令行參數    簡短形式   類型      描述                    默認值
--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」 
--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 加入默認讀取的位置

參考:tcp

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

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

相關文章
相關標籤/搜索