You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
756 B
Bash
38 lines
756 B
Bash
#!/bin/bash
|
|
pushd $(dirname ${BASH_SOURCE[0]}) >/dev/null
|
|
|
|
# Include configuration
|
|
source ../.env
|
|
export INFLUX_TOKEN
|
|
|
|
# Include other functions
|
|
source output.sh
|
|
|
|
# Include all sensor scripts
|
|
if [ -d "sensor-scripts" ]; then
|
|
for script in $(ls sensor-scripts/*.sh 2>/dev/null); do
|
|
log "Loading sensor function $(basename ${script} .sh)"
|
|
source "${script}"
|
|
done
|
|
fi
|
|
|
|
# Test if influxdb2 CLI is installed
|
|
if ! which influx >/dev/null; then
|
|
logError "Influx CLI not found!"
|
|
exit 1
|
|
fi
|
|
|
|
# Write data to influx DB
|
|
function writeData {
|
|
MEASURE="$1"
|
|
TAGS="$2"
|
|
FIELDS="$3"
|
|
|
|
influx write \
|
|
-b ${INFLUX_BUCKET} \
|
|
-o ${INFLUX_ORG} \
|
|
-p s \
|
|
"${MEASURE},${TAGS} ${FIELDS}"
|
|
}
|
|
|
|
popd >/dev/null |