- 打印dns解析时间,响应时间,传输时间等
curl -o /dev/null -s -w 'http_code:%{http_code}| http_connect:%{http_connect}| time_namelookup:%{time_namelookup}| time_connect:%{time_connect}| time_pretransfer:%{time_pretransfer}| time_starttransfer:%{time_starttransfer}| time_total:%{time_total}| size_download:%{size_download}| speed_download:%{speed_download}' www.baidu.com
curl -o /dev/null -s -w '状态码:%{http_code}| http连接耗时:%{http_connect}| 域名解释耗时:%{time_namelookup}| 连接耗时:%{time_connect}| 预传输耗时:%{time_pretransfer}| 开始传输耗时:%{time_starttransfer}| 总耗时:%{time_total}| 下载大小:%{size_download}| 下载速度:%{speed_download}' www.baidu.com
curl -o /dev/null --connect-timeout 10 -m 10 -N -s -w 'Http_code %{http_code}\nhttp_connect %{http_connect}\nDnslookup_time %{time_namelookup}\nConnect_time %{time_connect}\nPretransfer_time %{time_pretransfer}\nStarttransfer_time %{time_starttransfer}\nTotal_time %{time_total}\nDownload_size %{size_download}\nDownload_speed %{speed_download}\n' www.baidu.com
Http_code 200
http_connect 000
Dnslookup_time 0.014
Connect_time 0.021
Pretransfer_time 0.021
Starttransfer_time 0.029
Total_time 0.029
Download_size 2381
Download_speed 81038.000
- 使用curl访问unix-socket
例如 ingress-nginx 的监听地址为 unix:/tmp/nginx-status-server.sock 。
server {
listen unix:/tmp/nginx-status-server.sock;
set $proxy_upstream_name "internal";
keepalive_timeout 0;
gzip off;
access_log off;
location /healthz {
return 200;
}
location /nginx_status {
stub_status on;
}
... 省略...
}
用 curl 访问它的 Unix Socket 的方法如下:
curl --unix-socket /tmp/nginx-status-server.sock http://localhost/nginx_status
Active connections: 77
server accepts handled requests
64273 64273 971368
Reading: 0 Writing: 12 Waiting: 65
curl 在7.21以后才支持SNI访问
curl -vik --resolve dc.gdgov.cn:443:127.0.0.1 https://dc.gdgov.cn