Linux 工具命令
使用curl测试网络通信
#!/bin/bash
cnt_pos=1
while true
do
echo "--------------- the $cnt_pos requet ------------"
echo "Start time: "`date +"%Y-%m-%d %H:%M:%S"`
t0=`date +%s`
req_url="https://www.baidu.com"
echo "$req_url"
curl -w "@./curl-cfg.txt" -X get -i --connect-timeout 200 -m 200 "$req_url"
t1=`date +%s`
let s_t2=t1-t0
if [ $s_t2 -gt 3 ]
then
break
fi
let cnt_pos=cnt_pos+1
sleep 1s
done
curl-cfg.txt
remote_ip: %{remote_ip}
remote_port: %{remote_port}
local_ip: %{local_ip}
local_port: %{local_port}
http_code: %{http_code}
dns: %{time_namelookup}s
redirect: %{time_redirect}s
time_connect: %{time_connect}s
time_appconnect: %{time_appconnect}s
time_pretransfer: %{time_pretransfer}s
time_starttransfer: %{time_starttransfer}s
size_download: %{size_download}bytes
speed_download: %{speed_download}B/s
----------
time_total: %{time_total}s