move own scripts to own directory
authorChristian Weiske <cweiske@cweiske.de>
Sat, 5 Feb 2011 11:57:28 +0000 (12:57 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Sat, 5 Feb 2011 11:57:28 +0000 (12:57 +0100)
own/README [new file with mode: 0644]
own/create-rdd.sh [new file with mode: 0644]
own/lines-to-stdout.php [new file with mode: 0644]
own/multilinefile [new file with mode: 0644]
own/temperature.rrd [new file with mode: 0644]
own/work-with-lines.sh [new file with mode: 0755]

diff --git a/own/README b/own/README
new file mode 100644 (file)
index 0000000..6cf6757
--- /dev/null
@@ -0,0 +1,36 @@
+usb-wde1 tools
+--------------
+Tools to collect and analyze data from the USB-WDE1 weather receiver from ELV.de
+
+
+idea
+----
+1. pipe each received line to a command
+2. command splits up line into variables
+3. add variable data to rrdtool
+4. repeat
+
+
+idea: cat socat output to "read"
+
+
+
+Test it:
+$ php lines-to-stdout.php | ./work-with-lines.sh
+
+
+
+
+RRDtool database setup
+----------------------
+EXAMPLE
+        rrdtool create temperature.rrd --step 300 \
+         DS:temp:GAUGE:600:-273:5000 \
+         RRA:AVERAGE:0.5:1:1200 \
+         RRA:MIN:0.5:12:2400 \
+         RRA:MAX:0.5:12:2400 \
+         RRA:AVERAGE:0.5:12:2400
+
+ This sets up an RRD called temperature.rrd which accepts one temperature value every 300 seconds. If no new data is supplied for more than 600 seconds, the temperature becomes *UNKNOWN*.  The minimum acceptable value is -273 and the maximum is 5'000.
+
+ A few archive areas are also defined. The first stores the temperatures supplied for 100 hours (1'200 * 300 seconds = 100 hours). The second RRA stores the minimum temperature recorded over every hour (12 * 300 seconds = 1 hour), for 100 days (2'400 hours). The third and the fourth RRA's do the same for the maximum and average temperature, respectively.
diff --git a/own/create-rdd.sh b/own/create-rdd.sh
new file mode 100644 (file)
index 0000000..78f11b8
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+# data will be collected ~ every 3 minutes (150s)
+# after 600s (10min) data are "unknown"
+# archives:
+# - store avg temperature on every data point for 1day (576*150s)
+#
+# - store avg temperature every 10 minutes for 1 week (6*24*7 = 1008)
+# - store min temperature -"-
+# - store max temperature -"-
+#
+# - store avg temperature every day for 10 years
+
+for i in 1..8
+rrdtool create sensor-$1.rrd --step 150 \
+ DS:temp:GAUGE:600:-273:5000 \
+ DS:humidity:GAUGE:600:0:100 \
+ RRA:AVERAGE:0.5:1:576 \
+ RRA:AVERAGE:0.5:4:1008 \
+ RRA:MIN:0.5:4:1008 \
+ RRA:MAX:0.5:4:1008 \
+ RRA:AVERAGE:0.5:576:3650
diff --git a/own/lines-to-stdout.php b/own/lines-to-stdout.php
new file mode 100644 (file)
index 0000000..eb6b39d
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+
+$n = 0;
+while ($n < 4) {
+    echo $n++ . ';col2;col3;col4' . "\n";
+    sleep(1);
+}
+
+?>
\ No newline at end of file
diff --git a/own/multilinefile b/own/multilinefile
new file mode 100644 (file)
index 0000000..00c077e
--- /dev/null
@@ -0,0 +1,6 @@
+line1
+line2
+line3
+a
+b
+c
diff --git a/own/temperature.rrd b/own/temperature.rrd
new file mode 100644 (file)
index 0000000..780429c
Binary files /dev/null and b/own/temperature.rrd differ
diff --git a/own/work-with-lines.sh b/own/work-with-lines.sh
new file mode 100755 (executable)
index 0000000..9e52c9d
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#split words by semicolons
+IFS=";"
+
+#Beispielausgabe USB-WDE1:
+# $1;1;;13,8;22,7;22,6;17,8;22,2;21,2;22,9;;59;35;38;49;38;40;35;;;;;;;0
+# Doku des Formats in 92030_USB_WDE1_V1.0_UM.pdf bei elv.de verfügbar
+
+#Variablenamen:
+# t1-t8: Temperatur in °C der Sensoren 1-8
+# f1-f8: Feuchtegrad in % der Sensoren 1-8
+# tc:    Temperatur Kombinsensor in °C
+# fc:    Feuchtegrad Kombinsensor in %
+# wg:    Windgeschwindigkeit in km/h
+# ns:    Niederschlag (Wippenschläge)
+# regen: Regen 1=ja, 0=nein
+while read -r startzeichen zustand zeitstempel\
+              t1 t2 t3 t4 t5 t6 t7 t8\
+              f1 f2 f3 f4 f5 f6 f7 f8\
+              tc fc wg ns regen
+do
+    echo "line:"
+    echo 1: $one , 2: $two, 3: $three, 4: $four
+done
+echo "done with everything"