#!/usr/bin/env bash
[[ $# -eq 1 ]] || { echo "usage: $0 <cluster directory>"; exit 1; }
CLDIR="$1"
[[ -d $CLDIR ]] || { echo "error: missing cluster directory at $CLDIR"; exit 255; }

DIR_BIN="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

for x in $CLDIR/*.evolrate; do
    lbl=$(basename $x .evolrate)
    printf "%-16s " "$lbl"
    elems=( $($DIR_BIN/stats.py -f $x -c 1 -u) )
    vmin=${elems[1]}
    vmedian=${elems[4]}
    state="OK"
    [[ $vmin == "-1" ]] && state="BAD"
    [[ $vmedian == "1" ]] && state="BAD"
    printf "%3s   " "$state"
    echo "${elems[@]}"
done
