20611
|
1 |
#!/usr/bin/env bash
|
|
2 |
#
|
|
3 |
# $Id$
|
|
4 |
# Author: Makarius
|
|
5 |
#
|
|
6 |
# DESCRIPTION: Produce statistics from isatest session logs.
|
|
7 |
|
|
8 |
ISATEST_LOG=~isatest/log
|
|
9 |
|
|
10 |
|
|
11 |
## diagnostics
|
|
12 |
|
|
13 |
PRG="$(basename "$0")"
|
|
14 |
|
|
15 |
function usage()
|
|
16 |
{
|
|
17 |
echo
|
20614
|
18 |
echo "Usage: $PRG DIR PLATFORM TIMESPAN SESSIONS..."
|
20611
|
19 |
echo
|
20614
|
20 |
echo " Produce statistics from isatest session logs, looking TIMESPAN"
|
|
21 |
echo " days into the past. Outputs .png files into DIR."
|
20611
|
22 |
echo
|
|
23 |
exit 1
|
|
24 |
}
|
|
25 |
|
|
26 |
function fail()
|
|
27 |
{
|
|
28 |
echo "$1" >&2
|
|
29 |
exit 2
|
|
30 |
}
|
|
31 |
|
|
32 |
|
|
33 |
## arguments
|
|
34 |
|
|
35 |
[ "$1" = "-?" ] && usage
|
20614
|
36 |
[ "$#" -lt "4" ] && usage
|
20611
|
37 |
|
20614
|
38 |
DIR="$1"; shift
|
20611
|
39 |
PLATFORM="$1"; shift
|
|
40 |
TIMESPAN="$1"; shift
|
|
41 |
SESSIONS="$@"
|
|
42 |
|
|
43 |
|
|
44 |
## main
|
|
45 |
|
|
46 |
ALL_DATA="/tmp/isatest-all$$.dat"
|
|
47 |
SESSION_DATA="/tmp/isatest$$.dat"
|
20614
|
48 |
mkdir -p "$DIR" || fail "Bad directory: $DIR"
|
20611
|
49 |
|
|
50 |
zgrep "^Finished .*elapsed" \
|
20614
|
51 |
$(find "$ISATEST_LOG" -name "isatest-makeall-${PLATFORM}*" -ctime "-${TIMESPAN}") | \
|
20611
|
52 |
perl -e '
|
|
53 |
while (<>) {
|
20615
|
54 |
if (m/isatest-makeall-.*-(\d+)-(\d+)-(\d+)-.*:Finished (\S+) \(.*, (\d+):(\d+):(\d+) cpu time\)/) {
|
20611
|
55 |
my $year = $1;
|
|
56 |
my $month = $2;
|
|
57 |
my $day = $3;
|
|
58 |
my $name = $4;
|
20614
|
59 |
my $time = ($5 * 3600 + $6 * 60 + $7) / 60;
|
20611
|
60 |
|
20614
|
61 |
printf "$name $year-$month-$day %.2f\n", $time;
|
20611
|
62 |
}
|
|
63 |
}' > "$ALL_DATA"
|
|
64 |
|
|
65 |
for SESSION in $SESSIONS
|
|
66 |
do
|
|
67 |
fgrep "$SESSION " "$ALL_DATA" > "$SESSION_DATA"
|
|
68 |
gnuplot <<EOF
|
|
69 |
set terminal png
|
20614
|
70 |
set output "$DIR/${SESSION}.png"
|
|
71 |
set xdata time
|
|
72 |
set timefmt "%Y-%m-%d"
|
|
73 |
set format x "%d-%b"
|
|
74 |
set xlabel "$SESSION"
|
|
75 |
plot [] [0:] "$SESSION_DATA" using 2:3 title "" smooth sbezier, "$SESSION_DATA" using 2:3 title "" smooth csplines
|
20611
|
76 |
EOF
|
|
77 |
done
|
|
78 |
|
|
79 |
rm -f "$ALL_DATA" "$SESSION_DATA"
|