3 # set the host to connect to
8 host="http://127.0.0.1:19999"
10 echo "using netdata server at: $host"
12 charts=($(curl "$host/netdata.conf" 2>/dev/null | grep "^\[" | cut -d '[' -f 2 | cut -d ']' -f 1 | grep -v ^global$ | grep -v "^plugin" | sort -u))
13 if [ "${#charts[@]}" -eq 0 ]
15 echo "Cannot download charts from server: $host"
19 update_every="$(curl "$host/netdata.conf" 2>/dev/null | grep "update every = " | head -n 1 | cut -d '=' -f 2)"
20 [ $(( update_every + 1 - 1)) -eq 0 ] && update_every=1
22 entries="$(curl "$host/netdata.conf" 2>/dev/null | grep "history = " | head -n 1 | cut -d '=' -f 2)"
23 [ $(( entries + 1 - 1)) -eq 0 ] && entries=3600
25 # to compare equal things, set the entries to 3600 max
26 [ $entries -gt 3600 ] && entries=3600
28 if [ $entries -ne 3600 ]
30 echo >&2 "You are running a test for a history of $entries entries."
33 modes=("average" "max")
34 formats=("jsonp" "json" "ssv" "csv" "datatable" "datasource" "tsv" "ssvcomma" "html" "array")
35 options="flip|jsonwrap"
38 first=$((now - (entries * update_every)))
39 duration=$((now - first))
41 file="$(mktemp /tmp/netdata-stress-XXXXXXXX)"
44 [ -f $file ] && rm $file
50 echo "curl --compressed --keepalive-time 120 --header \"Connection: keep-alive\" \\" >$file
53 dt=$((RANDOM * duration / 32767))
54 st=$((RANDOM * duration / 32767))
56 [ $et -gt $now ] && st=$(( now - dt ))
58 points=$((RANDOM * 2000 / 32767 + 2))
62 mode=$((RANDOM * ${#modes[@]} / 32767))
63 mode="${modes[$mode]}"
65 chart=$((RANDOM * ${#charts[@]} / 32767))
66 chart="${charts[$chart]}"
68 format=$((RANDOM * ${#formats[@]} / 32767))
69 format="${formats[$format]}"
71 echo "--url \"$host/api/v1/data?chart=$chart&mode=$mode&format=$format&options=$options&after=$st&before=$et&points=$points\" \\"