HTTP状态是一个Python3脚本,用于可视化Web curl(1)统计信息。该脚本写在一个没有依赖性的文件中。本文介绍了有关如何使用http统计信息来了解网站的效果
如下所示,有两种方法可以在Ubuntu上安装httpstat:
直接下载脚本。
通过Python点
要从直接脚本安装httpstat,请使用以下命令-
$wget https://raw.githubusercontent.com/reorx/httpstat/master/httpstat.py
样本输出应该像这样-
--2016-12-19 11:27:18-- https://raw.githubusercontent.com/reorx/httpstat/master/httpstat.pyResolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10577 (10K) [text/plain] Saving to: ‘httpstat.py’ httpstat.py 100%[===================>] 10.33K --.-KB/s in 0.02s 2016-12-19 11:27:20 (433 KB/s) - ‘httpstat.py’ saved [10577/10577]
在安装httpstat之前,它应该在Ubuntu上需要一个python-pip软件包。要安装python-pip软件包,请使用以下命令-
$sudo apt install python-pip
样本输出应该像这样-
Building dependency tree Reading state information... Done The following additional packages will be installed: libexpat1-dev libpython-all-dev libpython-dev libpython2.7 libpython2.7-dev libpython2.7-minimal libpython2.7-stdlib python-all python-all-dev python-dev python-pip-whl python-pkg-resources python-setuptools python-wheel python2.7 python2.7-dev python2.7-minimal Suggested packages: python-setuptools-doc python2.7-doc binfmt-support The following NEW packages will be installed: libexpat1-dev libpython-all-dev libpython-dev libpython2.7-dev python-all python-all-dev python-dev python-pip python-pip-whl python-pkg-resources python-setuptools python-wheel python2.7-dev The following packages will be upgraded: libpython2.7 libpython2.7-minimal libpython2.7-stdlib python2.7 python2.7-minimal 5 upgraded, 13 newly installed, 0 to remove and 284 not upgraded. Need to get 29.8 MB/34.6 MB of archives. After this operation, 45.1 MB of additional disk space will be used. ......................................................................................
要安装httpstat,请使用以下命令-
$ pip install httpstat
样本输出应该像这样-
Collecting httpstat Downloading httpstat-1.2.1-py2-none-any.whl Installing collected packages: httpstat Successfully installed httpstat
如果通过直接脚本安装了httpstat,请使用以下命令-
$ python httpstat.py (cainiaojc.com)
样本输出应该像这样-
Connected to 117.18.237.191:80 from 192.168.1.182:58492 HTTP/1.1 200 OK Accept-Ranges: bytes Access-Control-Allow-Headers: X-Requested-With Access-Control-Allow-Origin: * Content-Type: text/html; charset=UTF-8 Date: Mon, 19 Dec 2016 06:09:15 GMT Last-Modified: Mon, 19 Dec 2016 05:20:54 GMT Server: ECS (pnq/AF9C) Vary: Accept-Encoding X-Cache: HIT Content-Length: 92840 Body stored in: /tmp/tmpvwKIfK DNS Lookup TCP Connection Server Processing Content Transfer [ 253ms | 16ms | 15ms | 32ms ] | | | | namelookup:253ms | | | connect:269ms | | starttransfer:284ms | total:316ms
如果您已通过python pip安装了httpstat,请使用以下命令-
$ httpstat sendfiles.net
样本输出应该像这样-
Connected to 115.112.255.70:80 from 192.168.1.182:46878 HTTP/1.1 200 OK Date: Mon, 19 Dec 2016 06:11:59 GMT Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16 X-Powered-By: PHP/5.4.16 Set-Cookie: PHPSESSID=ftvfqeu3gnr05a95hc2donbv16; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: User-Agent Access-Control-Allow-Origin: * Access-Control-Allow-Headers: X-Requested-With Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 Body stored in: /tmp/tmpq7FNyi DNS Lookup TCP Connection Server Processing Content Transfer [ 254ms | 1ms | 6ms | 2ms ] | | | | namelookup:254ms | | | connect:255ms | | starttransfer:261ms | total:263ms
上面的示例给出了(cainiaojc.com)和sendfiles.net的输出。它涉及有关日期,服务器,X-Powered-by-方式,Set-Cookie,变化,内容实质性信息以及许多此类有值的信息的信息,以搜索网页的统计信息。
httpstat中有很多选项,要了解有关httpstat的更多信息,请使用以下命令-
$ httpstat --help
样本输出应该像这样-
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 resposne 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和使用选项的明确信息。本文之后,您将能够了解如何安装httpstat来查找Ubuntu上的网站性能统计信息。在我们的下一篇文章中,我们将提出更多基于Linux的技巧。继续阅读!