integrate dummy data generator, check for readability of usb device, use full path...
authorChristian Weiske <cweiske@cweiske.de>
Wed, 9 Feb 2011 18:03:58 +0000 (19:03 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 9 Feb 2011 18:03:58 +0000 (19:03 +0100)
munin/usb-wde1-log-last.sh

index 0752498968fe6beb8fb8eaf63124474a733445b9..db27a13dc5ccf93ceb560d8678cb8f0c581316de 100755 (executable)
@@ -4,11 +4,23 @@
 # run this script as follows:
 # $ nohup ./usb-wde1-log-last.sh &
 #
+# Use --dummy-data as parameter to log dummy data only
+#
 # License: http://www.gnu.org/licenses/agpl.html AGPL
 # Author: Christian Weiske <cweiske@cweiske.de>
 #
 # FIXME: send RESET or INIT and M2
-# FIXME: use absolute path for log-single-line.sh
-#
-socat /dev/ttyUSB0,b9600 STDOUT\
- | ./log-single-line.sh /tmp/usb-wde1-last
+
+curdir="$(dirname "$0")"
+if [ "$1" = "--dummy-data" ]; then
+    $curdir/../dummy-data-generator.php\
+     | $curdir/log-single-line.sh /tmp/usb-wde1-last
+else
+    if [ ! -r /dev/ttyUSB0 ]; then
+        echo "Device /dev/ttyUSB0 is not readable"
+        exit 1
+    fi
+
+    socat /dev/ttyUSB0,b9600 STDOUT\
+     | $curdir/log-single-line.sh /tmp/usb-wde1-last
+fi