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
Line 
1#!/bin/bash
2#generate html report from nightly.log output file
3
4#----------------------------#
5# Initialize local variables #
6#----------------------------#
7
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}'`
17
18#Process matlab_log.log
19cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > matlab.log
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
25#style
26H1_STYLE='width="1000px" cellpadding="20"'
27H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
28
29H2_STYLE='width="900px" cellpadding="20"'
30H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
31
32TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
33TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
34
35MATLAB_STYLE='width="1000px" rules=none'
36MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
37
38BODY_STYLE='width="800px"'
39BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'
40
41FOOTER_STYLE='width="800px" cellpadding="10"'
42FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
43
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
62#-------------------#
63# build report.html #
64#-------------------#
65
66#first: summary
67cat << END > summary.html
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>
77<td $TABLE_FONT>OS: $OS</td>
78<td $TABLE_FONT>user: $USER</td>
79</tr>
80<tr>
81<td $TABLE_FONT>status: STATUS</td>
82<td $TABLE_FONT>release: $RELEASE</td>
83</tr>
84<tr>
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
95<td $TABLE_FONT>execution elapsed time: $EL_RUN</td>
96</tr>
97</table>
98<br><hr width="1000px">
99END
100
101#update status
102if [ $IS_RUN -eq 1 ]
103then
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
106else
107 if [ $IS_INSTALL -eq 1 ]
108 then
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
111 else
112 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
113 mv summary2.html summary.html
114 fi
115fi
116
117
118#report table
119if [ $IS_RUN -eq 1 ];
120then
121 cat << END > content.html
122<table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
123<table $(echo $BODY_STYLE) style="border-collapse:collapse;">
124<tr>
125<th $(echo $BODY_FONT)>Result</th>
126<th $(echo $BODY_FONT)>Tolerance</th>
127<th $(echo $BODY_FONT)>Test id</th>
128<th $(echo $BODY_FONT)>Test name</th>
129<th $(echo $BODY_FONT)>Field checked</th>
130</tr>
131$(cat matlab.log | while read line
132 do
133 echo "<tr>"
134
135 #get status
136 STATUS=`echo $line | awk '{print $1}'`
137
138 #FAILURE
139 if [ "$STATUS" = "FAILURE" ]
140 then
141
142 FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
143 FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
144 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
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);}
146 ';
147
148 else
149
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" '
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);}
164 ';
165 fi
166
167 echo "</tr>"
168
169 done
170 )
171</table>
172<br>
173END
174else
175 mktemp content.html
176fi
177
178#Matlab error report
179if [ -e matlaberror.log ]
180then
181 cat << END > matlaberror.html
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
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 content.html matlaberror.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.