Skip to content

Instantly share code, notes, and snippets.

@index0h
Last active February 28, 2019 09:17
Show Gist options
  • Save index0h/aed9e57b936077d20186e53c011aeac0 to your computer and use it in GitHub Desktop.
Save index0h/aed9e57b936077d20186e53c011aeac0 to your computer and use it in GitHub Desktop.
statsd_feeding.sh
#!/bin/sh
METRIC_NAME='test.metric'
STATSD_HOST='statsd.host'
STATSD_PORT='8125'
DELAY_MCS=100000
# "c" - counter, will aggregate as sum
# "t" - timer, will aggregate as avg
# "g" - gauge, will aggregate as last
AGGREGATION="c"
while true
do
DATA=`date +%S%1N | sed 's/^0*//'`
if [[ -z "${DATA}" ]]; then
DATA="0"
fi
echo "${METRIC_NAME}:${DATA}|${AGGREGATION}" | nc -u -w0 "${STATSD_HOST}" "${STATSD_PORT}"
usleep 100000
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment