Add refresh_interval parameter.
Change-Id: I01a55e14a169f257474cb6eff1a7b09a8eb9f293
This commit is contained in:
parent
9379486512
commit
d0869dcf7d
|
@ -19,6 +19,7 @@ kwh_price = 0.125
|
||||||
|
|
||||||
# Graphs
|
# Graphs
|
||||||
max_watts = 200
|
max_watts = 200
|
||||||
|
refresh_interval = 5
|
||||||
|
|
||||||
# Log files
|
# Log files
|
||||||
log_file = /tmp/kwapi-rrd.log
|
log_file = /tmp/kwapi-rrd.log
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// <![CDATA[
|
// <![CDATA[
|
||||||
function reloadImage(img) {
|
function reloadImage(img) {
|
||||||
var src = img.attr('src');
|
var src = img.attr('src');
|
||||||
param_position = src.indexOf('#');
|
param_position = src.indexOf('#a');
|
||||||
if(param_position != -1) {
|
if(param_position != -1) {
|
||||||
src = src.substring(0, param_position);
|
src = src.substring(0, param_position);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
setInterval('reloadAllImages()', 5000);
|
setInterval('reloadAllImages()', {{ refresh*1000 }});
|
||||||
});
|
});
|
||||||
// ]]>
|
// ]]>
|
||||||
</script>
|
</script>
|
||||||
|
@ -63,6 +63,7 @@
|
||||||
|
|
||||||
<!-- Probe view (all scales for one probe) -->
|
<!-- Probe view (all scales for one probe) -->
|
||||||
{% elif view == 'probe' %}
|
{% elif view == 'probe' %}
|
||||||
|
<h2>{{ probe }}</h2>
|
||||||
{% for scale in scales %}
|
{% for scale in scales %}
|
||||||
<img class="graph" src="/graph/{{ scale }}/{{ probe }}/" alt="Graph {{ probe }}"/>
|
<img class="graph" src="/graph/{{ scale }}/{{ probe }}/" alt="Graph {{ probe }}"/>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -19,8 +19,17 @@
|
||||||
import flask
|
import flask
|
||||||
from jinja2 import TemplateNotFound
|
from jinja2 import TemplateNotFound
|
||||||
|
|
||||||
|
from kwapi.openstack.common import cfg
|
||||||
import rrd
|
import rrd
|
||||||
|
|
||||||
|
web_opts = [
|
||||||
|
cfg.IntOpt('refresh_interval',
|
||||||
|
required=True,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
cfg.CONF.register_opts(web_opts)
|
||||||
|
|
||||||
blueprint = flask.Blueprint('v1', __name__, static_folder='static')
|
blueprint = flask.Blueprint('v1', __name__, static_folder='static')
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,6 +46,7 @@ def welcome_scale(scale):
|
||||||
try:
|
try:
|
||||||
return flask.render_template('index.html',
|
return flask.render_template('index.html',
|
||||||
probes=sorted(flask.request.probes),
|
probes=sorted(flask.request.probes),
|
||||||
|
refresh=cfg.CONF.refresh_interval,
|
||||||
scales=flask.request.scales,
|
scales=flask.request.scales,
|
||||||
scale=scale,
|
scale=scale,
|
||||||
view='scale')
|
view='scale')
|
||||||
|
@ -51,6 +61,7 @@ def welcome_probe(probe):
|
||||||
try:
|
try:
|
||||||
return flask.render_template('index.html',
|
return flask.render_template('index.html',
|
||||||
probe=probe,
|
probe=probe,
|
||||||
|
refresh=cfg.CONF.refresh_interval,
|
||||||
scales=flask.request.scales,
|
scales=flask.request.scales,
|
||||||
view='probe')
|
view='probe')
|
||||||
except TemplateNotFound:
|
except TemplateNotFound:
|
||||||
|
|
Loading…
Reference in New Issue