-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·55 lines (46 loc) · 2.48 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
# 2013-10-13 by maniac@localhost.sk initial version with rrd
# 2019-03-15 by maniac@localhost.sk version with influx
POWERPLANT_IP=x.x.x.x
INFLUXDB_IP=y.y.y.y
URL="http://$INFLUXDB_IP:8086/write?db=opentsdb"
AUTH="" # authenticate to influx format: -u login:pass ; e.g. AUTH="-u mylogin:mypass"
DELAY=10 # seconds to sleep before next iteration
#######################################################################
while true ; do
X=$(curl -m 10 -s "http://$POWERPLANT_IP/diagnostics/measurements.xml" | sed 's|</.*||g')
if [ $? -eq 0 ] ; then
inputVoltage=$(echo "$X" | sed 's|</.*||g' | grep inputVoltage | sed s/.*\>// )
inputThd=$(echo "$X" | sed 's|</.*||g' | grep inputThd | sed s/.*\>//)
inputFrequency=$(echo "$X" | sed 's|</.*||g' | grep inputFrequency | sed s/.*\>//)
outputVoltage=$(echo "$X" | sed 's|</.*||g' | grep outputVoltage | sed s/.*\>//)
outputThd=$(echo "$X" | sed 's|</.*||g' | grep outputThd | sed s/.*\>//)
outputCurrent=$(echo "$X" | sed 's|</.*||g' | grep outputCurrent | sed s/.*\>//)
outputPower=$(echo "$X" | sed 's|</.*||g' | grep outputPower | sed s/.*\>//)
outputDCOffset=$(echo "$X" | sed 's|</.*||g' | grep outputDCOffset | sed s/.*\>//)
sensorTemp1=$(echo "$X" | sed 's|</.*||g' | grep sensorTemp1 | sed s/.*\>//)
sensorTemp2=$(echo "$X" | sed 's|</.*||g' | grep sensorTemp2 | sed s/.*\>//)
# echo "inputVoltage: $inputVoltage"
# echo "inputThd: $inputThd"
# echo "inputFrequency: $inputFrequency"
# echo "outputVoltage: $outputVoltage"
# echo "outputThd: $outputThd"
# echo "outputCurrent: $outputCurrent"
# echo "outputPower: $outputPower"
# echo "outputDCOffset: $outputDCOffset"
# echo "sensorTemp1: $sensorTemp1"
# echo "sensorTemp2: $sensorTemp2"
fi
DATA='metric=inputVoltage,host=P10 value='"$inputVoltage"
DATA=$DATA$'\nmetric=inputThd,host=P10 value='"$inputThd"
DATA=$DATA$'\nmetric=inputFrequency,host=P10 value='"$inputFrequency"
DATA=$DATA$'\nmetric=outputVoltage,host=P10 value='"$outputVoltage"
DATA=$DATA$'\nmetric=outputThd,host=P10 value='"$outputThd"
DATA=$DATA$'\nmetric=outputCurrent,host=P10 value='"$outputCurrent"
DATA=$DATA$'\nmetric=outputPower,host=P10 value='"$outputPower"
DATA=$DATA$'\nmetric=outputDCOffset,host=P10 value='"$outputDCOffset"
DATA=$DATA$'\nmetric=sensorTemp1,host=P10 value='"$sensorTemp1"
DATA=$DATA$'\nmetric=sensorTemp2,host=P10 value='"$sensorTemp2"
curl $AUTH -X POST --data "$DATA" "$URL"
sleep $DELAY
done