天天看点

httpstat:一个检查网站性能的 curl 统计分析工具

httpstat 是一个 python 脚本,它以美妙妥善的方式反映了 curl 统计分析,它是一个单一脚本,兼容 python 3 ,在用户的系统上不需要安装额外的软件(依赖)。

从本质上来说它是一个 curl 工具的封装,意味着你可以在 url 后使用几个有效的 curl 选项,但是不包括 <code>-w</code>、 <code>-d</code>、 <code>-o</code>、 <code>-s</code> 和 <code>-s</code> 选项,这些已经被 httpstat 使用了。

httpstat:一个检查网站性能的 curl 统计分析工具

httpstat curl 统计分析工具

网站或服务器优化你可以查看我们的文章:

<a href="http://www.tecmint.com/apache-performance-tuning/" target="_blank">5 个优化 apache web 服务器性能的技巧</a>

<a href="http://www.tecmint.com/install-mod_pagespeed-to-boost-apache-nginx-performance/" target="_blank">使 apache 和 nginx 性能提升 10 倍</a>

<a href="http://www.tecmint.com/increase-nginx-performance-enable-gzip-compression-module/" target="_blank">如何使用 gzip 模块提高 nginx 性能</a>

<a href="https://linux.cn/article-5730-1.html">15 个优化 mysql/mariadb 性能的建议</a>

使用下面安装说明和用法来获取 httpstat 检查出你的网站速度。

<a target="_blank"></a>

你可以使用两种合理的方法安装 httpstat :

<code>$ wget -c https://raw.githubusercontent.com/reorx/httpstat/master/httpstat.py</code>

使用 <code>pip</code>(这个方法允许 httpstat 作为命令安装到你的系统中)像这样:

<code>$ sudo pip install httpstat</code>

<code>httpstat</code> 可以根据你安装它的方式来使用,如果你直接下载了它,进入下载目录使用下面的语句运行它:

<code>$ python httpstat.py url curl_options</code>

如果你使用 <code>pip</code> 来安装它,你可以作为命令来执行它,如下表:

<code>$ httpstat url curl_options</code>

查看 <code>httpstat</code> 帮助页,命令如下:

<code>$ python httpstat.py --help</code>

<code>或</code>

<code>$ httpstat --help</code>

<code>httpstat</code> 帮助:

<code>usage: httpstat url [curl_options]</code>

<code>httpstat -h | --help</code>

<code>httpstat --version</code>

<code>arguments:</code>

<code>url url to request, could be with or without `http(s)://` prefix</code>

<code>options:</code>

<code>curl_options any curl supported options, except for -w -d -o -s -s,</code>

<code>which are already used internally.</code>

<code>-h --help show this screen.</code>

<code>--version show version.</code>

<code>environments:</code>

<code>httpstat_show_body set to `true` to show response body in the output,</code>

<code>note that body length is limited to 1023 bytes, will be</code>

<code>truncated if exceeds. default is `false`.</code>

<code>httpstat_show_ip by default httpstat shows remote and local ip/port address.</code>

<code>set to `false` to disable this feature. default is `true`.</code>

<code>httpstat_show_speed set to `true` to show download and upload speed.</code>

<code>default is `false`.</code>

<code>httpstat_save_body by default httpstat stores body in a tmp file,</code>

<code>set to `false` to disable this feature. default is `true`</code>

<code>httpstat_curl_bin indicate the curl bin path to use. default is `curl`</code>

<code>from current shell $path.</code>

<code>httpstat_debug set to `true` to see debugging logs. default is `false`</code>

从上面帮助命令的输出,你可以看出 <code>httpstat</code> 已经具备了一些可以影响其行为的环境变量。

使用它们,只需输出适当的值的这些变量到 <code>.bashrc</code> 或 <code>.zshrc</code> 文件。

例如:

<code>export httpstat_show_ip=false</code>

<code>export httpstat_show_speed=true</code>

<code>export httpstat_save_body=false</code>

<code>export httpstat_debug=true</code>

你一旦添加完它们,保存文件然后运行下面的命令使改变生效:

下面是一些展示 <code>httpstat</code> 如何工作的例子。

<code>$ python httpstat.py google.com</code>

<code>$ httpstat google.com</code>

httpstat:一个检查网站性能的 curl 统计分析工具

httpstat – 展示网站统计分析

接下来的命令中:

<code>-x</code> 命令标记指定一个客户与 http 服务器连接的请求方法。

<code>--data-urlencode</code> 这个选项将会把数据(这里是 a=b)按 url 编码的方式编码后再提交。

<code>-v</code> 开启详细模式。

<code>$ python httpstat.py httpbin.org/post -x post --data-urlencode "a=b" -v</code>

httpstat:一个检查网站性能的 curl 统计分析工具

httpstat – 定制提交请求

原文发布时间为:2017-12-16

本文来自云栖社区合作伙伴“linux中国”