httpstat 是一个 Python 脚本,它以美妙妥善的方式反映了 curl 统计分析,它是一个单一脚本,兼容 Python 3 ,在用户的系统上不需要安装额外的软件(依赖)。
从本质上来说它是一个 cURL 工具的封装,意味着你可以在 URL 后使用几个有效的 cURL 选项,但是不包括-w
、 -D
、 -o
、 -s
和 -S
选项,这些已经被 httpstat 使用了。
安装:
wget -c https://raw.githubusercontent.com/reorx/httpstat/master/httpstat.py
or
pip install httpstat
python httpstat.py
Usage: httpstat URL [CURL_OPTIONS]
httpstat -h | --help
httpstat --version
Arguments:
URL url to request, could be with or without `http(s)://` prefix
Options:
CURL_OPTIONS any curl supported options, except for -w -D -o -S -s,
which are already used internally.
-h --help show this screen.
--version show version.
Environments:
HTTPSTAT_SHOW_BODY Set to `true` to show response 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`
python httpstat.py https://blog.geekyu.cn
Connected to 47.99.104.222:443 from 10.0.0.87:55948
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 25 Sep 2018 08:31:34 GMT
Content-Type: text/html
Content-Length: 9852
Last-Modified: Fri, 21 Sep 2018 07:21:24 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "5ba49bf4-267c"
Accept-Ranges: bytes
Body stored in: /tmp/tmpGu2f2A
DNS Lookup TCP Connection TLS Handshake Server Processing Content Transfer
[ 66ms | 48ms | 186ms | 37ms | 0ms ]
| | | | |
namelookup:66ms | | | |
connect:114ms | | |
pretransfer:300ms | |
starttransfer:337ms |
total:337ms
主要关注一下Server Processing ,如果该值过大,就要优化你网站服务器来加速访问速度。