source: issm/trunk/cron/report2.sh@ 5022

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

Added report2.sh and fixed cluster.rc

  • Property svn:executable set to *
File size: 6.0 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/TEMP/
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' | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > 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="800px"'
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) style="border-collapse:collapse;">
127<tr>
128<th $(echo $BODY_FONT)>Result</th>
129<th $(echo $BODY_FONT)>Tolerance</th>
130<th $(echo $BODY_FONT)>Test id</th>
131<th $(echo $BODY_FONT)>Test name</th>
132<th $(echo $BODY_FONT)>Field checked</th>
133</tr>
134$(cat matlab.log | while read line
135 do
136 echo "<tr>"
137
138 #get status
139 STATUS=`echo $line | awk '{print $1}'`
140
141 #FAILURE
142 if [ "$STATUS" = "FAILURE" ]
143 then
144
145 FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
146 FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
147 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
148 { 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);}
149 ';
150
151 else
152
153 #SUCCESS
154 if [ "$STATUS" = "SUCCESS" ]
155 then
156 color="bgcolor=#ddffdd";
157
158 #ERROR
159 else
160 color="bgcolor=#ffdddd";
161 fi
162
163 FONTC=$(echo "$BODY_FONTC $color")
164 FONTL=$(echo "$BODY_FONTL $color")
165 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
166 { 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);}
167 ';
168 fi
169
170 echo "</tr>"
171
172 done
173 )
174</table>
175<br>
176END
177else
178 mktemp content.html
179fi
180
181#Matlab error report
182if [ -e matlaberror.log ]
183then
184 cat << END > matlaberror.html
185<table $H2_STYLE><tr><td $H2_FONT>Matlab error</td></tr></table>
186<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
187<pre>$(cat matlaberror.log)</pre>
188</td></tr></table>
189END
190else
191 mktemp matlaberror.html
192fi
193
194#last footer
195cat << END > footer.html
196<br>
197<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>
198</div>
199END
200
201#concatenate files
202cat summary.html content.html matlaberror.html footer.html > report.html
203rm summary.html content.html footer.html matlaberror.html matlab.log
Note: See TracBrowser for help on using the repository browser.