Skip to content

Instantly share code, notes, and snippets.

@markhuge
Created December 30, 2016 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markhuge/240959d9acc1c637ef609c2a81f16522 to your computer and use it in GitHub Desktop.
Save markhuge/240959d9acc1c637ef609c2a81f16522 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#### StatsD data generator ####
STATSD_PORT=8125
STATSD_HOST=127.0.0.1
METRICS=("someService" "otherService" "foo.bar")
function generate_data {
for metric in "${METRICS[@]}"; do
for i in {1..100}; do
val=$(( ( RANDOM % 100 ) + 1 ))
echo -ne "Generating Metric data... $metric:$val|c"\\r
echo "$metric:$val|c" | nc -w0 -u $STATSD_HOST $STATSD_PORT
done
done
}
printf "\nRunning continuous metric generation. Ctrl+C to stop...\n"
while true; do
generate_data
#Random sleep interval to spread out datapoints
sleep $(((RANDOM % 5) + 1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment