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

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

minor

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