使用 cURL 获取站点的各类响应时间 – dns解析时间,响应时间,传输时间
http://zhangrenfang8738.blog.163.com/blog/static/95401881201142711450245/
监控站点首页下载时间:
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的话就是下面的情况,这是在脚本等情况下不需要的信息。
监控首页各项时间指标:
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 秒
使用 cURL 获取站点的各类响应时间 – dns解析时间,响应时间,传输时间等:
Example
1
curl -o /dev/null -s -w %{http_code}:%{http_connect}:%{content_type}:%{time_namelookup}:%{time_redirect}:%{time_pretransfer}:%{time_connect}:%{time_starttransfer}:%{time_total}:%{speed_download} digdeeply.org
这是一个本人博客站点执行 curl 命令的情况。输出通常是 HTML 代码,通过 -o 参数发送到 /dev/null。-s 参数去掉所有状态信息。-w 参数让 curl 输出的计时器的状态信息。
一次http请求中的各个时间段-dns解析,等待服务器响应,获取内容等
一次http请求中的各个时间段-dns解析,等待服务器响应,获取内容等
下边对-w参数做个详细的解释,由我(DigDeeply)翻译。有不对的地方请大家指出。(英文原文:http://curl.haxx.se/docs/manpage.html)
以下是可用的变量名:
-w, --write-out
以下变量会按CURL认为合适的格式输出,输出变量需要按照%{variable_name}的格式,如果需要输出%,double一下即可,即%%,同时,n是换行,r是回车,t是TAB。
url_effective The URL that was fetched last. This is most meaningful if you've told curl to follow location: headers.
filename_effective The ultimate filename that curl writes out to. This is only meaningful if curl is told to write to a file with the --remote-name or --output option. It's most useful in combination with the --remote-header-name option. (Added in 7.25.1)
http_code http状态码,如200成功,301转向,404未找到,500服务器错误等。(The numerical response code that was found in the last retrieved HTTP(S) or FTP(s) transfer. In 7.18.2 the alias response_code was added to show the same info.)
http_connect The numerical code that was found in the last response (from a proxy) to a curl CONNECT request. (Added in 7.12.4)
time_total 总时间,按秒计。精确到小数点后三位。 (The total time, in seconds, that the full operation lasted. The time will be displayed with millisecond resolution.)
time_namelookup DNS解析时间,从请求开始到DNS解析完毕所用时间。(The time, in seconds, it took from the start until the name resolving was completed.)
time_connect 连接时间,从开始到建立TCP连接完成所用时间,包括前边DNS解析时间,如果需要单纯的得到连接时间,用这个time_connect时间减去前边time_namelookup时间。以下同理,不再赘述。(The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.)
time_appconnect 连接建立完成时间,如SSL/SSH等建立连接或者完成三次握手时间。(The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0))
time_pretransfer 从开始到准备传输的时间。(The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.)
time_redirect 重定向时间,包括到最后一次传输前的几次重定向的DNS解析,连接,预传输,传输时间。(The time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3))
time_starttransfer 开始传输时间。在发出请求之后,Web 服务器返回数据的第一个字节所用的时间(The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result.)
size_download 下载大小。(The total amount of bytes that were downloaded.)
size_upload 上传大小。(The total amount of bytes that were uploaded.)
size_header 下载的header的大小(The total amount of bytes of the downloaded headers.)
size_request 请求的大小。(The total amount of bytes that were sent in the HTTP request.)
speed_download 下载速度,单位-字节每秒。(The average download speed that curl measured for the complete download. Bytes per second.)
speed_upload 上传速度,单位-字节每秒。(The average upload speed that curl measured for the complete upload. Bytes per second.)
content_type 就是content-Type,不用多说了,这是一个访问我博客首页返回的结果示例(text/html; charset=UTF-8);(The Content-Type of the requested document, if there was any.)
num_connects Number of new connects made in the recent transfer. (Added in 7.12.3)
num_redirects Number of redirects that were followed in the request. (Added in 7.12.3)
redirect_url When a HTTP request was made without -L to follow redirects, this variable will show the actual URL a redirect would take you to. (Added in 7.18.2)
ftp_entry_path The initial path libcurl ended up in when logging on to the remote FTP server. (Added in 7.15.4)
ssl_verify_result ssl认证结果,返回0表示认证成功。( The result of the SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.19.0))
若多次使用-w参数,按最后一个的格式输出。If this option is used several times, the last one will be used.
转载请注明:来自:DigDeeply’s Blog–使用 cURL 获取站点的各类响应时间 – dns解析时间,响应时间,传输时间
http://7567567.blog.51cto.com/706378/619842
https://fukun.org/archives/05102012.html
使用 cURL 获取站点的各类响应时间 – dns解析时间,响应时间,传输时间的更多相关文章
- curl命令测试网络请求中DNS解析、响应时间
https://blog.csdn.net/dreamer2020/article/details/78152576
- curl测试dns解析时间及tcp连接时间
1.用Linux下的curl命令测量网络请求(分号是分隔符,可以是其他符号): curl -o /dev/null -s -w %{time_connect}:%{time_starttransfer ...
- 如何获取浏览器的DNS解析时间
上一篇博客提到09年初WED团队开发的浏览器环境检测工具时,忘记说这个是aoao同学的创意了.不过没关系,据说他又在秘密规划新版本了,再据说新版要增加的DNS解析时间计算已经开发完成,点上面那个链接就 ...
- 分析DNS解析时间
提高网页的打开速度,一般地我们会选择使用CDN,利用“就近原则”让用户在最短的时间内获取到服务器资源,实际应用当中采用CDN的方式提高网站访问速度的效果也是最明显的.这也就是为什么国外的空间打开速度远 ...
- 解决域名DNS解析的故障
在实际应用过程中可能会遇到DNS解析错误的问题,就是说当我们访问一个域名时无法完成将其解析到IP地址的工作,而直接输入网站IP却可以正常访问,这就是因为DNS解析出现故障造成的.这个现象发生的机率比较 ...
- 如何解决dns解析故障
在实际应用过程中可能会遇到DNS解析错误的问题,就是说当我们访问一个域名时无法完成将其解析到IP地址的工作,而直接输入网站IP却可以正常访问,这就是因为DNS解析出现故障造成的.这个现象发生的机率比较 ...
- DNS解析出现错误故障解决
当DNS解析出现错误,例如把一个域名解析成一个错误的IP地址,或者根本不知道某个域名对应的IP地址是什么时,就无法通过域名访问相应的站点了,这就是DNS解析故障.出现DNS解析故障最大的症状就是访问站 ...
- 踩了个DNS解析的坑,但我还是没想通
hello大家好,我是小楼. 最近踩了个DNS解析的小坑,虽然问题解决了,但排查过程比较曲折,最后还是有一点没有想通,整个过程分享给大家. 背景 最近负责的服务要置换机器.置换机器可能很多小伙伴不知道 ...
- DNS 解析 prefeath
本文将详细介绍DNS预解析prefetch的主要内容 概述 DNS(Domain Name System, 域名系统),是域名和IP地址相互映射的一个分布式数据库.DNS 查询就是将域名转换成 IP ...
随机推荐
- Python_进程、线程及协程
一.Python进程 IO密集型----多线程 计算密集型----多进程 1.单进程 from multiprocessing import Process def foo(i): print('你好 ...
- 一个关于正整数x的约数个数的结论
分析理解:x的每一个约数都是由x的若干个质因数的积构成. 再根据乘法原理,每个质因数Pi的选择可以是0~Ni个,所以上述结论成立.
- Dom之表单提交与默认行为
一.button提交表单 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...
- js下的sleep实现
function sleep(d){ for(var t = Date.now();Date.now() - t <= d;); } sleep(5000); //当前方法暂停5秒
- C#本地时间和GMT(UTC)时间的转换
/// <summary> /// 本地时间转成GMT时间 /// </summary> 4 public static string ToGMTString(DateTime ...
- IOS开发-UI基础-视图
//------------------------------UIWindow--------------------------// 1.UIWindow:是 UIView 的子类,用于管理.协调 ...
- erlang的escript脚本
参考霸爷的博客 测试例子 #!/usr/bin/env escript %%! -smp enable -sname mmcshadow -mnesia debug verbose[/color] m ...
- Win7系统安装Centos7.0双系统(二)
4.6语言选择
- RDA 编译器的搭建
apt-get install subversion apt-get install make atp-get install gcc sudo vim /etc/profile export PAT ...
- 138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point t ...