-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_query_time_graph.sh
executable file
·80 lines (67 loc) · 1.46 KB
/
http_query_time_graph.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script runs queries to URL and graphs resulting connection and total times.
OPTIONS:
-h Show this message
-x Use this proxy
-g Compress data
-u URL to use
-r How much retries?
EOF
}
PROXY=
GZIP=
URL=
RETRIES=500
while getopts "x:ghu:r:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
x)
PROXY=$OPTARG
;;
g)
GZIP=1
;;
u)
URL=$OPTARG
;;
r)
RETRIES=$OPTARG
;;
?)
usage
exit 1
;;
esac
done
if [[ -z $URL ]]
then
usage
exit 1
fi
if [[ ! -z $PROXY ]]
then
PROXYCMD="-x $PROXY"
fi
if [[ ! -z $GZIP ]]
then
GZIPCMD="-H Content-Encoding:gzip"
fi
# clean data file
> /tmp/datafull
for x in $(seq $RETRIES)
do
echo "query $x of $RETRIES"
curl "$URL" -o /dev/null -w "%{time_connect} %{time_total}\n" -s $GZIPCMD $PROXYCMD >> /tmp/datafull
done
cat /tmp/datafull | awk '{print $1}' > /tmp/connect
cat /tmp/datafull | awk '{print $2}' > /tmp/total
echo "plot '/tmp/connect', '/tmp/total'" > /tmp/gnuplotcmd
gnuplot -p /tmp/gnuplotcmd