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:
@@ -101,40 +101,35 @@ def index():
|
||||
'avg_resources_node': "{0:10.6f}".format(avg_resources_node['Value']),
|
||||
}
|
||||
|
||||
latest_event_count = puppetdb._query(
|
||||
'aggregate-event-counts',
|
||||
query='["=", "latest-report?", true]',
|
||||
summarize_by='certname')
|
||||
nodes = puppetdb.nodes(with_status=True)
|
||||
|
||||
latest_event_count['noopskip'] = (
|
||||
latest_event_count['noops'] + latest_event_count['skips'])
|
||||
nodes_overview = []
|
||||
stats = {
|
||||
'changed': 0,
|
||||
'unchanged': 0,
|
||||
'failed': 0,
|
||||
'unreported': 0,
|
||||
}
|
||||
|
||||
latest_events = puppetdb._query(
|
||||
'event-counts',
|
||||
query='["=", "latest-report?", true]',
|
||||
summarize_by='certname')
|
||||
for node in list(nodes):
|
||||
if node.status == 'unreported':
|
||||
stats['unreported'] += 1
|
||||
elif node.status == 'changed':
|
||||
stats['changed'] += 1
|
||||
elif node.status == 'failed':
|
||||
stats['failed'] += 1
|
||||
else:
|
||||
stats['unchanged'] += 1
|
||||
|
||||
unreported = []
|
||||
unresponsive_window = datetime.utcnow() - (
|
||||
timedelta(hours=app.config['UNRESPONSIVE_HOURS']))
|
||||
for node in puppetdb.nodes():
|
||||
try:
|
||||
node_last_seen = node.report_timestamp.replace(tzinfo=None)
|
||||
if node_last_seen < unresponsive_window:
|
||||
delta = (datetime.utcnow() - node_last_seen)
|
||||
node.noresponse = str(delta.days) + "d "
|
||||
node.noresponse += str(int(delta.seconds / 3600)) + "h "
|
||||
node.noresponse += str(int((delta.seconds % 3600) / 60)) + "m"
|
||||
unreported.append(node)
|
||||
except AttributeError:
|
||||
unreported.append(node)
|
||||
if node.status != 'unchanged':
|
||||
nodes_overview.append(node)
|
||||
|
||||
return render_template(
|
||||
'index.html',
|
||||
metrics=metrics,
|
||||
latest_event_count=latest_event_count,
|
||||
latest_events=latest_events,
|
||||
unreported=unreported)
|
||||
nodes=nodes_overview,
|
||||
stats=stats
|
||||
)
|
||||
|
||||
|
||||
@app.route('/nodes')
|
||||
@@ -169,7 +164,7 @@ def nodes():
|
||||
nodes.append(node)
|
||||
else:
|
||||
nodes.append(node)
|
||||
|
||||
nodes = puppetdb.nodes(with_status=True)
|
||||
return Response(stream_with_context(
|
||||
stream_template('nodes.html', nodes=nodes)))
|
||||
|
||||
|
||||
@@ -61,12 +61,29 @@ h1.success {
|
||||
h1.noop {
|
||||
color:#aaa;
|
||||
}
|
||||
.numtag {
|
||||
width:20px;
|
||||
.label-count {
|
||||
width:25px;
|
||||
text-align:center;
|
||||
}
|
||||
.label-time {
|
||||
width:73px;
|
||||
text-align:center;
|
||||
}
|
||||
.label-status {
|
||||
width:100px;
|
||||
text-align:center;
|
||||
}
|
||||
.label-nothing {
|
||||
background-color:#ddd;
|
||||
width:20px;
|
||||
color:#ddd;
|
||||
}
|
||||
.label.label-failed {
|
||||
background-color: rgb(231, 76, 60);
|
||||
}
|
||||
.label.label-changed {
|
||||
background-color: rgb(24, 188, 156);
|
||||
}
|
||||
.label.label-unreported {
|
||||
background-color: rgb(231, 76, 60);
|
||||
background-color: rgb(129, 145, 146);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,13 @@
|
||||
sortList: [[0, 0]]
|
||||
});
|
||||
|
||||
$('.dashboard').tablesorter({
|
||||
headers: {
|
||||
2: { sorter: false }
|
||||
},
|
||||
sortList: [[0, 0]]
|
||||
});
|
||||
|
||||
$('input.filter-table').parent('div').removeClass('hide');
|
||||
|
||||
$("input.filter-table").on("keyup", function(e) {
|
||||
|
||||
@@ -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'>
|
||||
<tbody class="searchable">
|
||||
{% for node in unreported %}
|
||||
<h2>Node Status Detail</h2>
|
||||
<table class='dashboard table table-striped table-condensed'>
|
||||
<thead>
|
||||
<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>
|
||||
<th style="width:220px;">Status</th>
|
||||
<th style="width:600px;">Hostname</th>
|
||||
<th style="width:120px;"></th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<h2>Latest reports with events</h2>
|
||||
<table class='nodes table table-striped table-condensed'>
|
||||
</thead>
|
||||
<tbody class="searchable">
|
||||
{% for event in latest_events %}
|
||||
{% for node in nodes %}
|
||||
{% if node.status != 'unchanged' %}
|
||||
<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>
|
||||
<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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user