概述
这个工具可以收集一些网站的基础信息,而且它使用ascii字符的方式显示网站各种连接的时间,方便我们根据这个去优化网站,从而提高网站的连接响应速度。
安装
安装很简单,使用pip就可以完成pip install httpstat
使用
一般来说都是httpstat加上你的网站名字,比如
~ httpstat http://www.baidu.com/
Connected to 183.232.231.173:80 from 192.168.1.105:56032
HTTP/1.1 200 OK
Server: bfe/1.0.8.18
Date: Sat, 13 Jan 2018 03:15:13 GMT
Content-Type: text/html
Content-Length: 2381
Last-Modified: Mon, 23 Jan 2017 13:28:12 GMT
Connection: Keep-Alive
ETag: "588604ec-94d"
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Pragma: no-cache
Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
Accept-Ranges: bytes
Body stored in: /tmp/tmpeflrdk2d
DNS Lookup TCP Connection Server Processing Content Transfer
[ 12ms | 37ms | 38ms | 0ms ]
| | | |
namelookup:12ms | | |
connect:49ms | |
starttransfer:88ms |
total:88ms
上面显示了dns查找花了12ms,tcp连接花了37ms,服务器处理用了38ms,内容传输花了0ms,而且可以看到服务器的类型等等,这个工具还可以设置环境变量来控制显示的信息
Environments:
HTTPSTAT_SHOW_BODY Set to `true` to show resposne body in the output,
note that body length is limited to 1023 bytes, will be
truncated if exceeds. Default is `false`.
HTTPSTAT_SHOW_IP By default httpstat shows remote and local IP/port address.
Set to `false` to disable this feature. Default is `true`.
HTTPSTAT_SHOW_SPEED Set to `true` to show download and upload speed.
Default is `false`.
HTTPSTAT_SAVE_BODY By default httpstat stores body in a tmp file,
set to `false` to disable this feature. Default is `true`
HTTPSTAT_CURL_BIN Indicate the curl bin path to use. Default is `curl`
from current shell $PATH.
HTTPSTAT_DEBUG Set to `true` to see debugging logs. Default is `false`
如果你要临时让这个工具不显示比如网站的ip,只要在终端输入export HTTPSTAT_SHOW_IP=false
之后你就不会看到ip了,和第一次输出你可以对比一下
~ httpstat http://www.baidu.com/
HTTP/1.1 200 OK
Server: bfe/1.0.8.18
Date: Sat, 13 Jan 2018 03:22:15 GMT
Content-Type: text/html
Content-Length: 2381
Last-Modified: Mon, 23 Jan 2017 13:28:12 GMT
Connection: Keep-Alive
ETag: "588604ec-94d"
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Pragma: no-cache
Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
Accept-Ranges: bytes
Body stored in: /tmp/tmpf3fiqj62
DNS Lookup TCP Connection Server Processing Content Transfer
[ 12ms | 38ms | 38ms | 0ms ]
| | | |
namelookup:12ms | | |
connect:50ms | |
starttransfer:88ms |
total:88ms
其实这个工具是对curl的封装,所以有的curl参数对这个工具也是适用的
欢迎关注Bboysoul的博客www.bboysoul.com
Have Fun