add generic UDP reporter
This commit is contained in:
parent
a0f29e6106
commit
129ece3e0b
|
@ -63,6 +63,7 @@ Reporter | Description
|
|||
--------------- | -------------
|
||||
`stdout` | Write to standard out (default)
|
||||
`file` | Write to a file or named pipe
|
||||
`udp` | Send data to any service via UDP
|
||||
`statsd` | Send data to [StatsD](https://github.com/etsy/statsd)
|
||||
`influxdb` | Send data to [InfluxDB](http://influxdb.com/)
|
||||
`prometheus` | Provide HTTP endpoint for [Prometheus](http://prometheus.io/)
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
|
||||
defaults () {
|
||||
if [ -z $UDP_HOST ]; then
|
||||
UDP_HOST="127.0.0.1"
|
||||
fi
|
||||
if [ -z $UDP_DELIMITER ]; then
|
||||
UDP_DELIMITER="="
|
||||
fi
|
||||
}
|
||||
|
||||
start () {
|
||||
if [ -z $UDP_PORT ]; then
|
||||
echo "Error: udp requires \$UDP_PORT to be specified"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -n "$UDP_PREFIX" ]; then
|
||||
prefix="$UDP_PREFIX."
|
||||
fi
|
||||
if [ -n "$UDP_DELIMITER" ]; then
|
||||
delimiter="$UDP_DELIMITER"
|
||||
fi
|
||||
}
|
||||
|
||||
report () {
|
||||
local metric=$1
|
||||
local value=$2
|
||||
echo "$prefix$metric$delimiter$value" | nc -u -w0 $UDP_HOST $UDP_PORT
|
||||
}
|
||||
|
||||
docs () {
|
||||
echo "Send data to any service using UDP."
|
||||
echo "UDP_HOST=$UDP_HOST"
|
||||
echo "UDP_PORT=$UDP_PORT"
|
||||
echo "UDP_PREFIX=$UDP_PREFIX"
|
||||
echo "UDP_DELIMITER=\"$UDP_DELIMITER\""
|
||||
}
|
Loading…
Reference in New Issue