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

Last change on this file since 2182 was 2182, checked in by Mathieu Morlighem, 16 years ago

hope to have fixed nightly run for tonight

  • Property svn:executable set to *
File size: 5.6 KB
RevLine 
[882]1#!/bin/bash
2#generate html report from nightly.log output file
3
[1568]4#Process log
[2182]5cat nightly.log | grep 'ERROR' | grep -v "PETSC ERROR" > errors.log
6cat nightly.log | grep 'SUCCESS' > success.log
7cat nightly.log | grep 'FAILURE' > failures.log
[882]8
[1568]9#create some variables
[1635]10if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
[1576]11then
12 IS_INSTALL=0
13else
14 IS_INSTALL=1
15fi
[1636]16if [ $(wc -l nightly.log | awk '{printf("%s",$1);}') -eq 0 ]
[1568]17then
[1636]18 IS_RUN=0
19else
20 IS_RUN=1
21fi
[1568]22
[1605]23#style
24H1_STYLE='width="800px" cellpadding="20"'
25H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
[1568]26
[1605]27H2_STYLE='width="840px" cellpadding="20"'
28H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
[1074]29
[1605]30TABLE_STYLE='width="820px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
31TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
[882]32
[1873]33MATLAB_STYLE='width="820px" rules=none'
[1857]34MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
35
[1605]36BODY_STYLE='width="820px"'
37BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
[882]38
[1605]39NOTEST_STYLE='width="650px"'
40NOTEST_FONT='style="color:#FF0000; font-family:Arial, Verdana, Tahoma; font-size:14px;" align="left"'
[1074]41
[1605]42FOOTER_STYLE='width="800px" cellpadding="10"'
43FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
[1574]44
[1605]45#build report.html
46
47#first: summary
[1574]48cat << END > summary.html
[1605]49<div align="center">
50<table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
51
52<table $TABLE_STYLE>
53<tr>
54<td $TABLE_FONT>host: $HOST_NAME</td>
55<td $TABLE_FONT>date: $TODAY</td>
56</tr>
57<tr>
[2105]58<td $TABLE_FONT>user: $(whoami)</td>
[1605]59<td $TABLE_FONT>total elapsed time: $ELAPSED_TOTAL</td>
60</tr>
61<tr>
[2105]62<td $TABLE_FONT>OS: $OS</td>
[1605]63<td $TABLE_FONT>installation elapsed time: $ELAPSED_INSTAL</td>
64</tr>
65<tr>
66$(#print status
[2182]67if [ $(echo $IS_INSTALL) -eq 0 ];
[882]68then
[1568]69 #installation failed, end of report
[1605]70 echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation failed</span></td>"
71 echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
72 echo "</tr>"
73 echo "</table>"
[2182]74 rm errors.log success.log
[882]75else
[1605]76 #installation successful. Did we go to the end?
77
[1636]78 if [ $(echo $IS_RUN) -eq 0 ];
[1568]79 then
[1636]80 #run failed, end of report
81 echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation successful but tests runs failed</span></td>"
82 echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
83 echo "</tr>"
84 echo "</table>"
[2182]85 rm errors.log success.log failures.log
[1636]86
[1568]87 else
[1636]88
[2182]89 echo "<td $TABLE_FONT>status: <span style=\"color:#008000\">all test desks have been run</span></td>"
[1636]90 echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
91 echo "</tr>"
92 echo "<tr>"
[2182]93 echo "<td $TABLE_FONT>number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l nightly.log | awk '{printf("%s",$1);}'; rm errors.log)</td>"
[1636]94 echo "<td $TABLE_FONT> </td>"
95 echo "</tr>"
96 echo "<tr>"
[2182]97 echo "<td $TABLE_FONT>number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l nightly.log | awk '{printf("%s",$1);}'; rm success.log)</td>"
[1636]98 echo "<td $TABLE_FONT> </td>"
99 echo "</tr>"
100 echo "</table>"
101
102 #draw a line and clean up
103 echo "<br><hr width=\"900px\">"
[1568]104 fi
[1574]105fi)
106END
[882]107
[1855]108#Matlab error report
109cat << END > matlaberror.html
110<table $H2_STYLE><tr><td $H2_FONT>Matlab error</td></tr></table>
111<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
112<pre>$(more matlaberror.log)</pre>
113</td></tr></table>
114END
[1605]115
[1574]116#report content
[1576]117if [ $(echo $IS_INSTALL) = 1 ];
[1574]118then
119 cat << END > content.html
[2182]120<table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
121<table $(echo $BODY_STYLE) cellspacing="-1">
122<tr>
123<th $(echo $BODY_FONT)>Result</th>
124<th $(echo $BODY_FONT)>Tolerance</th>
125<th $(echo $BODY_FONT)>Test name</th>
126<th $(echo $BODY_FONT)>Analysis type</th>
127<th $(echo $BODY_FONT)>Sub type</th>
128<th $(echo $BODY_FONT)>Qmu</th>
129<th $(echo $BODY_FONT)>control</th>
130<th $(echo $BODY_FONT)>Control fit</th>
131<th $(echo $BODY_FONT)>Parallel</th>
132</tr>
133$( COUNTER=0
134MAX=`wc -l nightly.log | awk '{printf("%s",$1);}'`
135while [ $COUNTER -lt $MAX ]; do
136 let COUNTER=COUNTER+1
[882]137
[2182]138 echo "<tr>"
[882]139
[2182]140 #see wether it is success or error (get color: red or green)
141 RESULT="$(cat nightly.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';)"
142 if [ "$RESULT" = "SUCCESS" ];
143 then
144 color="bgcolor=#ddffdd";
[882]145 else
[2182]146 if [ "$RESULT" = "ERROR" ];
147 then
148 color="bgcolor=#ffdddd";
149 else
150 color="bgcolor=#ddddff";
151 fi
152 fi
153 FONT=$(echo "$BODY_FONT $color")
[882]154
[2182]155 #build html corresponding line
156 cat nightly.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk -v FONT="$FONT" '
157 /line'$COUNTER'o/ { printf("<td %s>%s</td><td %s>%s%s%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td>",FONT,$2,FONT,$4,$5,$6,FONT,$8,FONT,$10,FONT,$12,FONT,$14,FONT,$16,FONT,$18,FONT,$20);}
158 ';
[882]159
[2182]160 echo "</tr>"
[882]161
162done)
[2182]163</table>
[1574]164<br>
165END
166else
[1855]167 mktemp content.html
[1574]168fi
[882]169
[1574]170#last footer
171cat << END > footer.html
[1074]172<br>
[1605]173<table $FOOTER_STYLE><tr><td $FOOTER_FONT><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</td></tr></table>
174</div>
[882]175END
[1574]176
177#concatenate files
[2182]178if [ $IS_RUN -eq 0 ];
[1574]179then
[1855]180 cat summary.html matlaberror.html content.html footer.html > report.html
[1574]181else
[1855]182 cat summary.html content.html footer.html > report.html
[1574]183fi
[1855]184rm summary.html content.html footer.html matlaberror.html
Note: See TracBrowser for help on using the repository browser.