mirror of
https://github.com/pstadler/metrics.sh.git
synced 2025-02-28 13:59:12 -05:00
add influxdb reporter
This commit is contained in:
parent
a6af168235
commit
ffea7022ea
@ -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:"
|
||||
|
@ -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
19
reporters/influxdb.sh
Normal 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="
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
report () {
|
||||
METRIC=$1
|
||||
VALUE=$2
|
||||
local METRIC=$1
|
||||
local VALUE=$2
|
||||
echo $METRIC: $VALUE
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user