source: issm/branches/trunk-jpl-damage/scripts/report.sh@ 12004

Last change on this file since 12004 was 12004, checked in by cborstad, 13 years ago

merged trunk-jpl into trunk-jpl-damage through revision 11990

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