#!/bin/bash #generate html report from nightly.log output file #get some variables function today_date { suffix=`date | awk '{printf("%s-%s-%s %s",$2,$3,$6,$4);}'` echo $suffix; } ISSM_RELEASE="issm"; today=`today_date`; host_name=`hostname`; #Process log for errors cat nightly.log | grep 'package: macayeal' > macayeal.log cat nightly.log | grep 'package: ice' > ice.log cat nightly.log | grep 'package: cielo_serial' > cielo_serial.log cat nightly.log | grep 'package: cielo_parallel' > cielo_parallel.log cat nightly.log | grep NIGHTLYRUNTERMINATEDCORRECTLY > check.log cat nightly.log | grep ERROR | grep -v "PETSC ERROR"> errors.log cat nightly.log | grep SUCCESS > success.log cat errors.log success.log > tests.log mail -s "Nightly runs of $ISSM_RELEASE on: $host_name. Date:$today." mathieu.morlighem@jpl.nasa.gov < tests.log cat < report.html ISSM - Nightly run Report

ISSM Nightly run report


host: $host_name
date: $today
release: $ISSM_RELEASE

remark: $(if [ `wc -l check.log | awk '{printf("%s",$1);}'`  = "0" ];
then
	echo "stopped before the end"
else
	echo "all test desks have been run"
fi
rm check.log) 
number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}';  rm errors.log)
number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}';rm success.log tests.log)

$(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do #enter title if [ $package == "macayeal" ]; then echo "

MacAyeal package

" fi if [ $package == "ice" ]; then echo "

Ice package

" fi if [ $package == "cielo_serial" ]; then echo "

Cielo Serial package

" fi if [ $package == "cielo_parallel" ]; then echo "

Cielo Parallel package

" fi #check that at least one test exists if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then echo "   No test found." else echo "" echo "" # go through the lines of $package.log for i in $(seq 1 1 `wc -l $package.log | awk '{printf("%s",$1);}'`); do echo "" #see wether it is success or error (get color: red or green) if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$i'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ]; then color="bgcolor=#ddffdd"; else color="bgcolor=#ffdddd"; fi #build html corresponding line cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$i'o/ {printf("",$2,$3,$4,$5,$8,$10,$14);}'; echo "" done echo "
Result Tolerance Test Solution Field
%s %s%s%s %s %s %s
" fi rm $package.log done)
ISSM nightly run report
END echo Script has completed