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

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

minor

  • Property svn:executable set to *
File size: 6.2 KB
Line 
1#!/bin/bash
2#generate html report from nightly.log output file
3
4cd $ISSM_DIR/test/Verification/NightlyRun/
5
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}'`
15
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
23#style
24H1_STYLE='width="1000px" cellpadding="20"'
25H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
26
27H2_STYLE='width="900px" cellpadding="20"'
28H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
29
30TABLE_STYLE='width="800px" 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"'
32
33MATLAB_STYLE='width="1000px" rules=none'
34MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
35
36BODY_STYLE='width="1000px"'
37BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
38
39FOOTER_STYLE='width="800px" cellpadding="10"'
40FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
41
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
60#build report.html
61
62#first: summary
63cat << END > summary.html
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>
73<td $TABLE_FONT>OS: $OS</td>
74<td $TABLE_FONT>user: $USER</td>
75</tr>
76<tr>
77<td $TABLE_FONT>status: STATUS</td>
78<td $TABLE_FONT>release: $RELEASE</td>
79</tr>
80<tr>
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>execution elapsed time: $EL_RUN</td>
92</tr>
93</table>
94<br><hr width="1000px">
95END
96
97#update status
98if [ $IS_RUN -eq 1 ]
99then
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
102else
103 if [ $IS_INSTALL -eq 1 ]
104 then
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
107 else
108 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
109 mv summary2.html summary.html
110 fi
111fi
112
113#Matlab error report
114if [ -e matlaberror.log ]
115then
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>$(cat matlaberror.log)</pre>
120</td></tr></table>
121END
122else
123 mktemp matlaberror.html
124fi
125
126#report content
127if [ $IS_RUN -eq 1 ];
128then
129 cat << END > content.html
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</th>
137<th $(echo $BODY_FONT)>Subanalysis </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>
142<th $(echo $BODY_FONT)>Field checked</th>
143</tr>
144$(cat matlab.log | while read line
145 do
146 echo "<tr>"
147
148 #get status
149 STATUS=`echo $line | awk '{print $1}'`
150
151 #FAILURE
152 if [ "$STATUS" = "FAILURE" ]
153 then
154
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>\n<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<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n",FONTL,$1,FONTC,"N/A",FONTL,$3,FONTL,$5,FONTL,$7,FONTC,$9,FONTC,$11,FONTC,$13,FONTC,$15,FONTC,"N/A");}
159 ';
160
161 else
162
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>\n<td %s>%s%s%s</td>\n<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<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n",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 )
184</table>
185<br>
186END
187else
188 mktemp content.html
189fi
190
191#last footer
192cat << END > footer.html
193<br>
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>
196END
197
198#concatenate files
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.