1 | #!/bin/bash
|
---|
2 | #generate html report from nightly.log output file
|
---|
3 |
|
---|
4 | #get some variables
|
---|
5 | function today_date {
|
---|
6 | suffix=`date | awk '{printf("%s-%s-%s %s",$2,$3,$6,$4);}'`
|
---|
7 | echo $suffix;
|
---|
8 | }
|
---|
9 | ISSM_RELEASE="issm";
|
---|
10 | today=`today_date`;
|
---|
11 | host_name=`hostname`;
|
---|
12 |
|
---|
13 | #Process log for errors
|
---|
14 | cat nightly.log | grep 'package: macayeal' | grep -v "not supported yet" > macayeal.log
|
---|
15 | cat nightly.log | grep 'package: ice' | grep -v "not supported yet" > ice.log
|
---|
16 | cat nightly.log | grep 'package: cielo_serial' | grep -v "not supported yet" > cielo_serial.log
|
---|
17 | cat nightly.log | grep 'package: cielo_parallel'| grep -v "not supported yet" > cielo_parallel.log
|
---|
18 | cat nightly.log | grep NIGHTLYRUNTERMINATEDCORRECTLY > check.log
|
---|
19 | cat nightly.log | grep ERROR | grep -v "PETSC ERROR" > errors.log
|
---|
20 | cat nightly.log | grep SUCCESS > success.log
|
---|
21 | cat errors.log success.log > tests.log
|
---|
22 | #mail -s "Nightly runs of $ISSM_RELEASE on: $host_name. Date:$today." mathieu.morlighem@jpl.nasa.gov < tests.log
|
---|
23 |
|
---|
24 | #build report.html
|
---|
25 | cat <<END > report.html
|
---|
26 | <html>
|
---|
27 | <title>ISSM - Nightly run Report</title>
|
---|
28 | <body>
|
---|
29 |
|
---|
30 | <style type="text/css">
|
---|
31 | <!--
|
---|
32 | .issmbody {
|
---|
33 | margin: auto;
|
---|
34 | width:800px;
|
---|
35 | background: none;
|
---|
36 | color: #404040;
|
---|
37 | font-family: Arial, Verdana, Tahoma;
|
---|
38 | font-size: 14px;
|
---|
39 | font-weight: normal;
|
---|
40 | text-align: left;
|
---|
41 | }
|
---|
42 |
|
---|
43 | .issmh1 {
|
---|
44 | margin:2em auto;
|
---|
45 | width:800px;
|
---|
46 | background: none;
|
---|
47 | color: #6495ed;
|
---|
48 | font-family: Arial, Verdana, Tahoma;
|
---|
49 | font-size: 35px;
|
---|
50 | font-weight: bold;
|
---|
51 | text-align: center;
|
---|
52 | }
|
---|
53 |
|
---|
54 | .issmh2 {
|
---|
55 | margin:1.5em auto 1em auto;
|
---|
56 | width:800px;
|
---|
57 | background: transparent;
|
---|
58 | color: #6495ed;
|
---|
59 | font-family: Arial, Verdana, Tahoma;
|
---|
60 | font-weight: bold;
|
---|
61 | font-size: 28px;
|
---|
62 | text-align: left;
|
---|
63 | }
|
---|
64 |
|
---|
65 | .issmfooter {
|
---|
66 | margin:auto;
|
---|
67 | width:800px;
|
---|
68 | background: none;
|
---|
69 | color: #404040;
|
---|
70 | font-family: Arial, Verdana, Tahoma;
|
---|
71 | font-size: 12px;
|
---|
72 | font-weight: normal;
|
---|
73 | text-align: center;
|
---|
74 | }
|
---|
75 |
|
---|
76 | .issmcomment {
|
---|
77 | padding:4px;
|
---|
78 | margin:0 auto;
|
---|
79 | width:800px;
|
---|
80 | border:1px dashed #000000;
|
---|
81 | text-align: left;
|
---|
82 | font-family: Arial, Verdana, Tahoma;
|
---|
83 | font-size: 14px;
|
---|
84 | color: #404040;
|
---|
85 | background-color:#ffffdd}
|
---|
86 | -->
|
---|
87 | </style>
|
---|
88 | <div class="issmh1">ISSM Nightly run report</div>
|
---|
89 | <br>
|
---|
90 | <div class="issmcomment">
|
---|
91 | host: $host_name<br>
|
---|
92 | date: $today<br>
|
---|
93 | release: $ISSM_RELEASE<br>
|
---|
94 | <br>
|
---|
95 | status: $(if [ `wc -l check.log | awk '{printf("%s",$1);}'` = "0" ];
|
---|
96 | then
|
---|
97 | echo "<span style=\"color:#FF0000\">stopped before the end</span>"
|
---|
98 | else
|
---|
99 | echo "all test desks have been run"
|
---|
100 | fi
|
---|
101 | rm check.log)
|
---|
102 | <br>
|
---|
103 | number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}'; rm errors.log)<br>
|
---|
104 | number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}';rm success.log tests.log)</div>
|
---|
105 | <br>
|
---|
106 | <hr width="900px">
|
---|
107 |
|
---|
108 | $(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
|
---|
109 |
|
---|
110 | #enter title
|
---|
111 | if [ $package == "macayeal" ]; then
|
---|
112 | echo "<div class=\"issmh2\">MacAyeal package</div>"
|
---|
113 | fi
|
---|
114 | if [ $package == "ice" ]; then
|
---|
115 | echo "<div class=\"issmh2\">Ice package</div>"
|
---|
116 | fi
|
---|
117 | if [ $package == "cielo_serial" ]; then
|
---|
118 | echo "<div class=\"issmh2\">Cielo Serial package</div>"
|
---|
119 | fi
|
---|
120 | if [ $package == "cielo_parallel" ]; then
|
---|
121 | echo "<div class=\"issmh2\">Cielo Parallel package</div>"
|
---|
122 | fi
|
---|
123 |
|
---|
124 | #Print division
|
---|
125 | echo "<div class=\"issmbody\">"
|
---|
126 |
|
---|
127 | #check that at least one Test exists
|
---|
128 | if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
|
---|
129 |
|
---|
130 | #No Test: use a table to fix entourage bug.
|
---|
131 | echo "<table width=\"200px\" style=\"color:#FF0000; font-size:14px;\"><tr><td align=\"center\">No test found.</td></tr></table>"
|
---|
132 |
|
---|
133 | else
|
---|
134 |
|
---|
135 | echo "<table cellspacing=\"-1\" width=\"800px\" style=\"font-family: Arial, Verdana, Tahoma; color: #404040;\">"
|
---|
136 | echo "<tr> <th style=\"font-size:14px;\">Result</th> <th style=\"font-size:14px;\">Tolerance</th> <th style=\"font-size:14px;\">Test</th> <th style=\"font-size:14px;\">Solution</th> <th style=\"font-size:14px;\">Field</th> </tr>"
|
---|
137 |
|
---|
138 | # go through the lines of $package.log
|
---|
139 | for i in $(seq 1 1 `wc -l $package.log | awk '{printf("%s",$1);}'`); do
|
---|
140 |
|
---|
141 | echo "<tr>"
|
---|
142 |
|
---|
143 | #see wether it is success or error (get color: red or green)
|
---|
144 | if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$i'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
|
---|
145 | then
|
---|
146 | color="bgcolor=#ddffdd";
|
---|
147 | else
|
---|
148 | color="bgcolor=#ffdddd";
|
---|
149 | fi
|
---|
150 |
|
---|
151 | #build html corresponding line
|
---|
152 | cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$i'o/ {printf("<td '$color' style=\"font-size:14px;\">%s</td><td '$color' style=\"font-size:14px;\"> %s%s%s</td><td '$color' style=\"font-size:14px;\"> %s</td><td '$color' style=\"font-size:14px;\"> %s</td><td '$color' style=\"font-size:14px;\"> %s</td>",$2,$4,$5,$6,$8,$10,$14);}';
|
---|
153 | echo "</tr>"
|
---|
154 | done
|
---|
155 |
|
---|
156 | echo "</table>"
|
---|
157 | fi
|
---|
158 |
|
---|
159 | #Print end division and remove log file
|
---|
160 | echo "</div>"
|
---|
161 | rm $package.log
|
---|
162 |
|
---|
163 | done)
|
---|
164 |
|
---|
165 | <br>
|
---|
166 | <br>
|
---|
167 | <div class="issmfooter"><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</div>
|
---|
168 | </body>
|
---|
169 | </html>
|
---|
170 | END
|
---|