Admin/isatest/isatest-statistics
author wenzelm
Thu, 04 Oct 2007 16:21:31 +0200
changeset 24831 887d1b32a1a5
parent 22410 da313b67a04d
child 25453 80557dafd2a0
permissions -rwxr-xr-x
cover AFP logs as well, using "afp" pseudo-platform;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
24831
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    54
if [ "$PLATFORM" = afp ]; then
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    55
  LOG_DIR=~isatest/afp-log
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    56
  LOG_NAME="afp-test-devel*"
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    57
else
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    58
  LOG_DIR=~isatest/log
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    59
  LOG_NAME="isatest-makeall-${PLATFORM}*"
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    60
fi
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    61
22410
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    62
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    63
## main
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    64
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    65
ALL_DATA="/tmp/isatest-all$$.dat"
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    66
SESSION_DATA="/tmp/isatest$$.dat"
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    67
mkdir -p "$DIR" || fail "Bad directory: $DIR"
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    68
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    69
$ZGREP "^Finished .*elapsed" \
24831
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    70
  $(find "$LOG_DIR" -name "$LOG_NAME" -ctime "-${TIMESPAN}") | \
22410
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    71
perl -e '
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    72
  while (<>) {
24831
887d1b32a1a5 cover AFP logs as well, using "afp" pseudo-platform;
wenzelm
parents: 22410
diff changeset
    73
    if (m/(\d\d\d\d)-(\d\d)-(\d\d).*:Finished (\S+) \(.*, (\d+):(\d+):(\d+) cpu time\)/) {
22410
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    74
        my $year = $1;
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    75
        my $month = $2;
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    76
        my $day = $3;
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    77
        my $name = $4;
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    78
        my $time = ($5 * 3600 + $6 * 60 + $7) / 60;
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    79
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    80
        printf "$name $year-$month-$day %.2f\n", $time;
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    81
    }
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    82
  }' > "$ALL_DATA"
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    83
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    84
for SESSION in $SESSIONS
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    85
do
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    86
  fgrep "$SESSION " "$ALL_DATA" > "$SESSION_DATA"
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    87
  gnuplot <<EOF
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    88
set terminal $TE
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    89
set output "$DIR/${SESSION}.png"
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    90
set xdata time
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    91
set timefmt "%Y-%m-%d"
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    92
set format x "%d-%b"
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    93
set xlabel "$SESSION"
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    94
plot [] [0:] "$SESSION_DATA" using 2:3 smooth sbezier notitle, "$SESSION_DATA" using 2:3 smooth csplines notitle
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    95
EOF
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    96
done
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    97
da313b67a04d moved all isatest/cron job related files to own directory
kleing
parents:
diff changeset
    98
rm -f "$ALL_DATA" "$SESSION_DATA"