自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

httpstat:一個(gè)檢查網(wǎng)站性能的 curl 統(tǒng)計(jì)分析工具

運(yùn)維 系統(tǒng)運(yùn)維
httpstat 是一個(gè) Python 腳本,它以美妙妥善的方式反映了 curl 統(tǒng)計(jì)分析,它是一個(gè)單一腳本,兼容 Python 3 ,在用戶的系統(tǒng)上不需要安裝額外的軟件(依賴)。

httpstat 是一個(gè) Python 腳本,它以美妙妥善的方式反映了 curl 統(tǒng)計(jì)分析,它是一個(gè)單一腳本,兼容 Python 3 ,在用戶的系統(tǒng)上不需要安裝額外的軟件(依賴)。

從本質(zhì)上來說它是一個(gè) cURL 工具的封裝,意味著你可以在 URL 后使用幾個(gè)有效的 cURL 選項(xiàng),但是不包括 -w、 -D、 -o、 -s 和 -S 選項(xiàng),這些已經(jīng)被 httpstat 使用了。

httpstat Curl 統(tǒng)計(jì)分析工具

你可以看到上圖的一個(gè) ASCII 表顯示了每個(gè)過程消耗多長時(shí)間,對(duì)我來說最重要的一步是“服務(wù)器處理server processing” – 如果這個(gè)數(shù)字很高,那么你需要優(yōu)化你網(wǎng)站服務(wù)器來加速訪問速度。

網(wǎng)站或服務(wù)器優(yōu)化你可以查看我們的文章:

  1. 5 個(gè)優(yōu)化 Apache Web 服務(wù)器性能的技巧
  2. 使 Apache 和 Nginx 性能提升 10 倍
  3. 如何使用 Gzip 模塊提高 Nginx 性能
  4. 15 個(gè)優(yōu)化 MySQL/MariaDB 性能的建議

使用下面安裝說明和用法來獲取 httpstat 檢查出你的網(wǎng)站速度。

在 Linux 系統(tǒng)中安裝 httpstat

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

  1. 使用 wget 命令直接從它的 Github 倉庫獲取如下:
  1. $ wget -c https://raw.githubusercontent.com/reorx/httpstat/master/httpstat.py 
  1. 使用 pip(這個(gè)方法允許 httpstat 作為命令安裝到你的系統(tǒng)中)像這樣:
  1. $ sudo pip install httpstat 

注:確保 pip 包已經(jīng)在系統(tǒng)上安裝了,如果沒使用你的發(fā)行版包管理器 yum 或 apt安裝它。

在 Linux 中如何使用 httpstat

httpstat 可以根據(jù)你安裝它的方式來使用,如果你直接下載了它,進(jìn)入下載目錄使用下面的語句運(yùn)行它:

  1. $ python httpstat.py url cURL_options 

如果你使用 pip 來安裝它,你可以作為命令來執(zhí)行它,如下表:

  1. $ httpstat url cURL_options 

查看 httpstat 幫助頁,命令如下:

  1. $ python httpstat.py --help 
  2. 或 
  3. $ httpstat --help 

httpstat 幫助:

  1. Usage: httpstat URL [CURL_OPTIONS] 
  2. httpstat -h | --help 
  3. httpstat --version 
  4. Arguments: 
  5. URL     url to request, could be with or without `http(s)://` prefix 
  6. Options: 
  7. CURL_OPTIONS  any curl supported options, except for -w -D -o -S -s, 
  8. which are already used internally. 
  9. -h --help     show this screen. 
  10. --version     show version. 
  11. Environments: 
  12. HTTPSTAT_SHOW_BODY    Set to `trueto show response body in the output
  13. note that body length is limited to 1023 bytes, will be 
  14. truncated if exceeds. Default is `false`. 
  15. HTTPSTAT_SHOW_IP      By default httpstat shows remote and local IP/port address. 
  16. Set to `falseto disable this feature. Default is `true`. 
  17. HTTPSTAT_SHOW_SPEED   Set to `trueto show download and upload speed. 
  18. Default is `false`. 
  19. HTTPSTAT_SAVE_BODY    By default httpstat stores body in a tmp file, 
  20. set to `falseto disable this feature. Default is `true
  21. HTTPSTAT_CURL_BIN     Indicate the curl bin path to use. Default is `curl` 
  22. from current shell $PATH. 
  23. HTTPSTAT_DEBUG        Set to `trueto see debugging logs. Default is `false

從上面幫助命令的輸出,你可以看出 httpstat 已經(jīng)具備了一些可以影響其行為的環(huán)境變量。

使用它們,只需輸出適當(dāng)?shù)闹档倪@些變量到 .bashrc 或 .zshrc 文件。

例如:

  1. export  HTTPSTAT_SHOW_IP=false 
  2. export  HTTPSTAT_SHOW_SPEED=true 
  3. export  HTTPSTAT_SAVE_BODY=false 
  4. export  HTTPSTAT_DEBUG=true 

你一旦添加完它們,保存文件然后運(yùn)行下面的命令使改變生效:

  1. $ source ~/.bashrc 

你可以指定使用 cURL 執(zhí)行文件的路徑,默認(rèn)使用的是當(dāng)前 shell 的 $PATH 環(huán)境變量。

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

  1. $ python httpstat.py google.com 
  2. 或 
  3. $ httpstat google.com 

httpstat – 展示網(wǎng)站統(tǒng)計(jì)分析

接下來的命令中:

  1. -X 命令標(biāo)記指定一個(gè)客戶與 HTTP 服務(wù)器連接的請(qǐng)求方法。
  2. --data-urlencode 這個(gè)選項(xiàng)將會(huì)把數(shù)據(jù)(這里是 a=b)按 URL 編碼的方式編碼后再提交。
  3. -v 開啟詳細(xì)模式。
  1. $ python httpstat.py httpbin.org/post -X POST --data-urlencode "a=b" -v 

httpstat – 定制提交請(qǐng)求

你可以查看 cURL 的幫助獲取更多有用的高級(jí)選項(xiàng),或者瀏覽 httpstat 的 Github 倉庫: https://github.com/reorx/httpstat

這篇文章中,我們講述了一個(gè)有效的工具,它以簡單和整潔方式來查看 cURL 統(tǒng)計(jì)分析。如果你知道任何類似的工具,別猶豫,讓我們知道,你也可以問問題或評(píng)論這篇文章或 httpstat,通過下面反饋。

責(zé)任編輯:武曉燕 來源: Linux中國
相關(guān)推薦

2024-11-07 11:10:34

Python腳本統(tǒng)計(jì)分析

2010-06-07 17:26:41

Mrtg教程

2022-02-18 12:58:35

go-monitor工具服務(wù)質(zhì)量

2019-09-18 09:05:58

技術(shù)SQLDevOps

2011-05-27 13:56:04

網(wǎng)站流量

2015-08-19 09:40:51

統(tǒng)計(jì)分析

2010-06-01 14:30:06

Mrtg教程

2012-09-25 14:18:51

Linux桌面環(huán)境

2009-06-29 15:25:21

SessionJSP

2014-06-04 09:42:41

工業(yè)控制系統(tǒng)APT

2015-02-27 09:53:06

Countly

2010-12-30 09:44:10

C#Attribute

2016-10-18 14:13:21

數(shù)據(jù)統(tǒng)計(jì)模型

2015-01-05 17:28:02

JMP

2011-03-14 14:41:59

大數(shù)據(jù)數(shù)據(jù)中心

2021-06-10 09:53:04

數(shù)據(jù)統(tǒng)計(jì)統(tǒng)計(jì)分析數(shù)據(jù)

2023-10-25 09:39:46

2013-09-10 14:50:12

數(shù)組面試題

2014-10-28 14:59:42

手游付費(fèi)行為數(shù)據(jù)統(tǒng)計(jì)分析

2013-03-26 14:08:04

APP精細(xì)化友盟統(tǒng)計(jì)分析3.0
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)