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

Last change on this file since 5076 was 5076, checked in by Mathieu Morlighem, 15 years ago

minor

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