[882] | 1 | #!/bin/bash
|
---|
| 2 | #generate html report from nightly.log output file
|
---|
| 3 |
|
---|
| 4 | #get some variables
|
---|
| 5 | function today_date {
|
---|
| 6 | suffix=`date | awk '{printf("%s-%s-%s %s",$2,$3,$6,$4);}'`
|
---|
| 7 | echo $suffix;
|
---|
| 8 | }
|
---|
| 9 | ISSM_RELEASE="issm";
|
---|
| 10 | today=`today_date`;
|
---|
| 11 | host_name=`hostname`;
|
---|
| 12 |
|
---|
| 13 | #Process log for errors
|
---|
| 14 | cat nightly.log | grep 'package: macayeal' > macayeal.log
|
---|
| 15 | cat nightly.log | grep 'package: ice' > ice.log
|
---|
| 16 | cat nightly.log | grep 'package: cielo_serial' > cielo_serial.log
|
---|
| 17 | cat nightly.log | grep 'package: cielo_parallel' > cielo_parallel.log
|
---|
| 18 | cat nightly.log | grep NIGHTLYRUNTERMINATEDCORRECTLY > check.log
|
---|
| 19 | cat nightly.log | grep ERROR | grep -v "PETSC ERROR"> errors.log
|
---|
| 20 | cat nightly.log | grep SUCCESS > success.log
|
---|
| 21 | cat errors.log success.log > tests.log
|
---|
| 22 | mail -s "Nightly runs of $ISSM_RELEASE on: $host_name. Date:$today." mathieu.morlighem@jpl.nasa.gov < tests.log
|
---|
| 23 |
|
---|
| 24 | cat <<END > report.html
|
---|
| 25 | <html>
|
---|
| 26 | <title>ISSM - Nightly run Report</title>
|
---|
| 27 | <body>
|
---|
| 28 |
|
---|
| 29 | <style type="text/css">
|
---|
| 30 | <!--
|
---|
| 31 | body {
|
---|
| 32 | width: 900px;
|
---|
| 33 | background:none;
|
---|
| 34 | font-family: Arial, Verdana, Tahoma;
|
---|
| 35 | font-size: 14px;
|
---|
| 36 | color: #404040;
|
---|
| 37 | margin: auto;}
|
---|
| 38 | h1 {
|
---|
| 39 | margin-top:1em;
|
---|
| 40 | background: transparent;
|
---|
| 41 | color: #6495ed;
|
---|
| 42 | font-size: 250%;
|
---|
| 43 | text-align: center;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | h2 {
|
---|
| 47 | margin-top:1.5em;
|
---|
| 48 | background: transparent;
|
---|
| 49 | color: #6495ed;
|
---|
| 50 | font-size: 200%;
|
---|
| 51 | text-align: left;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | .comment
|
---|
| 55 | {white-space:pre-wrap;
|
---|
| 56 | word-wrap:break-word;
|
---|
| 57 | padding:4px;
|
---|
| 58 | border:1px dashed #000000;
|
---|
| 59 | background-color:#ffffdd}
|
---|
| 60 | -->
|
---|
| 61 | </style>
|
---|
| 62 | <div>
|
---|
| 63 | <br>
|
---|
| 64 | <h1>ISSM Nightly run report</h1>
|
---|
| 65 | <br>
|
---|
| 66 | <pre class="comment">
|
---|
| 67 | host: $host_name
|
---|
| 68 | date: $today
|
---|
| 69 | release: $ISSM_RELEASE
|
---|
| 70 |
|
---|
| 71 | remark: $(if [ `wc -l check.log | awk '{printf("%s",$1);}'` = "0" ];
|
---|
| 72 | then
|
---|
| 73 | echo "stopped before the end"
|
---|
| 74 | else
|
---|
| 75 | echo "all test desks have been run"
|
---|
| 76 | fi
|
---|
| 77 | rm check.log)
|
---|
| 78 | number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}'; rm errors.log)
|
---|
| 79 | number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}';rm success.log tests.log)</pre>
|
---|
| 80 | <hr>
|
---|
| 81 |
|
---|
| 82 | $(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
|
---|
| 83 |
|
---|
| 84 | #enter title
|
---|
| 85 | if [ $package == "macayeal" ]; then
|
---|
| 86 | echo "<h2>MacAyeal package</h2>"
|
---|
| 87 | fi
|
---|
| 88 | if [ $package == "ice" ]; then
|
---|
| 89 | echo "<h2>Ice package</h2>"
|
---|
| 90 | fi
|
---|
| 91 | if [ $package == "cielo_serial" ]; then
|
---|
| 92 | echo "<h2>Cielo Serial package</h2>"
|
---|
| 93 | fi
|
---|
| 94 | if [ $package == "cielo_parallel" ]; then
|
---|
| 95 | echo "<h2>Cielo Parallel package</h2>"
|
---|
| 96 | fi
|
---|
| 97 |
|
---|
| 98 | #check that at least one test exists
|
---|
| 99 | if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
|
---|
| 100 | echo "   No test found."
|
---|
| 101 | else
|
---|
| 102 |
|
---|
| 103 | echo "<table cellspacing="-1" width="900px">"
|
---|
| 104 | echo "<tr> <th>Result</th> <th>Tolerance</th> <th>Test</th> <th>Solution</th> <th>Field</th> </tr>"
|
---|
| 105 |
|
---|
| 106 | # go through the lines of $package.log
|
---|
| 107 | for i in $(seq 1 1 `wc -l $package.log | awk '{printf("%s",$1);}'`); do
|
---|
| 108 |
|
---|
| 109 | echo "<tr>"
|
---|
| 110 |
|
---|
| 111 | #see wether it is success or error (get color: red or green)
|
---|
| 112 | if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$i'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
|
---|
| 113 | then
|
---|
| 114 | color="bgcolor=#ddffdd";
|
---|
| 115 | else
|
---|
| 116 | color="bgcolor=#ffdddd";
|
---|
| 117 | fi
|
---|
| 118 |
|
---|
| 119 | #build html corresponding line
|
---|
| 120 | cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$i'o/ {printf("<td '$color'>%s</td><td '$color'> %s%s%s</td><td '$color'> %s</td><td '$color'> %s</td><td '$color'> %s</td>",$2,$3,$4,$5,$8,$10,$14);}';
|
---|
| 121 | echo "</tr>"
|
---|
| 122 | done
|
---|
| 123 |
|
---|
| 124 | echo "</table>"
|
---|
| 125 | fi
|
---|
| 126 | rm $package.log
|
---|
| 127 | done)
|
---|
| 128 |
|
---|
| 129 | <br>
|
---|
| 130 | <center><small></a><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</small></center>
|
---|
| 131 | </div>
|
---|
| 132 | END
|
---|
| 133 |
|
---|
| 134 | echo Script has completed
|
---|