diff --git a/puppetboard/app.py b/puppetboard/app.py index 2808ee5..a871b68 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -5,6 +5,7 @@ import os import logging import collections import urllib +from datetime import datetime, timedelta from flask import ( Flask, render_template, abort, url_for, @@ -101,7 +102,15 @@ def index(): latest_events = puppetdb._query('event-counts', query='["=", "latest-report?", true]', summarize_by='certname') - return render_template('index.html', metrics=metrics, latest_event_count=latest_event_count, latest_events=latest_events) + unreported = [] + for node in puppetdb.nodes(): + node_last_seen = node.report_timestamp.replace(tzinfo=None) + if node_last_seen < (datetime.utcnow()-timedelta(hours=app.config['UNRESPONSIVE_HOURS'])): + delta = (datetime.utcnow()-node_last_seen) + node.noresponse = str(delta.days) + "d " + str(int(delta.seconds/3600)) +"h " + str(int((delta.seconds%3600)/60))+ "m" + unreported.append(node) + + return render_template('index.html', metrics=metrics, latest_event_count=latest_event_count, latest_events=latest_events, unreported=unreported, unreported_time=app.config['UNRESPONSIVE_HOURS']) @app.route('/nodes') def nodes(): diff --git a/puppetboard/default_settings.py b/puppetboard/default_settings.py index d9dd533..0421bdd 100644 --- a/puppetboard/default_settings.py +++ b/puppetboard/default_settings.py @@ -7,5 +7,6 @@ PUPPETDB_TIMEOUT=20 PUPPETDB_API=3 DEV_LISTEN_HOST='127.0.0.1' DEV_LISTEN_PORT=5000 +UNRESPONSIVE_HOURS=2 ENABLE_QUERY=True LOGLEVEL='info' diff --git a/puppetboard/static/css/puppetboard.css b/puppetboard/static/css/puppetboard.css index f535a8c..49d18d1 100644 --- a/puppetboard/static/css/puppetboard.css +++ b/puppetboard/static/css/puppetboard.css @@ -65,3 +65,8 @@ h1.noop { width:20px; text-align:center; } +.label-nothing { + background-color:#ddd; + width:20px; + color:#ddd; +} diff --git a/puppetboard/templates/index.html b/puppetboard/templates/index.html index acf561c..e11489b 100644 --- a/puppetboard/templates/index.html +++ b/puppetboard/templates/index.html @@ -8,16 +8,16 @@
-

{{latest_event_count['failures']}} Failures

- in the latest node reports +

{{latest_event_count['failures']}} Failed

+ nodes in the latest reports
-

{{latest_event_count['successes']}} Successes

- in the latest node reports +

{{latest_event_count['successes']}} Succeeded

+ nodes in the latest reports
-

{{latest_event_count['noopskip']}} Noop/Skip

- in the latest node reports +

{{ unreported|length }} Unreported

+ nodes in the last {{ unreported_time }} hours
@@ -53,21 +53,34 @@
+

Nodes without Report since {{ unreported_time }} hours

+ + + {% for node in unreported %} + + + + + + + {% endfor %} + +
No Report{{ node.noresponse }}{{ node.name }}Latest Report

Latest Reports with events

-
- - - {% for event in latest_events %} - - - - - - - - {% endfor %} - -
{% if event['failures'] %}{{event['failures']}}{% endif%}{% if event['successes'] %}{{event['successes']}}{% endif%}{{event['subject']['title']}}Latest Report
+ + + {% for event in latest_events %} + + + + + + {% endfor %} + +
+ {% if event['failures'] %}{{event['failures']}}{% else %}0{% endif%} + {% if event['successes'] %}{{event['successes']}}{% else %}0{% endif%} + {{event['subject']['title']}}Latest Report
diff --git a/puppetboard/templates/nodes.html b/puppetboard/templates/nodes.html index bb879c8..c1e30d5 100644 --- a/puppetboard/templates/nodes.html +++ b/puppetboard/templates/nodes.html @@ -18,7 +18,7 @@ - + {% if config.PUPPETDB_API > 2 %} @@ -30,15 +30,11 @@ {% for node in nodes %} - @@ -52,6 +48,7 @@ diff --git a/requirements.txt b/requirements.txt index ae82b13..1b3318c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,5 @@ MarkupSafe==0.18 WTForms==1.0.4 Werkzeug==0.9.3 itsdangerous==0.22 -git+https://github.com/juliushaertl/pypuppetdb.git@feature-v3-newapis#egg=pypuppetdb +git+https://github.com/nedap/pypuppetdb#egg=pypuppetdb requests==1.2.3
StatusStatus Hostname Catalog compiled at
- {% if node.status %} - {% if node.status['failures'] %}{{node.status['failures']}}{% endif %} - {% if node.status['successes'] %}{{node.status['successes']}}{% endif %} - {% if node.status['noops'] or node.status['skips'] %}{{node.status['skips']+node.status['noops']}}{% endif %} - {% else %} - 0 - {% endif %} - + + {% if node.status['failures'] %}{{node.status['failures']}}{% else %}0{% endif %} + {% if node.status['successes'] %}{{node.status['successes']}}{% else %}0{% endif %} + {% if node.status['noops'] or node.status['skips'] %}{{node.status['skips']+node.status['noops']}}{% else %}0{% endif %} + {{node.name}} {{node.catalog_timestamp}} {% if node.report_timestamp %} + Latest Report Reports {% endif %}