#! /usr/bin/gawk -f
# Apply to a verbose WQ log file. It contains lines of the form:
#
#    Worker:Stdout:1414:mike104_3:True
#
# Any stdout from the task follows, but the last 3 fields report the
# task number, the worker ID, and runtime success status (True/False).

BEGIN {
   FS = ":";
   n = 0;
   count = 0;
}

/^Worker/ {
    if ( $2 == "Stdout" ) {
	++count;
	if ( $5 == "False" ) { failed[++n] = $3; }
    }
}

END {
    if ( count == 0 ) {
	print "No records seen. Was file a verbose WQ log?" ;
    } else {
	print count, "tasks lines seen.";
	print n, "tasks reported as not sucessful:\n" ;
	for ( i = 1; i <= n; i++ ) printf( "%s\n", failed[i] );
    }
}
