add StatsD reporter

This commit is contained in:
Patrick Stadler 2015-03-22 18:45:26 +01:00
parent ab6e30e0c2
commit 0ac6466912
2 changed files with 30 additions and 1 deletions

View File

@ -51,6 +51,7 @@ Reporter | Description
--------------- | -------------
`stdout` | Write to standard out (default)
`file` | Write to a file or named pipe
`statsd` | Send data to [Statsd](https://github.com/etsy/statsd)
`influxdb` | Send data to [InfluxDB](http://influxdb.com/)
`keen_io` | Send data to [Keen IO](https://keen.io)
`stathat` | Send data to [StatHat](https://www.stathat.com)
@ -250,5 +251,4 @@ docs () {
## Roadmap
- Test and improve init.d script and write docs for it
- Implement StatsD reporter
- Tests

29
reporters/statsd.sh Normal file
View File

@ -0,0 +1,29 @@
#!/bin/sh
defaults () {
if [ -z $STATSD_HOST ]; then
STATSD_HOST="127.0.0.1"
fi
if [ -z $STATSD_PORT ]; then
STATSD_PORT=8125
fi
}
start () {
if [ -n "$STATSD_PREFIX" ]; then
prefix="$STATSD_PREFIX."
fi
}
report () {
local metric=$1
local value=$2
echo "$prefix$metric:$value|g" | nc -u -w0 $STATSD_HOST $STATSD_PORT
}
docs () {
echo "Send data to StatsD using the gauges metric type."
echo "STATSD_HOST=$STATSD_HOST"
echo "STATSD_PORT=$STATSD_PORT"
echo "STATSD_PREFIX=$STATSD_PREFIX"
}