Pthread pause
[mirrors/Programs.git] / c / goertzel / sleepstats.sh
CommitLineData
43f096b6
TM
1#!/bin/bash
2
3export LC_ALL=C
4
5historymax=120;
6historylen='10 30 60 90 120'
7laststate=0;
8lastdate=''
9history='';
10
11#statsdone=$(tail -n $historymax "$1".stats | head -n 1 | cut -d ' ' -f 1);
12
13tail -f "$1" --pid=$$ | while read line; do
14 date="$(echo "$line" | cut -d ' ' -f 2)"
15 #test -n "$statsdone" && test "$date" -le "$statsdone" && continue;
16 state="$(echo "$line" | cut -d ' ' -f 5)"
17 test -z "$lastdate" && lastdate="$(( $date - 1 ))"
18
19 #echo $line
20 #echo $lastdate $date $state
21
22 for i in $(seq $lastdate $(( $date - 1 ))); do
23 echo -ne "$i $state\t"
24 history=$(echo -n "$laststate$history" | head -c $historymax)
25 for len in $historylen; do
26 on="$(echo -n ${history::$len} | tr -d 0 | wc -c)"
27 on="$(echo "scale=2; $on/$len" | bc)"
28 printf " %.2f" "$on"
29 done
30 echo
31 done
32
33 #History
34 #after=$(( $date - $lastdate))
35 #test $historymax -gt 0 && {
36 #}
37
38
39 #Prepare invariants for next round
40 lastdate="$date";
41 laststate="$state";
42done > "$1.stats"
This page took 0.980371 seconds and 4 git commands to generate.