curl监控站点响应时间

来源:互联网 发布:ubuntu terminal 配色 编辑:程序博客网 时间:2024/05/13 09:22

监控站点首页下载时间:

curl -o /dev/null -s -w ‘%{time_total}’ http://www.miotour.com

curl -o /dev/null -s -w ‘%{http_code}’ http://www.miotour.com

curl -o /dev/null -s -w %{http_code}:%{time_connect}:%{time_starttransfer}:%{time_total} http://www.miotour.com

结果:2.547

-s 静默输出;没有-s的话就是下面的情况,这是在脚本等情况下不需要的信息。

[ec2-user@ip-10-122-250-19 ~]$ curl -o/dev/null  -w ‘%{time_total}’http://www.miotour.com
% Total    %Received % Xferd  Average Speed  Time    Time    Time  Current
Dload  Upload  Total   Spent   Left Speed
100 67770   0 67770       0  19228     0 –:–:– 0:00:03 –:–:– 20705
结果:3.524

监控首页各项时间指标:

curl -o /dev/null -s -w ‘%{time_connect}:%{time_starttransfer}:%{time_total}’ http://www.miotour.com

结果:                                         0.244:                        1.044:                     2.672

时间指标解释 :

time_connect    建立到服务器的 TCP连接所用的时间

time_starttransfer   在发出请求之后,Web 服务器返回数据的第一个字节所用的时间

time_total   完成请求所用的时间

在发出请求之后,Web 服务器处理请求并开始发回数据所用的时间是

(time_starttransfer)1.044 -(time_connect)0.244 = 0.8 秒

客户机从服务器下载数据所用的时间是

(time_total)2.672 -(time_starttransfer)1.044 = 1.682 秒

指定特定主机IP地址访问网站

curl -x 61.135.169.105:80 http://www.baidu.com

curl -x 61.135.169.125:80 http://www.baidu.com

 

curl用法大全

-x 指定访问IP与端口号

curl -x 192.168.1.1:80 http://www.miotour.com

-I 仅仅取文件的http头部

curl   -I  -x 192.168.1.1:80 http://www.miotour.com

用referer做的防盗链,就可以使用-e来设置

curl -e “http://www.qiecuo.org”   http:// www.miotour.com -v -I

-H去构造你想要的http头部

curl -H “X-Forward-For:8.8.8.8″ http://www.miotour.com -v  -I

curl反馈时间,例如连接时间,下载时间等信息

curl -w %{time_connect}:%{time_starttransfer}:%{time_total} -s-o /dev/null

将一个文件保存到硬盘上,命名为file.html

curl -o file.html http://www.miotour.com/index.html

下载index.html文件, -O是大写的字母

curl -Ohttp://www.miotour.com/index.html

curl提交用户名和密码

curl http://name:passwd@www.miotour.com
curl -u name:passwd http://www.miotour.com

-b “cookie”此参数用来构造一个携带cookie的请求

USER AGENT 关于浏览器发送的http请求信息. Curl允许用命令制定. 发送一些用于欺骗服务器或cgi的信息.   比如:   curl -A 'Mozilla/3.0 (Win95; I)' http://www.nationsbank.com/   其他命令:     'Mozilla/3.0 (Win95; I)'      Netscape Version 3 for Windows 95     'Mozilla/3.04 (Win95; U)'     Netscape Version 3 for Windows 95     'Mozilla/2.02 (OS/2; U)'      Netscape Version 2 for OS/2     'Mozilla/4.04 [en] (X11; U; AIX 4.2; Nav)'            NS for AIX     'Mozilla/4.05 [en] (X11; U; Linux 2.0.32 i586)'       NS for Linux   注意:Internet Explorer能自动调节:     'Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)'     MSIE for W95   Mozilla 使用User-Agent名字:     'Konqueror/1.0'              KDE File Manager desktop client     'Lynx/2.7.1 libwww-FM/2.14' Lynx command line browser
PROGRESS METER   The progress meter exists to show a user that something actually is   happening. The different fields in the output have the following meaning:   % Total     % Received % Xferd   Average Speed           Time              Curr.                                  Dload   Upload Total     Current   Left     Speed    151M     0 38608           9406        4:41:43   0:00:04   4:41:39   9287   From left-to-right:                - 全部完成的百分比    Total          - 总的字节                - 已完成的百分比    Received       - 已下载的字节                - 上传的百分数    Xferd          - 上传的字节数    Average Speed    Dload          - 下载速度    Average Speed    Upload         - 上传速度    Time Total     - 需要的全部时间    Time Current   - 从下载到现在的时间    Time Left      - 预期需要的时间    Curr.Speed     - 最后5秒的数据需要的时间 (the first                    5 seconds of a transfer is based on less time of course.)
原创粉丝点击