安装:
wget -O tsar.zip https://github.com/alibaba/tsar/archive/master.zip --no-check-certificate
unzip ./tsar.zip
cd tsar-master/
make&& make install
如果不用tsar,还可以用sar,perf 等
tsar使用方法: $ tsar [Module] [Options]
Modules Enabled:
--nginx nginx statistics
--dev_traf Net traffic statistics for dev_volume
--nginx_code nginx httpcode
--nginx_domain nginx domain statistics
Options:
--live/-l running print live mode, which module will print
--interval/-i specify intervals numbers, in minutes if with --live, it is in seconds
--list/-l
1、查看 --nginx 每2s的输出信息,以list形式
$ tsar --nginx -l -i 2
Time ----------------------------------------------nginx---------------------------------------------
Time accept handle reqs active read write wait qps rt sslqps spdyps sslhst
16/08/18-15:15:08 3.00 3.00 3.00 1.00 0.00 1.00 0.00 1.50 0.33 0.00 0.00 0.00
16/08/18-15:15:10 3.00 3.00 3.00 1.00 0.00 1.00 0.00 1.50 0.67 0.00 0.00 0.00
2、 查看 --nginx_code 每1s的输出信息,以list形式
注:这里设置了某个域名或者location的403拒绝访问,可以看到到这台机器的ngin_code有很多403状态码。
$ tsar --nginx_code -i 1 -l
Time ----------------------------------------------------nginx_code--------------------------------------------------
Time 200 206 302 304 403 404 416 499 500 502 503 504 508 dother
16/04/19-15:09:33 82.00 0.00 4.00 0.00 1.1K 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
16/04/19-15:09:34 79.00 0.00 11.00 0.00 1.1K 0.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 1.00
16/04/19-15:09:35 77.00 0.00 10.00 0.00 1.2K 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00
16/04/19-15:09:36 94.00 0.00 7.00 0.00 1.3K 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00
3、查看 --nginx_domain 每2s的输出信息,以list形式
$ tsar --nginx_domain -l -i 2
Time ----------------------------------:80-----------------------------------
Time cps qps 2XX 3XX 4XX 5XX rt uprt upret
16/08/18-15:12:09 1.50 1.50 1.50 0.00 0.00 0.00 0.00 0.00 0.00
16/08/18-15:12:11 1.50 1.50 1.50 0.00 0.00 0.00 0.67 1.00 0.00
16/08/18-15:12:13 1.50 1.50 1.50 0.00 0.00 0.00 0.33 0.50 0.00
4、watch nginx_code 过去60min 情况,可以看到403很多
$ tsar --watch 60 --nginx_code
Time ----------------------------------------------------nginx_code--------------------------------------------------
Time 200 206 302 304 403 404 416 499 500 502 503 504 508 dother
16/04/19-15:00 254.05 0.00 2.78 0.00 279.56 0.09 0.00 112.91 0.00 0.00 0.00 0.00 0.00 25.93
16/04/19-15:05 359.30 0.00 6.29 0.01 531.19 0.23 0.00 263.09 0.00 0.00 0.00 0.00 0.00 0.82
16/04/19-15:10 80.11 0.00 6.59 0.00 1.2K 0.14 0.00 0.33 0.00 0.00 0.00 0.00 0.00 0.70
16/04/19-15:15 80.18 0.00 6.96 0.00 1.2K 0.26 0.00 0.30 0.00 0.00 0.00 0.00 0.00 0.69
16/04/19-15:20 105.71 0.00 9.26 0.01 1.1K 0.13 0.00 0.32 0.00 0.00 0.00 0.00 0.00 1.59
其他模块,例如--cpu,--mem,--load,--tcp的使用情况类似。
Modules Enabled:
--percpu Per cpu share (user, system, interrupt, nice, & idle)
--cpu CPU share (user, system, interrupt, nice, & idle)
--mem Physical memory share (active, inactive, cached, free, wired)
--swap swap usage
--tcp TCP traffic (v4)
--udp UDP traffic (v4)
--traffic Net traffic statistics
--io Linux I/O performance
--pcsw Process (task) creation and context switch
--partition Disk and partition usage
--tcpx TCP connection data
--load System Run Queue and load average
References: