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
Line 
1#!/bin/bash
2#generate html report from nightly.log output file
3
4#Process log
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
9cat nightly.log | grep NIGHTLYRUNTERMINATEDCORRECTLY > check.log
10cat nightly.log | grep ERROR | grep -v "PETSC ERROR" > errors.log
11cat nightly.log | grep SUCCESS > success.log
12cat errors.log success.log > tests.log
13
14#create some variables
15if [ `wc -l nightly.log | awk '{printf("%s",$1);}'` = "0" ]
16then
17 IS_INSTALL=0
18else
19 IS_INSTALL=1
20fi
21if [ `wc -l check.log | awk '{printf("%s",$1);}'` = "0" ]
22then
23 IS_END=0
24else
25 IS_END=1
26fi
27
28#build report.html
29
30#first: header
31cat << END > header.html
32<html>
33<title>ISSM - Nightly run Report</title>
34<body>
35
36<style type="text/css">
37 <!--
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
49 .issmh1 {
50 margin:2em auto;
51 width:800px;
52 background: none;
53 color: #6495ed;
54 font-family: Arial, Verdana, Tahoma;
55 font-size: 35px;
56 font-weight: bold;
57 text-align: center;
58 }
59
60 .issmh2 {
61 margin:1.5em auto 1em auto;
62 width:800px;
63 background: transparent;
64 color: #6495ed;
65 font-family: Arial, Verdana, Tahoma;
66 font-weight: bold;
67 font-size: 28px;
68 text-align: left;
69 }
70
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 {
83 padding:4px;
84 margin:0 auto;
85 width:800px;
86 border:1px dashed #000000;
87 text-align: left;
88 font-family: Arial, Verdana, Tahoma;
89 font-size: 14px;
90 color: #404040;
91 background-color:#ffffdd}
92 -->
93</style>
94<div class="issmh1">ISSM Nightly run report</div>
95<br>
96END
97
98#then: summary
99cat << END > summary.html
100<div class="issmcomment">
101date: $TODAY<br>
102host: $HOST_NAME<br>
103OS: $OS<br>
104release: $ISSM_RELEASE<br>
105total elapsed time: $ELAPSED_TOTAL<br>
106installation elapsed time: $ELAPSED_INSTAL<br>
107runs elapsed time: $ELAPSED_RUN<br>
108<br>
109status: $(if [ $(echo $IS_INSTALL) = 0 ];
110then
111 #installation failed, end of report
112 echo "<span style=\"color:#FF0000\">installation failed</span></div>"
113 rm check.log errors.log success.log tests.log
114else
115 if [ $(echo $IS_END) = 0 ];
116 then
117 echo "<span style=\"color:#FF0000\">stopped before the end</span>"
118 else
119 echo "all test desks have been run"
120 fi
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
129
130#report content
131if [ $(echo $IS_INSTALL) = 1 ];
132then
133 cat << END > content.html
134$(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
135
136 #enter title
137 if [ $package == "macayeal" ]; then
138 echo "<div class=\"issmh2\">MacAyeal package</div>"
139 fi
140 if [ $package == "ice" ]; then
141 echo "<div class=\"issmh2\">Ice package</div>"
142 fi
143 if [ $package == "cielo_serial" ]; then
144 echo "<div class=\"issmh2\">Cielo Serial package</div>"
145 fi
146 if [ $package == "cielo_parallel" ]; then
147 echo "<div class=\"issmh2\">Cielo Parallel package</div>"
148 fi
149
150 #Print division
151 echo "<div class=\"issmbody\">"
152
153 #check that at least one Test exists
154 if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
155
156 #No Test: use a table to fix entourage bug.
157 echo "<table width=\"20%\" style=\"color:#FF0000; font-size:14px;\"><tr><td align=\"center\">No test found.</td></tr></table>"
158
159 else
160
161 echo "<table cellspacing=\"-1\" width=\"100%\" style=\"font-family: Arial, Verdana, Tahoma; color: #404040;\">"
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>"
163
164 # go through the lines of $package.log
165 COUNTER=0
166 MAX=`wc -l $package.log | awk '{printf("%s",$1);}'`
167 while [ $COUNTER -lt $MAX ]; do
168 let COUNTER=COUNTER+1
169
170 echo "<tr>"
171
172 #see wether it is success or error (get color: red or green)
173 if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
174 then
175 color="bgcolor=#ddffdd";
176 else
177 color="bgcolor=#ffdddd";
178 fi
179
180 #build html corresponding line
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);}';
182 echo "</tr>"
183 done
184
185 echo "</table>"
186 fi
187
188 #Print end division and remove log file
189 echo "</div>"
190 rm $package.log
191
192done)
193<br>
194END
195else
196 for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
197 rm $package.log
198 done
199fi
200
201#last footer
202cat << END > footer.html
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>
207END
208
209#concatenate files
210if [ $(echo $IS_INSTALL) = 1 ];
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.