You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
709 B

#!/bin/sh
myhost=$(/bin/hostname -f)
CURL="/usr/bin/curl -is -o /dev/null -w \"%{http_code}\\\n\" -u user:password -XPOST 'http://influxdb.url/write?db=jpi' --data-binary "
AWK="/usr/bin/awk"
WC="/usr/bin/wc"
DF="/bin/df -t ext4 "
SED="/bin/sed -e 1d"
CHRONY="/usr/bin/chronyc -nc tracking"
z=$(basename $0)
IAM="${z%.*}"
tmpfile="$FLUXPLUGHOME"/tmp/"$IAM"
datafile="$FLUXPLUGHOME"/data/"$IAM"
MAXLINES=10
sendfile() {
datfile="$1"
echo $CURL" @$datfile"
}
writeline() {
line="$1"
length="$2"
echo "$line" >> "$tmpfile"
lines=$("$WC" -l < "$tmpfile")
if [ "$lines" -ge $length ]; then
mv "$tmpfile" "$datafile"
sendfile "$datafile"
fi
}