add influxdb reporter

This commit is contained in:
Patrick Stadler 2015-03-14 13:32:26 +01:00
parent a6af168235
commit ffea7022ea
6 changed files with 35 additions and 16 deletions

View File

@ -5,9 +5,9 @@ INTERVAL=1
REPORTER=stdout # TODO: handle multiple reporters
# env
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
# handle opts
opts_spec=":dhvr:"

View File

@ -1,12 +1,5 @@
#!/bin/sh
report () {
local METRIC=$1
local VALUE=$2
local DATE=$(iso_date)
echo "$DATE $METRIC: $VALUE" >> $FILE_LOCATION
}
init () {
if [ -z $FILE_LOCATION ]; then
echo "Missing configuration: \$FILE_LOCATION"
@ -18,6 +11,13 @@ init () {
fi
}
report () {
local METRIC=$1
local VALUE=$2
local DATE=$(iso_date)
echo "$DATE $METRIC: $VALUE" >> $FILE_LOCATION
}
docs () {
echo "Write to a file or named pipe."
echo "\$FILE_LOCATION=$FILE_LOCATION"

19
reporters/influxdb.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/sh
init () {
if [ -z $INFLUXDB_API_ENDPOINT ]; then
echo "Error: influxdb requires \$INFLUXDB_API_ENDPOINT to be set"
exit 1
fi
}
report () {
local METRIC=$1
local VALUE=$2
curl -X POST -d "[{\"name\":\"$METRIC\",\"columns\":[\"value\"],\"points\":[[$VALUE]]}]" $INFLUXDB_API_ENDPOINT
}
docs () {
echo "Send data to InfluxDB."
echo "\$INFLUXDB_API_ENDPOINT="
}

View File

@ -22,8 +22,8 @@ init() {
}
report () {
METRIC=$1
VALUE=$2
local METRIC=$1
local VALUE=$2
curl -s $__keen_io_api_url -H "Content-Type: application/json" \
-d "{\"metric\": \"$METRIC\", \"value\": $VALUE}" > /dev/null
}

View File

@ -8,8 +8,8 @@ init () {
}
report () {
METRIC=$1
VALUE=$2
local METRIC=$1
local VALUE=$2
curl -s -d "stat=$METRIC&ezkey=$STATHAT_API_KEY&value=$VALUE" \
http://api.stathat.com/ez > /dev/null
}

View File

@ -1,8 +1,8 @@
#!/bin/sh
report () {
METRIC=$1
VALUE=$2
local METRIC=$1
local VALUE=$2
echo $METRIC: $VALUE
}