mirror of
https://github.com/pstadler/metrics.sh.git
synced 2025-07-13 02:51:03 -04:00
influxdb now sends hostname per default
This commit is contained in:
parent
e97e43c90e
commit
1d30530199
@ -5,16 +5,32 @@ init () {
|
|||||||
echo "Error: influxdb requires \$INFLUXDB_API_ENDPOINT to be set"
|
echo "Error: influxdb requires \$INFLUXDB_API_ENDPOINT to be set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z $INFLUXDB_SEND_HOSTNAME ]; then
|
||||||
|
INFLUXDB_SEND_HOSTNAME=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$INFLUXDB_SEND_HOSTNAME" = true ]; then
|
||||||
|
__influxdb_columns="[\"value\",\"host\"]"
|
||||||
|
else
|
||||||
|
__influxdb_columns="[\"value\"]"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
report () {
|
report () {
|
||||||
local METRIC=$1
|
local METRIC=$1
|
||||||
local VALUE=$2
|
local VALUE=$2
|
||||||
|
if [ "$INFLUXDB_SEND_HOSTNAME" = true ]; then
|
||||||
|
local POINTS="[$VALUE,\"$HOSTNAME\"]"
|
||||||
|
else
|
||||||
|
local POINTS="[$VALUE]"
|
||||||
|
fi
|
||||||
curl -X POST $INFLUXDB_API_ENDPOINT \
|
curl -X POST $INFLUXDB_API_ENDPOINT \
|
||||||
-d "[{\"name\":\"$METRIC\",\"columns\":[\"value\"],\"points\":[[$VALUE]]}]"
|
-d "[{\"name\":\"$METRIC\",\"columns\":$__influxdb_columns,\"points\":[$POINTS]}]"
|
||||||
}
|
}
|
||||||
|
|
||||||
docs () {
|
docs () {
|
||||||
echo "Send data to InfluxDB."
|
echo "Send data to InfluxDB."
|
||||||
echo "\$INFLUXDB_API_ENDPOINT="
|
echo "\$INFLUXDB_API_ENDPOINT="
|
||||||
|
echo "\$INFLUXDB_SEND_HOSTNAME=$INFLUXDB_SEND_HOSTNAME"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user