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

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

updated nightly run

  • Property svn:executable set to *
File size: 6.2 KB
RevLine 
[882]1#!/bin/bash
2#generate html report from nightly.log output file
3
[2185]4cd $ISSM_DIR/test/Verification/NightlyRun/
[882]5
[2185]6#process nightly.log
7TODAY=` cat nightly.log | grep "today" | awk '{printf("%s %s",$2,$3);}'`
8USER=` cat nightly.log | grep "user" | awk '{print $2}'`
9HOST_NAME=` cat nightly.log | grep "host" | awk '{print $2}'`
10OS=` cat nightly.log | grep "OS" | awk '{print $2}'`
11RELEASE=` cat nightly.log | grep "release" | awk '{print $2}'`
12EL_INSTALL=`cat nightly.log | grep "elapsed_install" | awk '{print $2}'`
13EL_RUN=` cat nightly.log | grep "elapsed_run" | awk '{print $2}'`
14EL_TOTAL=` cat nightly.log | grep "elapsed_total" | awk '{print $2}'`
[1568]15
[2185]16#Process matlab_log.log
17cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' > matlab.log
18NUM_TOT=`wc -l matlab.log | awk '{print $1}'`
19NUM_ERR=`cat matlab.log | grep 'ERROR' | grep -v "PETSC ERROR" | wc -l`
20NUM_SUC=`cat matlab.log | grep 'SUCCESS' | wc -l`
21NUM_FAI=`cat matlab.log | grep 'FAILURE' | wc -l`
22
[1605]23#style
[2185]24H1_STYLE='width="1000px" cellpadding="20"'
[1605]25H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
[1568]26
[2185]27H2_STYLE='width="900px" cellpadding="20"'
[1605]28H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
[1074]29
[2185]30TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
[1605]31TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
[882]32
[2185]33MATLAB_STYLE='width="1000px" rules=none'
[1857]34MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
35
[2185]36BODY_STYLE='width="1000px"'
[1605]37BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
[882]38
[1605]39FOOTER_STYLE='width="800px" cellpadding="10"'
40FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
[1574]41
[2185]42#style 2
43BODY_FONTC=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g"`
44BODY_FONTL=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g"`
45
46#create some variables
47if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
48then
49 IS_INSTALL=0
50else
51 IS_INSTALL=1
52fi
53if [ $(wc -l matlab.log | awk '{printf("%s",$1);}') -eq 0 ]
54then
55 IS_RUN=0
56else
57 IS_RUN=1
58fi
59
[1605]60#build report.html
61
62#first: summary
[1574]63cat << END > summary.html
[1605]64<div align="center">
65<table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
66
67<table $TABLE_STYLE>
68<tr>
69<td $TABLE_FONT>host: $HOST_NAME</td>
70<td $TABLE_FONT>date: $TODAY</td>
71</tr>
72<tr>
[2185]73<td $TABLE_FONT>OS: $OS</td>
74<td $TABLE_FONT>user: $USER</td>
[1605]75</tr>
76<tr>
[2185]77<td $TABLE_FONT>status: STATUS</td>
78<td $TABLE_FONT>release: $RELEASE</td>
[1605]79</tr>
80<tr>
[2185]81<td $TABLE_FONT>number of success: $NUM_SUC/$NUM_TOT
82<td $TABLE_FONT>total elapsed time: $EL_TOTAL</td>
83</tr>
84<tr>
85<td $TABLE_FONT>number of errors: $NUM_ERR/$NUM_TOT
86
87<td $TABLE_FONT>installation elapsed time: $EL_INSTALL</td>
88</tr>
89<tr>
90<td $TABLE_FONT>number of failures: $NUM_FAI/$NUM_TOT
91<td $TABLE_FONT>installation elapsed time: $EL_INSTALL</td>
92</tr>
93</table>
94<br><hr width="1000px">
95END
96
97#update status
98if [ $IS_RUN -eq 1 ]
[882]99then
[2185]100 cat summary.html | sed -e "s/STATUS/<span style=\"color:#008000\">all test desks have been run<\/span>/g" > summary2.html
101 mv summary2.html summary.html
[882]102else
[2185]103 if [ $IS_INSTALL -eq 1 ]
[1568]104 then
[2185]105 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation successful but tests runs failed<\/span>/g" > summary2.html
106 mv summary2.html summary.html
[1568]107 else
[2185]108 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
109 mv summary2.html summary.html
[1568]110 fi
[2185]111fi
[882]112
[1855]113#Matlab error report
[2185]114if [ -e matlaberror.log ]
115then
[1855]116cat << END > matlaberror.html
117<table $H2_STYLE><tr><td $H2_FONT>Matlab error</td></tr></table>
118<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
119<pre>$(more matlaberror.log)</pre>
120</td></tr></table>
121END
[2185]122else
123 mktemp matlaberror.html
124fi
[1605]125
[1574]126#report content
[2185]127if [ $IS_INSTALL -eq 1 ];
[1574]128then
129 cat << END > content.html
[2182]130<table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
131<table $(echo $BODY_STYLE) cellspacing="-1">
132<tr>
133<th $(echo $BODY_FONT)>Result</th>
134<th $(echo $BODY_FONT)>Tolerance</th>
135<th $(echo $BODY_FONT)>Test name</th>
136<th $(echo $BODY_FONT)>Analysis type</th>
137<th $(echo $BODY_FONT)>Sub type</th>
138<th $(echo $BODY_FONT)>Qmu</th>
139<th $(echo $BODY_FONT)>control</th>
140<th $(echo $BODY_FONT)>Control fit</th>
141<th $(echo $BODY_FONT)>Parallel</th>
[2185]142<th $(echo $BODY_FONT)>Field checked</th>
[2182]143</tr>
[2185]144$(cat matlab.log | while read line
145 do
146 echo "<tr>"
[882]147
[2185]148 #get status
149 STATUS=`echo $line | awk '{print $1}'`
[882]150
[2185]151 #FAILURE
152 if [ "$STATUS" = "FAILURE" ]
153 then
[882]154
[2185]155 FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
156 FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
157 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
158 { printf("<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><td %s>%s</td><td %s>%s</td><td %s>%s</td>",FONTL,$1,FONTC,"N/A",FONTL,$3,FONTL,$5,FONTL,$7,FONTC,$9,FONTC,$11,FONTC,$13,FONTC,$15,FONTC,"N/A");}
159 ';
[882]160
[2185]161 else
[882]162
[2185]163 #SUCCESS
164 if [ "$STATUS" = "SUCCESS" ]
165 then
166 color="bgcolor=#ddffdd";
167
168 #ERROR
169 else
170 color="bgcolor=#ffdddd";
171 fi
172
173 FONTC=$(echo "$BODY_FONTC $color")
174 FONTL=$(echo "$BODY_FONTL $color")
175 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
176 { 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><td %s>%s</td>",FONTL,$1,FONTL,$3,$4,$5,FONTL,$7,FONTL,$9,FONTL,$11,FONTC,$13,FONTC,$15,FONTC,$17,FONTC,$19,FONTL,$21);}
177 ';
178 fi
179
180 echo "</tr>"
181
182 done
183 )
[2182]184</table>
[1574]185<br>
186END
187else
[1855]188 mktemp content.html
[1574]189fi
[882]190
[1574]191#last footer
192cat << END > footer.html
[1074]193<br>
[1605]194<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>
195</div>
[882]196END
[1574]197
198#concatenate files
[2185]199cat summary.html matlaberror.html content.html footer.html > report.html
200rm summary.html content.html footer.html matlaberror.html matlab.log
Note: See TracBrowser for help on using the repository browser.