single line logger works nwo
authorChristian Weiske <cweiske@cweiske.de>
Sat, 5 Feb 2011 17:14:26 +0000 (18:14 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Sat, 5 Feb 2011 17:14:26 +0000 (18:14 +0100)
munin/log-single-line.sh

index 50c6f4303346f9db31beea78c500ab482409f33d..c32fa36110f1a03e9defd09b597aae38f2966c4b 100755 (executable)
@@ -1,9 +1,12 @@
 #!/bin/sh
 #Logs a single line into the log file passed as script parameter
+# adds timestamp to the logview openformat lines
 
-
-#split words by semicolons
-IFS=";"
+file="$1"
+if [ "x$file" = "x" ]; then
+    echo Please pass a file name to log the line into
+    exit 1
+fi
 
 #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
@@ -13,7 +16,6 @@ IFS=";"
 
 while read -r line
 do
-    timestamp = `date +%s`
-    echo $line sed "s/$1;1;;/$1;1;$timestamp;/"
+    timestamp=`date +%s`
+    echo $line|sed "s/\$1;1;;/\$1;1;$timestamp;/" > "$file"
 done
-echo "done with everything"