source: issm/trunk/cron/report.sh@ 882

Last change on this file since 882 was 882, checked in by Mathieu Morlighem, 16 years ago

Added html report

File size: 3.6 KB
Line 
1#!/bin/bash
2#generate html report from nightly.log output file
3
4#get some variables
5function today_date {
6suffix=`date | awk '{printf("%s-%s-%s %s",$2,$3,$6,$4);}'`
7echo $suffix;
8}
9ISSM_RELEASE="issm";
10today=`today_date`;
11host_name=`hostname`;
12
13#Process log for errors
14cat nightly.log | grep 'package: macayeal' > macayeal.log
15cat nightly.log | grep 'package: ice' > ice.log
16cat nightly.log | grep 'package: cielo_serial' > cielo_serial.log
17cat nightly.log | grep 'package: cielo_parallel' > cielo_parallel.log
18cat nightly.log | grep NIGHTLYRUNTERMINATEDCORRECTLY > check.log
19cat nightly.log | grep ERROR | grep -v "PETSC ERROR"> errors.log
20cat nightly.log | grep SUCCESS > success.log
21cat errors.log success.log > tests.log
22mail -s "Nightly runs of $ISSM_RELEASE on: $host_name. Date:$today." mathieu.morlighem@jpl.nasa.gov < tests.log
23
24cat <<END > report.html
25<html>
26<title>ISSM - Nightly run Report</title>
27<body>
28
29<style type="text/css">
30 <!--
31 body {
32 width: 900px;
33 background:none;
34 font-family: Arial, Verdana, Tahoma;
35 font-size: 14px;
36 color: #404040;
37 margin: auto;}
38 h1 {
39 margin-top:1em;
40 background: transparent;
41 color: #6495ed;
42 font-size: 250%;
43 text-align: center;
44 }
45
46 h2 {
47 margin-top:1.5em;
48 background: transparent;
49 color: #6495ed;
50 font-size: 200%;
51 text-align: left;
52 }
53
54 .comment
55 {white-space:pre-wrap;
56 word-wrap:break-word;
57 padding:4px;
58 border:1px dashed #000000;
59 background-color:#ffffdd}
60 -->
61</style>
62<div>
63<br>
64<h1>ISSM Nightly run report</h1>
65<br>
66<pre class="comment">
67host: $host_name
68date: $today
69release: $ISSM_RELEASE
70
71remark: $(if [ `wc -l check.log | awk '{printf("%s",$1);}'` = "0" ];
72then
73 echo "stopped before the end"
74else
75 echo "all test desks have been run"
76fi
77rm check.log)
78number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}'; rm errors.log)
79number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}';rm success.log tests.log)</pre>
80<hr>
81
82$(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
83
84 #enter title
85 if [ $package == "macayeal" ]; then
86 echo "<h2>MacAyeal package</h2>"
87 fi
88 if [ $package == "ice" ]; then
89 echo "<h2>Ice package</h2>"
90 fi
91 if [ $package == "cielo_serial" ]; then
92 echo "<h2>Cielo Serial package</h2>"
93 fi
94 if [ $package == "cielo_parallel" ]; then
95 echo "<h2>Cielo Parallel package</h2>"
96 fi
97
98 #check that at least one test exists
99 if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
100 echo "&nbsp;&nbsp No test found."
101 else
102
103 echo "<table cellspacing="-1" width="900px">"
104 echo "<tr> <th>Result</th> <th>Tolerance</th> <th>Test</th> <th>Solution</th> <th>Field</th> </tr>"
105
106 # go through the lines of $package.log
107 for i in $(seq 1 1 `wc -l $package.log | awk '{printf("%s",$1);}'`); do
108
109 echo "<tr>"
110
111 #see wether it is success or error (get color: red or green)
112 if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$i'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
113 then
114 color="bgcolor=#ddffdd";
115 else
116 color="bgcolor=#ffdddd";
117 fi
118
119 #build html corresponding line
120 cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$i'o/ {printf("<td '$color'>%s</td><td '$color'> %s%s%s</td><td '$color'> %s</td><td '$color'> %s</td><td '$color'> %s</td>",$2,$3,$4,$5,$8,$10,$14);}';
121 echo "</tr>"
122 done
123
124 echo "</table>"
125 fi
126 rm $package.log
127done)
128
129 <br>
130 <center><small></a><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</small></center>
131</div>
132END
133
134echo Script has completed
Note: See TracBrowser for help on using the repository browser.