Permalink
Browse files

added reports folder; added JS assets

also removed reports folder existence/creation work

Change-Id: I35becc9c0bb6fcfe5062fc6bb1ee18027f624a98
  • Loading branch information...
1 parent 07de00d commit 6cd49bc2b436c3902ac6976316ab02f78d242503 @BigBlueHat BigBlueHat committed Jun 29, 2012
Showing with 59 additions and 8 deletions.
  1. +4 −0 .gitignore
  2. +9 −6 analyzer.py
  3. +5 −1 cbhealthchecker
  4. +11 −1 report-htm.tmpl
  5. +28 −0 reports/app.js
  6. +2 −0 reports/zepto.min.js
View
@@ -1,2 +1,6 @@
*.pyc
.pydevproject
+reports/*.html
+reports/*.txt
+reports/*.json
+
View
@@ -4,6 +4,7 @@
import logging
import traceback
import string
+import fnmatch
import util_cli as util
import cluster_stats
@@ -266,12 +267,6 @@ def run_analysis(self, scale):
def run_report(self, txtfile, htmlfile, verbose, scale, debug):
working_dir = os.path.dirname(sys.argv[0])
reports_dir = os.path.join(working_dir, 'reports')
- try:
- os.mkdir(reports_dir)
- except OSError:
- # directory exists, and that's OK
- pass
-
txtfile = os.path.join(reports_dir, txtfile)
htmlfile = os.path.join(reports_dir, htmlfile)
@@ -324,3 +319,11 @@ def run_report(self, txtfile, htmlfile, verbose, scale, debug):
f = open(htmlfile, 'w')
print >> f, Template(file=os.path.join(working_dir, "report-htm.tmpl"), searchList=[dict])
f.close()
+
+ # generate array/list of available reports for use via AJAX
+ available_reports = [os.path.splitext(n)[0]
+ for n in fnmatch.filter(os.listdir('./reports/'),
+ '*.html')]
+ f = open(os.path.join(reports_dir, 'all.json'), 'w')
+ print >> f, util.pretty_print(available_reports)
+ f.close()
View
@@ -7,6 +7,7 @@ import os
import traceback
import copy
import logging
+import time
import collector
import analyzer
@@ -20,7 +21,10 @@ log.setLevel(logging.INFO)
log.addHandler(logging.StreamHandler())
def parse_opt():
- (bucket, cluster, user, password, txtfile, htmlfile, statsfile, verbose, debug, inputfile, scale, statsonly) = ('all', '', '', '', 'clusterstats.txt', 'health_report.html', 'stats.json', False, False, '', 'day', False)
+ time_file_name = time.strftime('%Y-%m-%d_%H-%M-%S')
+ (bucket, cluster, user, password, txtfile, htmlfile, statsfile, verbose, debug,
+ inputfile, scale, statsonly) = ('all', '', '', '', time_file_name + '.txt',
+ time_file_name + '.html', time_file_name + '.json', False, False, '', 'day', False)
try:
(opts, _args) = getopt.getopt(sys.argv[1:],
View
@@ -62,11 +62,12 @@
thead {display: table-header-group;}
tr {page-break-inside: avoid;}
+ nav {display: none}
article {page-break-after: always}
</style>
<!-- screen only styles -->
<style type="text/css" media="screen">
- body {margin:10%;padding:0;font:16px 'Arial';background:#FCFDFB}
+ body {margin:10% 10% 10% 0;padding:0;font:16px 'Arial';background:#FCFDFB}
h1 {padding-left: 2px;margin-top: 0px;margin-bottom: 0px;font-size:25px;line-height:30px}
h2 {font: bold 21px 'Arial';line-height: 24px;}
@@ -87,10 +88,16 @@
.t1, .t3{border-collapse: collapse;}
.t1{margin-left: 26px;margin-top: 51px;}
+
+ #sidebar {float: left;padding:15px}
+ #sidebar ul {list-style:none;margin:0;padding:0}
+ #main {margin-left:12em}
</style>
</head>
<body>
+<nav id="sidebar"></nav>
+<section id="main">
<h1>Couchbase Cluster Health Check Report</h1>
<p class="p1"><span class="ft1">Tool Version: $globals['versions']</span></p>
<p class="p0"><span class="ft1">Stats Scale : $scale</span></p>
@@ -306,5 +313,8 @@
#end for
</article>
#end if
+</section>
+<script src="zepto.min.js"></script>
+<script src="app.js"></script>
</body>
</html>
View
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2012, Couchbase, Inc.
+ * All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+
+Zepto(function($) {
+ $.getJSON('all.json',
+ function(data) {
+ $reports = $('<ul>').appendTo('#sidebar');
+ $.each(data, function(key, val) {
+ $reports.append('<li><a href="' + val + '.html">' + val + '</a></li>');
+ });
+ });
+})

0 comments on commit 6cd49bc

Please sign in to comment.