mirror of
https://github.com/pstadler/metrics.sh.git
synced 2025-11-12 23:01:37 -05:00
add StatsD reporter
This commit is contained in:
29
reporters/statsd.sh
Normal file
29
reporters/statsd.sh
Normal 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"
|
||||
}
|
||||
Reference in New Issue
Block a user