diff --git a/puppetboard/app.py b/puppetboard/app.py
index 0ac6db7..141fe5f 100644
--- a/puppetboard/app.py
+++ b/puppetboard/app.py
@@ -4,8 +4,12 @@ from __future__ import absolute_import
import os
import logging
import collections
-import urllib
+try:
+ from urllib import unquote
+except ImportError:
+ from urllib.parse import unquote
from datetime import datetime, timedelta
+from multiprocessing.dummy import Pool as ThreadPool
from flask import (
Flask, render_template, abort, url_for,
@@ -88,19 +92,17 @@ def index():
# TODO: Would be great if we could parallelize this somehow, doing these
# requests in sequence is rather pointless.
prefix = 'com.puppetlabs.puppetdb.query.population'
- num_nodes = get_or_abort(
- puppetdb.metric,
- "{0}{1}".format(prefix, ':type=default,name=num-nodes'))
- num_resources = get_or_abort(
- puppetdb.metric,
- "{0}{1}".format(prefix, ':type=default,name=num-resources'))
- avg_resources_node = get_or_abort(
- puppetdb.metric,
- "{0}{1}".format(prefix, ':type=default,name=avg-resources-per-node'))
+ pool = ThreadPool()
+ endpoints = [
+ "{0}{1}".format(prefix, ':type=default,name=num-nodes'),
+ "{0}{1}".format(prefix, ':type=default,name=num-resources'),
+ "{0}{1}".format(prefix, ':type=default,name=avg-resources-per-node'),
+ ]
+ fetched_metrics = pool.map(puppetdb.metric, endpoints)
metrics = {
- 'num_nodes': num_nodes['Value'],
- 'num_resources': num_resources['Value'],
- 'avg_resources_node': "{0:10.0f}".format(avg_resources_node['Value']),
+ 'num_nodes': fetched_metrics[0]['Value'],
+ 'num_resources': fetched_metrics[1]['Value'],
+ 'avg_resources_node': "{0:10.0f}".format(fetched_metrics[2]['Value']),
}
nodes = puppetdb.nodes(
@@ -284,10 +286,14 @@ def query():
if app.config['ENABLE_QUERY']:
form = QueryForm()
if form.validate_on_submit():
+ if form.query.data[0] == '[':
+ query = form.query.data
+ else:
+ query = '[{0}]'.format(form.query.data)
result = get_or_abort(
puppetdb._query,
form.endpoints.data,
- query='[{0}]'.format(form.query.data))
+ query=query)
return render_template('query.html', form=form, result=result)
return render_template('query.html', form=form)
else:
@@ -298,14 +304,14 @@ def query():
@app.route('/metrics')
def metrics():
metrics = get_or_abort(puppetdb._query, 'metrics', path='mbeans')
- for key, value in metrics.iteritems():
+ for key, value in metrics.items():
metrics[key] = value.split('/')[3]
return render_template('metrics.html', metrics=sorted(metrics.items()))
@app.route('/metric/ The request sent to PuppetDB was invalid. This is usually caused by using an unsupported operator. The request sent to PuppetDB was invalid. This is usually caused by using an unsupported operator. What you were looking for has been disabled by the administrator. What you were looking for has been disabled by the administrator. What you were looking for could not be found in PuppetDB. What you were looking for could not be found in PuppetDB. This error usually occurs because:
- Please have a look at the log output for further information. This error usually occurs because:
+ Bad Request
- Bad Request
+Permission Denied
- Permission Denied
+Not Found
- Not Found
+Internal Server Error
-
-
- Internal Server Error
+
+
Please have a look at the log output for further information.
{% endblock %} diff --git a/puppetboard/templates/_macros.html b/puppetboard/templates/_macros.html index ba70a69..3c0bad5 100644 --- a/puppetboard/templates/_macros.html +++ b/puppetboard/templates/_macros.html @@ -1,8 +1,8 @@ {% macro facts_table(facts, autofocus=False, condensed=False, show_node=False, show_value=True, link_facts=False, margin_top=20, margin_bottom=20) -%} -| Start time | @@ -119,7 +119,7 @@{{report.agent_version}} | {% endif %} {% if show_host_col %} -{{nodename}} | +{{ report.node }} | {% endif %} {% endfor %} diff --git a/puppetboard/templates/fact.html b/puppetboard/templates/fact.html index 9950d74..b6a9782 100644 --- a/puppetboard/templates/fact.html +++ b/puppetboard/templates/fact.html @@ -2,8 +2,8 @@ {% import '_macros.html' as macros %} {% block content %}
|---|
| Status | -Hostname | -- | ||||||
|---|---|---|---|---|---|---|---|---|
| - - {{node.status}} - - {% if node.status=='unreported'%} - {{ node.unreported_time }} - {% else %} - {% if node.events['failures'] %}{{node.events['failures']}}{% else %}0{% endif%} - {% if node.events['successes'] %}{{node.events['successes']}}{% else %}0{% endif%} - {% endif %} - | -{{ node.name }} | -
- {% if node.unreported_time != None or node.status != 'unreported' %}
- Latest Report
- {% else %}
- No Report
+ Nodes status detail ({{nodes|length}})+
Nodes status detail-
- Nothing seems to be changing.
-
+ Nodes status detail+ {% endif %} -{% endblock row_fluid %} +{% endblock content %} diff --git a/puppetboard/templates/layout.html b/puppetboard/templates/layout.html index a49e942..b7697d4 100644 --- a/puppetboard/templates/layout.html +++ b/puppetboard/templates/layout.html @@ -2,66 +2,52 @@ - |