Commit | Line | Data |
---|---|---|
43f096b6 TM |
1 | #!/bin/bash |
2 | ||
3 | export LC_ALL=C | |
4 | ||
5 | historymax=120; | |
6 | historylen='10 30 60 90 120' | |
7 | laststate=0; | |
8 | lastdate='' | |
9 | history=''; | |
10 | ||
11 | #statsdone=$(tail -n $historymax "$1".stats | head -n 1 | cut -d ' ' -f 1); | |
12 | ||
13 | tail -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"; | |
42 | done > "$1.stats" |