source: issm/trunk/cron/report.sh@ 1576

Last change on this file since 1576 was 1576, checked in by seroussi, 16 years ago

some fixing

  • Property svn:executable set to *
File size: 5.8 KB
RevLine 
[882]1#!/bin/bash
2#generate html report from nightly.log output file
3
[1568]4#Process log
[884]5cat nightly.log | grep 'package: macayeal' | grep -v "not supported yet" > macayeal.log
6cat nightly.log | grep 'package: ice' | grep -v "not supported yet" > ice.log
7cat nightly.log | grep 'package: cielo_serial' | grep -v "not supported yet" > cielo_serial.log
8cat nightly.log | grep 'package: cielo_parallel'| grep -v "not supported yet" > cielo_parallel.log
[882]9cat nightly.log | grep NIGHTLYRUNTERMINATEDCORRECTLY > check.log
[884]10cat nightly.log | grep ERROR | grep -v "PETSC ERROR" > errors.log
[882]11cat nightly.log | grep SUCCESS > success.log
12cat errors.log success.log > tests.log
13
[1568]14#create some variables
[1576]15if [ `wc -l nightly.log | awk '{printf("%s",$1);}'` = "0" ]
16then
17 IS_INSTALL=0
18else
19 IS_INSTALL=1
20fi
[1568]21if [ `wc -l check.log | awk '{printf("%s",$1);}'` = "0" ]
22then
23 IS_END=0
24else
25 IS_END=1
26fi
27
[1574]28#build report.html
[1568]29
[1574]30#first: header
31cat << END > header.html
[882]32<html>
33<title>ISSM - Nightly run Report</title>
34<body>
35
36<style type="text/css">
37 <!--
[1074]38 .issmbody {
39 margin: auto;
40 width:800px;
41 background: none;
42 color: #404040;
43 font-family: Arial, Verdana, Tahoma;
44 font-size: 14px;
45 font-weight: normal;
46 text-align: left;
47 }
48
[942]49 .issmh1 {
[1074]50 margin:2em auto;
51 width:800px;
[942]52 background: none;
[882]53 color: #6495ed;
[942]54 font-family: Arial, Verdana, Tahoma;
55 font-size: 35px;
[944]56 font-weight: bold;
[882]57 text-align: center;
58 }
59
[942]60 .issmh2 {
[1074]61 margin:1.5em auto 1em auto;
[943]62 width:800px;
[882]63 background: transparent;
64 color: #6495ed;
[942]65 font-family: Arial, Verdana, Tahoma;
[944]66 font-weight: bold;
[942]67 font-size: 28px;
[882]68 text-align: left;
69 }
70
[1074]71 .issmfooter {
72 margin:auto;
73 width:800px;
74 background: none;
75 color: #404040;
76 font-family: Arial, Verdana, Tahoma;
77 font-size: 12px;
78 font-weight: normal;
79 text-align: center;
80 }
81
82 .issmcomment {
[882]83 padding:4px;
[1074]84 margin:0 auto;
[943]85 width:800px;
[882]86 border:1px dashed #000000;
[942]87 text-align: left;
88 font-family: Arial, Verdana, Tahoma;
89 font-size: 14px;
90 color: #404040;
[882]91 background-color:#ffffdd}
92 -->
93</style>
[1074]94<div class="issmh1">ISSM Nightly run report</div>
[882]95<br>
[1574]96END
97
98#then: summary
99cat << END > summary.html
[1074]100<div class="issmcomment">
[1530]101date: $TODAY<br>
102host: $HOST_NAME<br>
[1568]103OS: $OS<br>
[1074]104release: $ISSM_RELEASE<br>
[1566]105total elapsed time: $ELAPSED_TOTAL<br>
106installation elapsed time: $ELAPSED_INSTAL<br>
107runs elapsed time: $ELAPSED_RUN<br>
[882]108<br>
[1576]109status: $(if [ $(echo $IS_INSTALL) = 0 ];
[882]110then
[1568]111 #installation failed, end of report
[1574]112 echo "<span style=\"color:#FF0000\">installation failed</span></div>"
113 rm check.log errors.log success.log tests.log
[882]114else
[1576]115 if [ $(echo $IS_END) = 0 ];
[1568]116 then
[1574]117 echo "<span style=\"color:#FF0000\">stopped before the end</span>"
[1568]118 else
119 echo "all test desks have been run"
120 fi
[1574]121 echo "<br>"
122 echo "number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}'; rm errors.log)<br>"
123 echo "number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}';rm success.log tests.log)</div>"
124 echo "<br>"
125 echo "<hr width=\"900px\">"
126 rm check.log
127fi)
128END
[882]129
[1574]130#report content
[1576]131if [ $(echo $IS_INSTALL) = 1 ];
[1574]132then
133 cat << END > content.html
[882]134$(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
135
136 #enter title
137 if [ $package == "macayeal" ]; then
[1074]138 echo "<div class=\"issmh2\">MacAyeal package</div>"
[882]139 fi
140 if [ $package == "ice" ]; then
[1074]141 echo "<div class=\"issmh2\">Ice package</div>"
[882]142 fi
143 if [ $package == "cielo_serial" ]; then
[1074]144 echo "<div class=\"issmh2\">Cielo Serial package</div>"
[882]145 fi
146 if [ $package == "cielo_parallel" ]; then
[1074]147 echo "<div class=\"issmh2\">Cielo Parallel package</div>"
[882]148 fi
149
[1074]150 #Print division
151 echo "<div class=\"issmbody\">"
152
153 #check that at least one Test exists
[882]154 if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
[1074]155
156 #No Test: use a table to fix entourage bug.
[1406]157 echo "<table width=\"20%\" style=\"color:#FF0000; font-size:14px;\"><tr><td align=\"center\">No test found.</td></tr></table>"
[1074]158
[882]159 else
160
[1406]161 echo "<table cellspacing=\"-1\" width=\"100%\" style=\"font-family: Arial, Verdana, Tahoma; color: #404040;\">"
[943]162 echo "<tr> <th style=\"font-size:14px;\">Result</th> <th style=\"font-size:14px;\">Tolerance</th> <th style=\"font-size:14px;\">Test</th> <th style=\"font-size:14px;\">Solution</th> <th style=\"font-size:14px;\">Field</th> </tr>"
[882]163
164 # go through the lines of $package.log
[1521]165 COUNTER=0
[1435]166 MAX=`wc -l $package.log | awk '{printf("%s",$1);}'`
167 while [ $COUNTER -lt $MAX ]; do
168 let COUNTER=COUNTER+1
[882]169
170 echo "<tr>"
171
172 #see wether it is success or error (get color: red or green)
[1435]173 if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
[882]174 then
175 color="bgcolor=#ddffdd";
176 else
177 color="bgcolor=#ffdddd";
178 fi
179
180 #build html corresponding line
[1435]181 cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("<td '$color' style=\"font-size:14px;\">%s</td><td '$color' style=\"font-size:14px;\"> %s%s%s</td><td '$color' style=\"font-size:14px;\"> %s</td><td '$color' style=\"font-size:14px;\"> %s</td><td '$color' style=\"font-size:14px;\"> %s</td>",$2,$4,$5,$6,$8,$10,$14);}';
[882]182 echo "</tr>"
183 done
184
185 echo "</table>"
186 fi
[1074]187
188 #Print end division and remove log file
189 echo "</div>"
[882]190 rm $package.log
[1074]191
[882]192done)
[1574]193<br>
194END
195else
196 for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
197 rm $package.log
198 done
199fi
[882]200
[1574]201#last footer
202cat << END > footer.html
[1074]203<br>
204<div class="issmfooter"><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</div>
205</body>
206</html>
[882]207END
[1574]208
209#concatenate files
[1576]210if [ $(echo $IS_INSTALL) = 1 ];
[1574]211then
212 cat header.html summary.html content.html footer.html > report.html
213 rm header.html summary.html content.html footer.html
214else
215 cat header.html summary.html footer.html > report.html
216 rm header.html summary.html footer.html
217fi
Note: See TracBrowser for help on using the repository browser.