add license and author
[usb-wde1-tools.git] / munin / log-single-line.sh
1 #!/bin/sh
2 # Logs a single line into the log file passed as script parameter
3 #  and adds timestamp to the logview openformat lines
4 #
5 # License: http://www.gnu.org/licenses/agpl.html AGPL
6 # Author: Christian Weiske <cweiske@cweiske.de>
7
8 file="$1"
9 if [ "x$file" = "x" ]; then
10     echo Please pass a file name to log the line into
11     exit 1
12 fi
13
14 # $1;1;;13,8;22,7;22,6;17,8;22,2;21,2;22,9;;59;35;38;49;38;40;35;;;;;;;0
15 while read -r line
16 do
17     beginning=`echo "$line"|cut -b 1-3`
18     if [ "$beginning" = '$1;' ]; then
19         timestamp=`date +%s`
20         echo $line|sed "s/\$1;1;;/\$1;1;$timestamp;/" > "$file"
21     fi
22 done