X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=c%2Fgoertzel%2Fsleepmon.sh;h=cfa02973e5144863ac161dc9f38d5f857c6225c6;hb=d0c03bf12c2c930b628f8748ec26c25a38327066;hp=72c827530ab6c3f5c78aca90644be6c72a9d6bc5;hpb=3afb9fca6a37d4deea62d7b894fb953e8b538614;p=mirrors%2FPrograms.git diff --git a/c/goertzel/sleepmon.sh b/c/goertzel/sleepmon.sh index 72c8275..cfa0297 100755 --- a/c/goertzel/sleepmon.sh +++ b/c/goertzel/sleepmon.sh @@ -17,19 +17,19 @@ graphout="${out%%.*}.png" killall speaker-test &>/dev/null speaker-test -t sine &>/dev/null & -pid_test=$! + +touch "$out" +bash ./sleepstats.sh "$out" &>/dev/null & tresh=10 lastdate="$(date +%s)" -laststate=0 -history=''; -historymax=120; -historylen='10 30 60 90 120' screen=false graph=false export LC_ALL=C +#trap 'kill -9 $(jobs -p);' SIGINT + while getopts "sg" OPT; do test "$OPT" == 's' && screen=true; test "$OPT" == 'g' && graph=true; @@ -48,18 +48,8 @@ arecord | ./goertzel -n i -q -l c -t $tresh -d 4 | while read line; do printf "%.2f\t %s %s %d" "$time" "$date" "$(date '+%F %T')" "$statenum" - #History - after=$(( $date - $lastdate)) - test $historymax -gt 0 && { - history=$(echo -n "$(yes | tr '\ny' $laststate | head -c $after)$history" | head -c $historymax) - for len in $historylen; do - on="$(echo -n ${history::$len} | tr -d 0 | wc -c)" - on="$(echo "scale=2; $on/$len" | bc)" - printf " %.2f" "$on" - done - } - #Debug + after=$(( $date - $lastdate)) printf " (%s %3d After %4d secs)\n" "$statename" "$level" "$after"; #Fun with values @@ -72,9 +62,8 @@ arecord | ./goertzel -n i -q -l c -t $tresh -d 4 | while read line; do #Prepare invariants for next round lastdate="$date"; - laststate="$statenum"; done | tee "$out" -kill $pid_test; sleep 0.2 +kill $(jobs -p); sleep 0.2 echo echo "Your log: $out" $graph && {