Update influxdb reporter to syntax of 0.9

They completely changed their API.
This commit is contained in:
Michael Weibel 2015-07-29 07:59:44 +02:00
parent 8882f19ab3
commit d5fbece5ae
1 changed files with 4 additions and 12 deletions

View File

@ -13,10 +13,7 @@ start () {
fi
if [ "$INFLUXDB_SEND_HOSTNAME" = true ]; then
__influxdb_columns="[\"value\",\"host\"]"
__influxdb_hostname=$(hostname)
else
__influxdb_columns="[\"value\"]"
__influxdb_hostname="host=$(hostname)"
fi
}
@ -24,17 +21,12 @@ report () {
local metric=$1
local value=$2
local points
if [ "$INFLUXDB_SEND_HOSTNAME" = true ]; then
points="[$value,\"$__influxdb_hostname\"]"
else
points="[$value]"
fi
local data="[{\"name\":\"$metric\",\"columns\":$__influxdb_columns,\"points\":[$points]}]"
curl -s -X POST $INFLUXDB_API_ENDPOINT -d $data
local data="$metric,$__influxdb_hostname value=$value"
curl -s -X POST $INFLUXDB_API_ENDPOINT --data-binary "$data"
}
docs () {
echo "Send data to InfluxDB."
echo "INFLUXDB_API_ENDPOINT=$INFLUXDB_API_ENDPOINT"
echo "INFLUXDB_SEND_HOSTNAME=$INFLUXDB_SEND_HOSTNAME"
}
}