Enhance node status feature in overview and nodes

This commit uses the new parameter with_status from nedap/pypuppetdb#18

Node status is now shown as text with the additional information of
failed/succeded events, unreported time

The statistics on Overview now show the *number of nodes*
that have status failed/changed/unreported
This commit is contained in:
Julius Härtl
2013-11-05 10:07:53 +01:00
parent a84da91f06
commit f187638b6e
5 changed files with 96 additions and 63 deletions

View File

@@ -1,25 +1,31 @@
{% extends 'layout.html' %}
{% block row_fluid %}
<div class="container" style="margin-bottom:55px;">
<div class="row">
<div class="span12">
<div class="span4 stat">
<a href="nodes?status=failures">
<h1 class="error">{{latest_event_count['failures']}} <small>node(s)</small></h1>
<h1 class="error">{{stats['failed']}}
<small>{% if stats['failed']== 1 %} node {% else %} nodes {% endif %}</small>
</h1>
</a>
<span>with failures in latest reports</span>
<span>with status failed</span>
</div>
<div class="span4 stat">
<a href="nodes?status=successes">
<h1 class="success">{{latest_event_count['successes']}} <small>node(s)</small></h1>
<h1 class="success">{{stats['changed']}}
<small>{% if stats['changed']== 1 %} node {% else %} nodes {% endif %}</small>
</h1>
</a>
<span>with successes in latest reports</span>
<span>with status changed</span>
</div>
<div class="span4 stat">
<h1 class="noop">{{ unreported|length }} <small>unreported</small></h1>
<h1 class="noop">{{ stats['unreported'] }}
<small>{% if stats['unreported']== 1 %} node {% else %} nodes {% endif %}</small>
</h1>
<span>
{% if unreported|length == 1 %} node {% else %} nodes {% endif %}
in the last {{ config.UNRESPONSIVE_HOURS }} hours
unreported in the last {{ config.UNRESPONSIVE_HOURS }} hours
</span>
</div>
</div>
@@ -44,34 +50,38 @@
<div class="row">
<div class="span12">
<h2>Nodes unresponsive in the last {{ config.UNRESPONSIVE_HOURS }} hours</h2>
<table class='nodes table table-striped table-condensed'>
<h2>Node Status Detail</h2>
<table class='dashboard table table-striped table-condensed'>
<thead>
<tr>
<th style="width:220px;">Status</th>
<th style="width:600px;">Hostname</th>
<th style="width:120px;"></th>
</tr>
</thead>
<tbody class="searchable">
{% for node in unreported %}
{% for node in nodes %}
{% if node.status != 'unchanged' %}
<tr>
<td style="width:110px;"><span class="label label-important">No Report</span></td>
<td>{{ node.noresponse }}</td>
<td><a href="{{url_for('node', node_name=node.name)}}">{{ node.name }}</a></td>
<td style="width:120px;"><a class="btn btn-small btn-primary" href="{{url_for('report_latest', node_name=node.name)}}">Latest Report</a></td>
</tr>
{% endfor %}
</tbody>
</table>
<h2>Latest reports with events</h2>
<table class='nodes table table-striped table-condensed'>
<tbody class="searchable">
{% for event in latest_events %}
<tr>
<td style="width:110px;">
{% if event['failures'] %}<span class="label label-important numtag">{{event['failures']}}</span>{% else %}<span class="label numtag">0</span>{% endif%}
{% if event['successes'] %}<span class="label label-success numtag">{{event['successes']}}</span>{% else %}<span class="label numtag">0</span>{% endif%}
<td>
<a href="{{url_for('report_latest', node_name=node.name)}}">
<span class="label label-status label-{{node.status}}">{{node.status}}</span>
</a>
{% if node.status=='unreported'%}
<span class="label label-time label-unreported"> {{ node.unreported_time }} </label>
{% else %}
{% if node.events['failures'] %}<span class="label label-important label-count">{{node.events['failures']}}</span>{% else %}<span class="label label-count">0</span>{% endif%}
{% if node.events['successes'] %}<span class="label label-success label-count">{{node.events['successes']}}</span>{% else %}<span class="label label-count">0</span>{% endif%}
{% endif %}
</td>
<td style="width:700px;"><a href="{{url_for('node', node_name=event['subject']['title'])}}">{{event['subject']['title']}}</a></td>
<td style="width:120px;"><a class="btn btn-small btn-primary" href="{{url_for('report_latest', node_name=event['subject']['title'])}}">Latest Report</a></td>
</tr>
<td><a href="{{url_for('node', node_name=node.name)}}">{{ node.name }}</a></td>
<td><a class="btn btn-small btn-primary" href="{{url_for('report_latest', node_name=node.name)}}">Latest Report</a></td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>

View File

@@ -29,10 +29,14 @@
{% for node in nodes %}
<tr>
<td><a href="{{url_for('report_latest', node_name=node.name)}}">
{% if node.status['failures'] %}<span class="label numtag label-important">{{node.status['failures']}}</span>{% else %}<span class="label label-nothing">0</span>{% endif %}
{% if node.status['successes'] %}<span class="label numtag label-success">{{node.status['successes']}}</span>{% else %}<span class="label label-nothing">0</span>{% endif %}
{% if node.status['noops'] or node.status['skips'] %}<span class="label numtag">{{node.status['skips']+node.status['noops']}}</span>{% else %}<span class="label label-nothing">0</span>{% endif %}
<span class="label label-status label-{{ node.status }}">{{ node.status }}</span>
</a>
{% if node.status=='unreported'%}
<span class="label label-time label-unreported"> {{ node.unreported_time }} </label>
{% else %}
{% if node.events['failures'] %}<span class="label label-count label-important">{{node.events['failures']}}</span>{% else %}<span class="label label-count">0</span>{% endif%}
{% if node.events['successes'] %}<span class="label label-count label-success">{{node.events['successes']}}</span>{% else %}<span class="label label-count">0</span>{% endif%}
{% endif %}
</td>
<td><a href="{{url_for('node', node_name=node.name)}}">{{node.name}}</a></td>
<td rel="utctimestamp">{{node.catalog_timestamp}}</td>