author | wenzelm |
Wed, 21 Nov 2007 16:36:47 +0100 | |
changeset 25453 | 80557dafd2a0 |
parent 24831 | 887d1b32a1a5 |
child 25477 | d350aa8cc53d |
permissions | -rwxr-xr-x |
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
1 |
#!/usr/bin/env bash |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
2 |
# |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
3 |
# $Id$ |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
4 |
# Author: Makarius |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
5 |
# |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
6 |
# DESCRIPTION: Produce statistics from isatest session logs. |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
7 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
8 |
## platform settings |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
9 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
10 |
case $(uname) in |
24831
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
11 |
SunOS) |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
12 |
ZGREP=xgrep |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
13 |
TE="png color" |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
14 |
;; |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
15 |
*) |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
16 |
ZGREP=zgrep |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
17 |
TE="png" |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
18 |
;; |
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
19 |
esac |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
20 |
|
24831
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
21 |
|
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
22 |
## diagnostics |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
23 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
24 |
PRG="$(basename "$0")" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
25 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
26 |
function usage() |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
27 |
{ |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
28 |
echo |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
29 |
echo "Usage: $PRG DIR PLATFORM TIMESPAN SESSIONS..." |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
30 |
echo |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
31 |
echo " Produce statistics from isatest session logs, looking TIMESPAN" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
32 |
echo " days into the past. Outputs .png files into DIR." |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
33 |
echo |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
34 |
exit 1 |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
35 |
} |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
36 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
37 |
function fail() |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
38 |
{ |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
39 |
echo "$1" >&2 |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
40 |
exit 2 |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
41 |
} |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
42 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
43 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
44 |
## arguments |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
45 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
46 |
[ "$1" = "-?" ] && usage |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
47 |
[ "$#" -lt "4" ] && usage |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
48 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
49 |
DIR="$1"; shift |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
50 |
PLATFORM="$1"; shift |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
51 |
TIMESPAN="$1"; shift |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
52 |
SESSIONS="$@" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
53 |
|
25453 | 54 |
case "$PLATFORM" in |
55 |
*para*) |
|
56 |
PARALLEL=true |
|
57 |
;; |
|
58 |
*) |
|
59 |
PARALLEL=false |
|
60 |
;; |
|
61 |
esac |
|
62 |
||
24831
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
63 |
if [ "$PLATFORM" = afp ]; then |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
64 |
LOG_DIR=~isatest/afp-log |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
65 |
LOG_NAME="afp-test-devel*" |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
66 |
else |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
67 |
LOG_DIR=~isatest/log |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
68 |
LOG_NAME="isatest-makeall-${PLATFORM}*" |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
69 |
fi |
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
70 |
|
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
71 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
72 |
## main |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
73 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
74 |
ALL_DATA="/tmp/isatest-all$$.dat" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
75 |
SESSION_DATA="/tmp/isatest$$.dat" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
76 |
mkdir -p "$DIR" || fail "Bad directory: $DIR" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
77 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
78 |
$ZGREP "^Finished .*elapsed" \ |
24831
887d1b32a1a5
cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents:
22410
diff
changeset
|
79 |
$(find "$LOG_DIR" -name "$LOG_NAME" -ctime "-${TIMESPAN}") | \ |
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
80 |
perl -e ' |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
81 |
while (<>) { |
25453 | 82 |
if (m/(\d\d\d\d)-(\d\d)-(\d\d).*:Finished (\S+) \((\d+):(\d+):(\d+) elapsed time, (\d+):(\d+):(\d+) cpu time\)/) { |
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
83 |
my $year = $1; |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
84 |
my $month = $2; |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
85 |
my $day = $3; |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
86 |
my $name = $4; |
25453 | 87 |
my $elapsed_time = ($5 * 3600 + $6 * 60 + $7) / 60; |
88 |
my $cpu_time = ($8 * 3600 + $9 * 60 + $10) / 60; |
|
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
89 |
|
25453 | 90 |
printf "$name $year-$month-$day %.2f %.2f\n", $cpu_time, $elapsed_time; |
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
91 |
} |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
92 |
}' > "$ALL_DATA" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
93 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
94 |
for SESSION in $SESSIONS |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
95 |
do |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
96 |
fgrep "$SESSION " "$ALL_DATA" > "$SESSION_DATA" |
25453 | 97 |
PLOT="plot [] [0:] \"$SESSION_DATA\" using 2:3 smooth sbezier notitle, \"$SESSION_DATA\" using 2:3 smooth csplines notitle" |
98 |
if [ "$PARALLEL" = true ]; then |
|
99 |
PLOT="${PLOT}, \"$SESSION_DATA\" using 2:4 smooth sbezier title \"elapsed\", \"$SESSION_DATA\" using 2:4 smooth csplines title \"elapsed\"" |
|
100 |
fi |
|
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
101 |
gnuplot <<EOF |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
102 |
set terminal $TE |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
103 |
set output "$DIR/${SESSION}.png" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
104 |
set xdata time |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
105 |
set timefmt "%Y-%m-%d" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
106 |
set format x "%d-%b" |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
107 |
set xlabel "$SESSION" |
25453 | 108 |
$PLOT |
22410
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
109 |
EOF |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
110 |
done |
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
111 |
|
da313b67a04d
moved all isatest/cron job related files to own directory
kleing
parents:
diff
changeset
|
112 |
rm -f "$ALL_DATA" "$SESSION_DATA" |