1 | #!/bin/bash
|
---|
2 | #generate html report from info.log output file
|
---|
3 |
|
---|
4 | #----------------------------#
|
---|
5 | # Initialize local variables #
|
---|
6 | #----------------------------#
|
---|
7 |
|
---|
8 | #process info.log
|
---|
9 | TODAY=` cat info.log | grep "today" | awk '{printf("%s %s",$2,$3);}'`
|
---|
10 | USER=` cat info.log | grep "user" | awk '{print $2}'`
|
---|
11 | HOST_NAME=` cat info.log | grep "host" | awk '{print $2}'`
|
---|
12 | OS=` cat info.log | grep "OS" | awk '{print $2}'`
|
---|
13 | RELEASE=` cat info.log | grep "release" | awk '{print $2}'`
|
---|
14 | EL_INSTALL=`cat info.log | grep "elapsed_install" | awk '{print $2}'`
|
---|
15 | EL_RUN=` cat info.log | grep "elapsed_run" | awk '{print $2}'`
|
---|
16 | EL_TOTAL=` cat info.log | grep "elapsed_total" | awk '{print $2}'`
|
---|
17 | CRASH=` cat info.log | grep "matlab_crash:" | awk '{print $2}'`
|
---|
18 |
|
---|
19 | #Process matlab_log.log
|
---|
20 | cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' | grep -v "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > matlab.log
|
---|
21 | cat matlab_log.log | grep "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > petscerror.log
|
---|
22 | NUM_TOT=`wc -l matlab.log | awk '{print $1}'`
|
---|
23 | NUM_ERR=`cat matlab.log | grep 'ERROR' | grep -v "PETSC" | wc -l`
|
---|
24 | NUM_SUC=`cat matlab.log | grep 'SUCCESS' | wc -l`
|
---|
25 | NUM_FAI=`cat matlab.log | grep 'FAILURE' | wc -l`
|
---|
26 |
|
---|
27 | #style
|
---|
28 | H1_STYLE='width="1000px" cellpadding="20"'
|
---|
29 | H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
|
---|
30 |
|
---|
31 | H2_STYLE='width="900px" cellpadding="20"'
|
---|
32 | H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
|
---|
33 |
|
---|
34 | TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
|
---|
35 | TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
|
---|
36 |
|
---|
37 | MATLAB_STYLE='width="1000px" rules=none'
|
---|
38 | MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="left"'
|
---|
39 |
|
---|
40 | BODY_STYLE='width="800px"'
|
---|
41 | BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'
|
---|
42 |
|
---|
43 | FOOTER_STYLE='width="800px" cellpadding="10"'
|
---|
44 | FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
|
---|
45 |
|
---|
46 | #style 2
|
---|
47 | BODY_FONTC=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g"`
|
---|
48 | BODY_FONTL=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g"`
|
---|
49 |
|
---|
50 | #create some variables
|
---|
51 | if [ $(ls -1 $ISSM_TIER/bin | wc -l) -le 20 ];
|
---|
52 | then
|
---|
53 | IS_INSTALL=0
|
---|
54 | else
|
---|
55 | IS_INSTALL=1
|
---|
56 | fi
|
---|
57 |
|
---|
58 | #-------------------#
|
---|
59 | # build report.html #
|
---|
60 | #-------------------#
|
---|
61 |
|
---|
62 | #first: summary
|
---|
63 | cat << 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 successes: $NUM_SUC/$NUM_TOT
|
---|
82 | <td $TABLE_FONT>total elapsed time: $EL_TOTAL</td>
|
---|
83 | </tr>
|
---|
84 | <tr>
|
---|
85 | <td $TABLE_FONT>number of <a href="#ERROR">errors</a>: $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 <a href="#FAILURE">failures</a>: $NUM_FAI/$NUM_TOT
|
---|
91 | <td $TABLE_FONT>execution elapsed time: $EL_RUN</td>
|
---|
92 | </tr>
|
---|
93 | </table>
|
---|
94 | <br><hr width="1000px">
|
---|
95 | END
|
---|
96 |
|
---|
97 | #update status
|
---|
98 | if [ $IS_INSTALL -eq 1 ]
|
---|
99 | then
|
---|
100 | if [ $CRASH -eq 0 ]
|
---|
101 | then
|
---|
102 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#008000\">all test desks have been run<\/span>/g" > summary2.html
|
---|
103 | else
|
---|
104 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation successful but Matlab crashed<\/span>/g" > summary2.html
|
---|
105 | fi
|
---|
106 | else
|
---|
107 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
|
---|
108 | fi
|
---|
109 | mv summary2.html summary.html
|
---|
110 |
|
---|
111 | #report table
|
---|
112 | if [ $IS_INSTALL -eq 1 ];
|
---|
113 | then
|
---|
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" '
|
---|
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);}
|
---|
139 | ';
|
---|
140 |
|
---|
141 | else
|
---|
142 |
|
---|
143 | #SUCCESS
|
---|
144 | if [ "$STATUS" = "SUCCESS" ]
|
---|
145 | then
|
---|
146 | FONTC=$(echo "$BODY_FONTC bgcolor=#ddffdd")
|
---|
147 | FONTL=$(echo "$BODY_FONTL bgcolor=#ddffdd")
|
---|
148 | #ERROR
|
---|
149 | else
|
---|
150 | FONTC=$(echo "$BODY_FONTC bgcolor=#ffdddd id=ERROR")
|
---|
151 | FONTL=$(echo "$BODY_FONTL bgcolor=#ffdddd")
|
---|
152 | fi
|
---|
153 |
|
---|
154 |
|
---|
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>
|
---|
166 | END
|
---|
167 | else
|
---|
168 | mktemp content.html
|
---|
169 | fi
|
---|
170 |
|
---|
171 | #Matlab error report
|
---|
172 | if [ -e matlaberror.log ]
|
---|
173 | then
|
---|
174 | cat << END > matlaberror.html
|
---|
175 | <table $H2_STYLE><tr><td $H2_FONT>Matlab errors</td></tr></table>
|
---|
176 | <table $MATLAB_STYLE><tr><td $MATLAB_FONT>
|
---|
177 | <pre style="
|
---|
178 | white-space: -moz-pre-wrap;
|
---|
179 | white-space: -pre-wrap;
|
---|
180 | white-space: -o-pre-wrap;
|
---|
181 | white-space: pre-wrap;
|
---|
182 | word-wrap: break-word;
|
---|
183 | ">$(cat matlaberror.log)</pre>
|
---|
184 | </td></tr></table>
|
---|
185 | END
|
---|
186 | else
|
---|
187 | mktemp matlaberror.html
|
---|
188 | fi
|
---|
189 |
|
---|
190 | #Matlab error report
|
---|
191 | if test -s petscerror.log
|
---|
192 | then
|
---|
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>
|
---|
196 | <pre style="
|
---|
197 | white-space: -moz-pre-wrap;
|
---|
198 | white-space: -pre-wrap;
|
---|
199 | white-space: -o-pre-wrap;
|
---|
200 | white-space: pre-wrap;
|
---|
201 | word-wrap: break-word;
|
---|
202 | ">$(cat petscerror.log)</pre>
|
---|
203 | </td></tr></table>
|
---|
204 | END
|
---|
205 | else
|
---|
206 | mktemp petscerror.html
|
---|
207 | fi
|
---|
208 |
|
---|
209 | #last footer
|
---|
210 | cat << 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>
|
---|
214 | END
|
---|
215 |
|
---|
216 | #concatenate files
|
---|
217 | cat summary.html content.html matlaberror.html petscerror.html footer.html > report.html
|
---|
218 | rm summary.html content.html footer.html matlaberror.html petscerror.html matlab.log
|
---|