直接上图↓

curl命令还能这样用?_curl

图1

 

上面的命令,可以查看http请求各个环节的耗时情况,能够帮助我们排查和定位问题。

 

要实现上图的输出效果,需要将下面格式化文本提前准备好。

curl命令还能这样用?_curl_02

图2

有的朋友可能好奇,图1的命令为什么要加-o /dev/null?不加的话,会把响应也显示出来,看起来不够美观了~

curl命令还能这样用?_curl_03

 

那图1为啥还要加-s命令呢?如果不加的话,会显示下面的进度条信息↓

curl命令还能这样用?_curl_04

 

 

这个命令对于计算机网络学的好的同学来说,简直就是神器了,https://curl.haxx.se/docs/manpage.html这里面,搜索-w,可以看到完整的参数,大家可以根据需求,添加到curl-time.txt文本中~,下面截取部分内容,供大家参考。

http_code 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)

http_version The http version that was effectively used. (Added in 7.50.0)

 

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)

 

 

得到http请求各个环节的耗时情况,就可以定位瓶颈所在,展开进一步的排查和优化了~

 

预告一下,下篇文章将会给大家介绍下时序数据库openTSDB,敬请期待~