fix minor wonks with metrics

This commit is contained in:
forest 2020-05-13 00:34:38 -05:00
parent 30464ac8e5
commit 34d920b005
2 changed files with 4 additions and 6 deletions

View File

@ -1,6 +1,7 @@
import matplotlib.ticker as ticker import matplotlib.ticker as ticker
import matplotlib.pyplot as pyplot import matplotlib.pyplot as pyplot
import matplotlib.dates as mdates import matplotlib.dates as mdates
from functools import reduce
import requests import requests
#import json #import json
from datetime import datetime from datetime import datetime
@ -175,7 +176,7 @@ def draw_plot_bytes(data, scale, size_x=3, size_y=1):
my_plot.xaxis.set_major_locator(day_locator) my_plot.xaxis.set_major_locator(day_locator)
my_plot.xaxis.set_major_formatter(day_formatter) my_plot.xaxis.set_major_formatter(day_formatter)
max_value = reduce(lambda a, b: a if a > b else b, y, scale)
average=(sum(y)/len(y))/scale average=(sum(y)/len(y))/scale
average=average*1.25+0.1 average=average*1.25+0.1
@ -186,7 +187,7 @@ def draw_plot_bytes(data, scale, size_x=3, size_y=1):
fill_color=color_gradient(average) fill_color=color_gradient(average)
highlight_color=lerp_rgb_tuples(fill_color, (1,1,1), 0.5) highlight_color=lerp_rgb_tuples(fill_color, (1,1,1), 0.5)
my_plot.fill_between( x, scale, color=bg_color, alpha=0.13) my_plot.fill_between( x, max_value, color=bg_color, alpha=0.13)
my_plot.fill_between( x, y, color=highlight_color, alpha=0.3) my_plot.fill_between( x, y, color=highlight_color, alpha=0.3)
my_plot.plot(x, y, 'r-', color=highlight_color) my_plot.plot(x, y, 'r-', color=highlight_color)

View File

@ -20,11 +20,8 @@
{% endfor %} {% endfor %}
</div> </div>
<div class="row"> <div class="row">
<div>
<h1>cpu</h1>
<img src="/metrics/{{ metric }}/{{ vm['id'] }}/{{ duration }}/l"/> <img src="/metrics/{{ metric }}/{{ vm['id'] }}/{{ duration }}/l"/>
</div> </div>
</div>
{% endblock %} {% endblock %}