From eaa58920674ef6d8ae85af38a4f3ae713581f961 Mon Sep 17 00:00:00 2001 From: Rodrigo Lazo Date: Fri, 14 Oct 2011 21:23:08 -0300 Subject: [PATCH] Added var plotting using js. --- monitor/http_display.py | 20 ++++++--- monitor/www_templates/var.html | 96 +++++++++++++++++++++++++++++++++--------- 2 files changed, 90 insertions(+), 26 deletions(-) rewrite monitor/www_templates/var.html (82%) diff --git a/monitor/http_display.py b/monitor/http_display.py index 15b0289..9fec072 100755 --- a/monitor/http_display.py +++ b/monitor/http_display.py @@ -123,12 +123,20 @@ class MonitorHttpHandler(object): template = self.env.get_template('var.html') references = self._get_default_references() references["title"] = "Historic Values of var: %s" % name - data = self._store.get_var(name) - if data: - # filename, _ = plotting.new_multigraph(data, name, self._static_path) - filename, _ = plotting.gnuplot_new_multigraph(data, name, self._static_path) - references["filename"] = filename - references["items"] = [{'hostname' : k, 'value': v.get_latest()} for k, v in data.iteritems()] + references["data"] = self._store.get_var(name) + value_range = set() + for value in references["data"].itervalues(): + value_range.update([x.value for x in value.get_all_compact()]) + if len(value_range) > 1: + break + else: + references["single_value"] = value_range.pop() + + miny = min([min(a.get_all(), lambda x: x.value) + for a in references["data"].values()]) + maxy = max([max(a.get_all(), lambda x: x.value)[1] + for a in references["data"].values()]) + print miny, maxy return template.render(references) @cherrypy.expose diff --git a/monitor/www_templates/var.html b/monitor/www_templates/var.html dissimilarity index 82% index 243a0a9..45f7b14 100644 --- a/monitor/www_templates/var.html +++ b/monitor/www_templates/var.html @@ -1,20 +1,76 @@ -{% extends "base.html" %} -{% block body %} -{% if not filename %} -

Empty dataset. Check varname

-{% else %} - - - - - -
-

Latest values collected were:

-
    - {% for item in items %} -
  • [{{item.hostname}}] At {{item.value.timestamp|timestampformat }} was {{ item.value.value }}
  • - {% endfor %} -
-
-{% endif %} -{% endblock body %} +{% extends "base.html" %} + +{% block header%} + + + + + + + + + + + + + + + + + + +{% endblock header%} + +{% block body %} +{% if not data %} +

Empty dataset. Check hostname

+{% else %} + +
+ + + +{% endif %} +{% endblock body %} -- 2.11.4.GIT