mirror of
https://github.com/pstadler/metrics.sh.git
synced 2025-02-28 22:09:11 -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
|
REPORTER=stdout # TODO: handle multiple reporters
|
||||||
|
|
||||||
# env
|
# env
|
||||||
export LC_ALL=en_US.UTF-8
|
LC_ALL=en_US.UTF-8
|
||||||
export LANG=en_US.UTF-8
|
LANG=en_US.UTF-8
|
||||||
export LANGUAGE=en_US.UTF-8
|
LANGUAGE=en_US.UTF-8
|
||||||
|
|
||||||
# handle opts
|
# handle opts
|
||||||
opts_spec=":dhvr:"
|
opts_spec=":dhvr:"
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
report () {
|
|
||||||
local METRIC=$1
|
|
||||||
local VALUE=$2
|
|
||||||
local DATE=$(iso_date)
|
|
||||||
echo "$DATE $METRIC: $VALUE" >> $FILE_LOCATION
|
|
||||||
}
|
|
||||||
|
|
||||||
init () {
|
init () {
|
||||||
if [ -z $FILE_LOCATION ]; then
|
if [ -z $FILE_LOCATION ]; then
|
||||||
echo "Missing configuration: \$FILE_LOCATION"
|
echo "Missing configuration: \$FILE_LOCATION"
|
||||||
@ -18,6 +11,13 @@ init () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report () {
|
||||||
|
local METRIC=$1
|
||||||
|
local VALUE=$2
|
||||||
|
local DATE=$(iso_date)
|
||||||
|
echo "$DATE $METRIC: $VALUE" >> $FILE_LOCATION
|
||||||
|
}
|
||||||
|
|
||||||
docs () {
|
docs () {
|
||||||
echo "Write to a file or named pipe."
|
echo "Write to a file or named pipe."
|
||||||
echo "\$FILE_LOCATION=$FILE_LOCATION"
|
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 () {
|
report () {
|
||||||
METRIC=$1
|
local METRIC=$1
|
||||||
VALUE=$2
|
local VALUE=$2
|
||||||
curl -s $__keen_io_api_url -H "Content-Type: application/json" \
|
curl -s $__keen_io_api_url -H "Content-Type: application/json" \
|
||||||
-d "{\"metric\": \"$METRIC\", \"value\": $VALUE}" > /dev/null
|
-d "{\"metric\": \"$METRIC\", \"value\": $VALUE}" > /dev/null
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ init () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
report () {
|
report () {
|
||||||
METRIC=$1
|
local METRIC=$1
|
||||||
VALUE=$2
|
local VALUE=$2
|
||||||
curl -s -d "stat=$METRIC&ezkey=$STATHAT_API_KEY&value=$VALUE" \
|
curl -s -d "stat=$METRIC&ezkey=$STATHAT_API_KEY&value=$VALUE" \
|
||||||
http://api.stathat.com/ez > /dev/null
|
http://api.stathat.com/ez > /dev/null
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
report () {
|
report () {
|
||||||
METRIC=$1
|
local METRIC=$1
|
||||||
VALUE=$2
|
local VALUE=$2
|
||||||
echo $METRIC: $VALUE
|
echo $METRIC: $VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user