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 modes=("average" "max")
26 formats=("jsonp" "json" "ssv" "csv" "datatable" "datasource" "tsv" "ssvcomma" "html" "array")
27 options="flip|jsonwrap"
30 first=$[now - (entries * update_every)]
31 duration=$[now - first]
33 file="$(mktemp /tmp/netdata-stress-XXXXXXXX)"
36 [ -f $file ] && rm $file
42 echo "curl --compressed --keepalive-time 120 --header \"Connection: keep-alive\" \\" >$file
45 dt=$[RANDOM * duration / 32767]
46 st=$[RANDOM * duration / 32767]
48 [ $et -gt $now ] && st=$[ now - dt ]
50 points=$[RANDOM * 2000 / 32767 + 2]
54 mode=$[RANDOM * ${#modes[@]} / 32767]
55 mode="${modes[$mode]}"
57 chart=$[RANDOM * ${#charts[@]} / 32767]
58 chart="${charts[$chart]}"
60 format=$[RANDOM * ${#formats[@]} / 32767]
61 format="${formats[$format]}"
63 echo "--url \"$host/api/v1/data?chart=$chart&mode=$mode&format=$format&options=$options&after=$st&before=$et&points=$points\" \\"