天天看點

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中國”