Skip to content

Commit

Permalink
Merge pull request #91 from flask-dashboard/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
mircealungu committed Apr 24, 2018
2 parents 14d7420 + e6a57dd commit aec3370
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion flask_monitoringdashboard/routings/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import math
import plotly
import plotly.graph_objs as go
import ast

from flask import session, url_for, render_template, request
from flask_wtf import FlaskForm
Expand Down Expand Up @@ -93,8 +94,10 @@ def result_time_per_user(end):
def result_outliers(end):
rule = get_monitor_rule(end)
url = get_url(end)
table = get_outliers_sorted(end, Outlier.execution_time)
mean_cpu = get_mean_cpu(table)
return render_template('endpoint/outliers.html', link=config.link, session=session, rule=rule, url=url,
end=end, index=7, table=get_outliers_sorted(end, Outlier.execution_time))
end=end, index=7, table=table, mean=mean_cpu)


def formatter(ms):
Expand Down Expand Up @@ -408,3 +411,22 @@ def get_time_per_user(end):
)
graph = plotly.offline.plot(go.Figure(data=data, layout=layout), output_type='div', show_link=False)
return graph, form

def get_mean_cpu(outliers):
""" Returns a list containing mean CPU percentages per core for all given outliers."""
if not outliers:
return None

count = 0 # some outliers have no CPU info
values = [] # list of lists that stores the CPU inf

for outlier in outliers:
if not outlier.cpu_percent:
continue
x = ast.literal_eval(outlier.cpu_percent)
values.append(x)
count += 1

sums = [sum(x) for x in zip(*values)]
means = list(map(lambda x: round(x/count), sums))
return means
1 change: 1 addition & 0 deletions flask_monitoringdashboard/templates/endpoint/outliers.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "endpoint/main.html" %}
{% block graph_content %}
<p> <strong>Mean CPU Percent: </strong>{{ mean }}</p>
<br/>
{% for row in table %}
<div class="panel panel-default">
Expand Down

0 comments on commit aec3370

Please sign in to comment.