metrics.sh/reporters/influxdb.sh

32 lines
678 B
Bash
Raw Normal View History

2015-03-14 08:32:26 -04:00
#!/bin/sh
defaults () {
if [ -z $INFLUXDB_SEND_HOSTNAME ]; then
INFLUXDB_SEND_HOSTNAME=true
fi
}
start () {
2015-03-14 08:32:26 -04:00
if [ -z $INFLUXDB_API_ENDPOINT ]; then
echo "Error: influxdb requires \$INFLUXDB_API_ENDPOINT to be specified"
2015-03-22 13:01:27 -04:00
return 1
2015-03-14 08:32:26 -04:00
fi
if [ "$INFLUXDB_SEND_HOSTNAME" = true ]; then
__influxdb_hostname="host=$(hostname)"
fi
2015-03-14 08:32:26 -04:00
}
report () {
local metric=$1
local value=$2
local data="$metric,$__influxdb_hostname value=$value"
curl -s -X POST $INFLUXDB_API_ENDPOINT --data-binary "$data"
2015-03-14 08:32:26 -04:00
}
docs () {
echo "Send data to InfluxDB."
echo "INFLUXDB_API_ENDPOINT=$INFLUXDB_API_ENDPOINT"
echo "INFLUXDB_SEND_HOSTNAME=$INFLUXDB_SEND_HOSTNAME"
}