Last active
February 9, 2021 07:42
-
-
Save charz/d4dee6874ebebd4d86fe90b4c4d10cbb to your computer and use it in GitHub Desktop.
curl with xid and time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curlxidheaders() { | |
echo "number,timestamp,status_code,message,size,speed_bytes_per_sec,time_total,time_namelookup,time_connect,time_appconnect,time_pretransfer,time_redirect,time_starttransfer" | |
} | |
curlxid() { | |
curl -w 'code: %{http_code} %{http_connect}|size: %{size_download}|speed: %{speed_download}|total: %{time_total}, %{time_namelookup}, %{time_connect}, %{time_appconnect}, %{time_pretransfer}, %{time_redirect},%{time_starttransfer}' \ | |
-s -o /dev/null -v "$@" 2>&1 | \ | |
grep -E 'X-Trans-Id|total|Date:' | \ | |
tr '\r\n<' '|' | \ | |
awk -F '[|]' '{split($2,x,": "); split($5,d,", "); split($7,c,": "); split($8,s,":"); split($9,p, ":"); split($10,t,":"); print ", "d[2]", "c[2]", X-Trans-Id="x[2]","s[2]","p[2]","t[2]}' | |
} | |
curlxid5() { | |
for _ in {1..4}; | |
do | |
(curlxid "$@" &) 2> /dev/null | |
done | |
(curlxid "$@") 2> /dev/null | |
} | |
curlxid10() { | |
for _ in {1..9}; | |
do | |
(curlxid "$@" &) 2> /dev/null | |
done | |
(curlxid "$@") 2> /dev/null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment