Skip to content
Browse files

Add anchor and link with the report

  • Loading branch information...
1 parent 71cd516 commit 145dbc7e7469c52c5d654ab4abf8e3e5c24a4778 @bcui6611 bcui6611 committed Aug 23, 2012
Showing with 32 additions and 49 deletions.
  1. +12 −6 analyzer.py
  2. +1 −1 cbhealthchecker
  3. +19 −42 reports/template.tmpl
View
18 analyzer.py
@@ -43,14 +43,16 @@ class UtilTool:
def isdict(self, obj):
return isinstance(obj, dict)
- def statsClass(self, status):
+ def statsClass(self, status, hasOkStatus=True):
if status == "Error":
- return "status-error"
+ return ["status-error", "Immediate action needed"]
elif status == "Warning":
- return "status-warning"
+ return ["status-warning", "Attention needed"]
else:
- return "status-ok"
-
+ if hasOkStatus:
+ return ["status-ok", "OK"]
+ else:
+ return ["", "OK"]
class StatsAnalyzer:
def __init__(self, log):
self.log = log
@@ -59,7 +61,7 @@ def run_analysis(self, scale):
for bucket in stats_buffer.buckets.iterkeys():
bucket_type = stats_buffer.bucket_info[bucket]['bucketType']
- bucket_list[bucket] = {"status":"OK", "type":bucket_type}
+ bucket_list[bucket] = {"status":"OK", "type":bucket_type, "anchor":None}
bucket_symptoms[bucket] = []
bucket_node_symptoms[bucket] = {}
bucket_node_status[bucket] = {}
@@ -186,6 +188,7 @@ def run_analysis(self, scale):
for val in values["error"]:
bucket_node_status[bucket][val["node"]] = "Error"
bucket_list[bucket]["status"] = "Error"
+ bucket_list[bucket]["anchor"] = "counter_%s_%s_%s" % (bucket, val["node"], counter["name"])
if values.has_key("warn"):
if indicator_warn.has_key(counter["name"]) == False:
indicator_warn[counter["name"]] = []
@@ -217,6 +220,7 @@ def run_analysis(self, scale):
bucket_node_status[bucket][node_val] = "Warning"
if bucket_list[bucket]["status"] == "OK":
bucket_list[bucket]["status"] = "Warning"
+ bucket_list[bucket]["anchor"] = "counter_%s_%s_%s" % (bucket, node_val, counter["name"])
elif type(values) is list:
for val in values:
if val[0] == "error":
@@ -243,6 +247,7 @@ def run_analysis(self, scale):
for node in val[1]:
bucket_node_status[bucket][node["node"]] = "Error"
bucket_list[bucket]["status"] = "Error"
+ bucket_list[bucket]["anchor"] = "counter_%s_%s_%s" % (bucket, node["node"], counter["name"])
elif val[0] == "warn":
if indicator_warn.has_key(counter["name"]) == False:
indicator_warn[counter["name"]] = []
@@ -269,6 +274,7 @@ def run_analysis(self, scale):
bucket_node_status[bucket][node["node"]] = "Warning"
if bucket_list[bucket]["status"] == "OK":
bucket_list[bucket]["status"] = "Warning"
+ bucket_list[bucket]["anchor"] = "counter_%s_%s_%s" % (bucket, node["node"], counter["name"])
except Exception, err:
self.log.error("Exception launched when processing counter: {0}".format(counter["name"]))
traceback.print_exc()
View
2 cbhealthchecker
@@ -24,7 +24,7 @@ def parse_opt():
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)
+ time_file_name + '.html', time_file_name + '.json', True, False, '', 'day', False)
try:
(opts, _args) = getopt.getopt(sys.argv[1:],
View
61 reports/template.tmpl
@@ -21,13 +21,8 @@
<p class="p0"><span class="ft1">Execution Time: $globals['report_time'].strftime("%Y-%m-%d %H:%M:%S")</span></p>
<p>
<strong>Overall cluster health:</strong>
-#if $globals.cluster_health == "Error"
- <span class="status-error">Immediate action needed</span>
-#elif $globals.cluster_health == "Warning"
- <span class="status-warning">Attention needed</span>
-#else
- <span class="status-ok">OK</span>
-#end if
+#set $cluster_status = $util.statsClass($globals.cluster_health)
+ <span class="$cluster_status[0]">$cluster_status[1]</span>
</p>
#if $indicator_error_exist
@@ -40,10 +35,11 @@
<h4>$error_values["description"] - <strong class="status-error">$error_values["cause"]</strong></h4>
<ul>
#for $err_val in sorted($error_values["value"])
+ <a name="counter_${error_values["bucket"]}_${err_val["node"]}_${counter}"/>
#if $err_val["node"] == "total"
- <li>Symptom in <em>$error_values["bucket"]</em> bucket:</em>
+ <li>Symptom in <em><a href="#bucket_$error_values["bucket"]">$error_values["bucket"]</a></em> bucket:</em>
#else
- <li>Symptom in <em>$error_values["bucket"]</em> bucket on <em>$err_val["node"] node(s):</em>
+ <li>Symptom in <em><a href="#bucket_$error_values["bucket"]">$error_values["bucket"]</a></em> bucket on <em><a href="#node_${error_values["bucket"]}_${err_val["node"]}">$err_val["node"]:</a></em>
#end if
<ul>
<li><strong>$err_val["value"]</strong></li>
@@ -70,11 +66,11 @@
</tr>
</thead>
#for $bucket in sorted($bucket_list.keys())
- #set $bucket_status_class = 'status-' + $bucket_list[$bucket]["status"].lower()
+ #set $bucket_status = $util.statsClass($bucket_list[$bucket]["status"])
<tr>
- <td>$bucket</td>
+ <td><a href="#bucket_${bucket}">$bucket</a></td>
<td>$bucket_list[$bucket]["type"]</td>
- <td class="$bucket_status_class">$bucket_list[$bucket]["status"]</td>
+ <td class="$bucket_status[0]"><a href="#${bucket_list[$bucket]["anchor"]}">$bucket_status[1]</a></td>
</tr>
#end for
</table>
@@ -131,27 +127,17 @@
<h3>Bucket metrics</h3>
#for $bucket in sorted($bucket_list.keys())
#set $status = $bucket_list[$bucket]["status"]
+ <a name="bucket_${bucket}"/>
<p class="bucket">
<strong>Bucket: </strong> $bucket &ndash;
- #if $status == "Error"
- <span class="status-error">Immediate action needed</span>
- #elif $status == "Warning"
- <span class="status-warning">Attention needed</span>
- #else
- <span class="status-ok">OK</span>
- #end if
+ #set $bucket_status = $util.statsClass($status)
+ <a href="#$bucket_list[$bucket]["anchor"]"><span class="$bucket_status[0]">$bucket_status[1]</span></a>
</p>
<table class="t1">
#for $symptom in sorted($bucket_symptoms[$bucket])
<tr>
<td title="$symptom["formula"]">$symptom["description"]</td>
- #if $symptom["status"] == "Error"
- #set $statusClass = "status-error"
- #elif $symptom["status"] == "Warning"
- #set $statusClass = "status-warning"
- #else
- #set $statusClass = ""
- #end if
+ #set $statusClass = $util.statsClass($symptom["status"], False)[0]
#if $util.isdict($symptom["value"])
#if $debug
<td class="$statusClass" title="$symptom["value"]["raw"]">$symptom["value"]["value"]</td>
@@ -167,15 +153,11 @@
#if $verbose
#for $node in sorted($bucket_node_symptoms[$bucket])
#set $node_values = $bucket_node_symptoms[$bucket][$node]
+ <a name="node_${bucket}_${node}"/>
<p class="node"><strong>Node: </strong> $node &ndash;
#if $bucket_node_status[$bucket].has_key($node)
- #if $bucket_node_status[$bucket][$node] == "Error"
- <span class="status-error">Immediate action needed</span>
- #elif $bucket_node_status[$bucket][$node] == "Warning"
- <span class="status-warning">Attention needed</span>
- #else
- <span class="status-ok">OK</span>
- #end if
+ #set $node_status = $util.statsClass($bucket_node_status[$bucket][$node])
+ <span class="$node_status[0]">$node_status[1]</span>
#else
<span class="status-ok">OK</span>
#end if
@@ -188,13 +170,7 @@
#else
<td>$node_value["description"]</td>
#end if
- #if $node_value["status"] == "Error"
- #set $statusClass = "status-error"
- #elif $node_value["status"] == "Warning"
- #set $statusClass = "status-warning"
- #else
- #set $statusClass = ""
- #end if
+ #set $statusClass = $util.statsClass($node_value["status"], False)[0]
#if $util.isdict($node_value["value"])
#if $debug
<td class="$statusClass" title="$node_value["value"]["raw"]">$node_value["value"]["value"]</td>
@@ -221,10 +197,11 @@
<h4>$warn_values["description"] - <span class="status-warning">$warn_values["cause"]</span></h4>
<ul>
#for $warn_val in sorted($warn_values["value"])
+ <a name="counter_${warn_values["bucket"]}_${warn_val["node"]}_${counter}"/>
#if $warn_val["node"] == "total"
- <li>Symptom in <em>$warn_values["bucket"]</em> bucket:
+ <li>Symptom in <em><a href="#bucket_$warn_values["bucket"]">$warn_values["bucket"]</a></em> bucket:
#else
- <li>Symptom in <em>$warn_values["bucket"]</em> bucket on <em>$warn_val["node"]</em> node(s):
+ <li>Symptom in <em><a href="#bucket_$warn_values["bucket"]">$warn_values["bucket"]</a></em> bucket on <em><a href="#node_${warn_values["bucket"]}_${warn_val["node"]}">$warn_val["node"]</a></em>:
#end if
<ul>
<li><strong>$warn_val["value"]</strong></li>

0 comments on commit 145dbc7

Please sign in to comment.
Something went wrong with that request. Please try again.