天天看點

httpstat:一個檢查網站性能的 curl 統計分析工具

httpstat 是一個 python 腳本,它以美妙妥善的方式反映了 curl 統計分析,它是一個單一腳本,相容 python 3 ,在使用者的系統上不需要安裝額外的軟體(依賴)。

從本質上來說它是一個 curl 工具的封裝,意味着你可以在 url 後使用幾個有效的 curl 選項,但是不包括 -w、 -d、 -o、 -s 和 -s 選項,這些已經被 httpstat 使用了。

httpstat:一個檢查網站性能的 curl 統計分析工具

httpstat curl 統計分析工具

網站或伺服器優化你可以檢視我們的文章:

<a href="http://www.tecmint.com/apache-performance-tuning/">5 個優化 apache web 伺服器性能的技巧</a>

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

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

15 個優化 mysql/mariadb 性能的建議

使用下面安裝說明和用法來擷取 httpstat 檢查出你的網站速度。

在 linux 系統中安裝 httpstat

你可以使用兩種合理的方法安裝 httpstat :

使用 wget 指令直接從它的 github 倉庫擷取如下:

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

使用 pip(這個方法允許 httpstat 作為指令安裝到你的系統中)像這樣:

$ sudo pip install httpstat 

注:確定 pip 包已經在系統上安裝了,如果沒使用你的發行版包管理器 yum 或 apt安裝它。

在 linux 中如何使用 httpstat

httpstat 可以根據你安裝它的方式來使用,如果你直接下載下傳了它,進入下載下傳目錄使用下面的語句運作它:

$ python httpstat.py url curl_options 

如果你使用 pip 來安裝它,你可以作為指令來執行它,如下表:

$ httpstat url curl_options 

檢視 httpstat 幫助頁,指令如下:

$ python httpstat.py --help 

或 

$ httpstat --help 

httpstat 幫助:

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` 

從上面幫助指令的輸出,你可以看出 httpstat 已經具備了一些可以影響其行為的環境變量。

使用它們,隻需輸出适當的值的這些變量到 .bashrc 或 .zshrc 檔案。

例如:

export  httpstat_show_ip=false 

export  httpstat_show_speed=true 

export  httpstat_save_body=false 

export  httpstat_debug=true 

你一旦添加完它們,儲存檔案然後運作下面的指令使改變生效:

$ source ~/.bashrc 

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

$ python httpstat.py google.com 

$ httpstat google.com 

httpstat:一個檢查網站性能的 curl 統計分析工具

httpstat – 展示網站統計分析

接下來的指令中:

-x 指令标記指定一個客戶與 http 伺服器連接配接的請求方法。

--data-urlencode 這個選項将會把資料(這裡是 a=b)按 url 編碼的方式編碼後再送出。

-v 開啟詳細模式。

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

httpstat:一個檢查網站性能的 curl 統計分析工具

httpstat – 定制送出請求

你可以檢視 curl 的幫助擷取更多有用的進階選項,或者浏覽 httpstat 的 github 倉庫

這篇文章中,我們講述了一個有效的工具,它以簡單和整潔方式來檢視 curl 統計分析。如果你知道任何類似的工具,别猶豫,讓我們知道,你也可以問問題或評論這篇文章或 httpstat,通過下面回報。

作者:aaron kili

來源:51cto