Skip to content
Snippets Groups Projects
Commit 1984d2fc authored by Brian Moe's avatar Brian Moe
Browse files

Added histogram display to web page.

parent 0601ac51
No related branches found
No related tags found
No related merge requests found
......@@ -16,8 +16,11 @@ from datetime import datetime, timedelta
from subprocess import Popen, PIPE, STDOUT
DEST_DIR = "/var/www/html/histo/2"
MAX_X = 1800
DEST_DIR = settings.LATENCY_REPORT_DEST_DIR
MAX_X = settings.LATENCY_MAXIMUM_CHARTED
WEB_PAGE_FILE_PATH = settings.LATENCY_REPORT_WEB_PAGE_FILE_PATH
class Command(NoArgsCommand):
......@@ -31,6 +34,12 @@ class Command(NoArgsCommand):
start_week = now - timedelta(7)
start_month = now - timedelta(30)
past = timedelta(100)
now -= past
start_day -= past
start_week -= past
start_month -= past
time_ranges = [(start_day, "day"), (start_week, "week"), (start_month, "month")]
annotations = {}
......@@ -60,22 +69,17 @@ class Command(NoArgsCommand):
makePlot(data, atype, maxx=MAX_X).savefig(fname)
annotations[atype][time_range] = note
writeIndex(annotations, os.path.join(DEST_DIR, 'index.html'))
writeIndex(annotations, WEB_PAGE_FILE_PATH)
def writeIndex(notes, fname):
template = """<html>
<head>
</head>
<h1>Gracedb Event Reporting Latency</h1>
Tables generated: %(time)s<br/>
Maximum charted latency: %(maxx)s seconds
<body>%(table)s
</body>
</html>
"""
table = '<table border="1">'
createdDate = str(datetime.now())
maxx = MAX_X
table = '<table border="1" bgcolor="white">'
table += """<caption>Tables generated: %s<br/>
Maximum charted latency: %s seconds</caption>""" % (createdDate, maxx)
table += "<tr><th>&nbsp;</th>"
for time_range in ['day', 'week', 'month']:
table += "<th>last %s</th>" % time_range
......@@ -84,7 +88,7 @@ Maximum charted latency: %(maxx)s seconds
table += "<tr>"
table += "<td>%s</td>" % atype_name
for time_range in ['day', 'week', 'month']:
table += "<td>"
table += '<td align="center" bgcolor="white">'
n = notes[atype][time_range]
extra = ""
if n['fname'] is not None:
......@@ -99,12 +103,8 @@ Maximum charted latency: %(maxx)s seconds
table += "</tr>"
table += "</table>"
values = {}
values['table'] = table
values['time'] = str(datetime.now())
values['maxx'] = MAX_X # XXX ugh.
f = open(fname, "w")
f.write(template % values)
f.write(table)
f.close()
def makePlot(data, title, maxx=1800, facecolor='green'):
......
from django.http import HttpResponse
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.conf import settings
def histo(request):
table = open(settings.LATENCY_REPORT_WEB_PAGE_FILE_PATH, "r").read()
return render_to_response(
'gracedb/histogram.html',
{'table': table},
context_instance=RequestContext(request))
......@@ -43,6 +43,13 @@ DATABASE_PASSWORD = 'redrum4x'
DATABASE_HOST = '' # Set to empty string for localhost.
DATABASE_PORT = '' # Set to empty string for default.
# Latency histograms. Where they go and max latency to bin.
LATENCY_REPORT_DEST_DIR = "/home/lars/django/data/latency"
LATENCY_MAXIMUM_CHARTED = 1800
LATENCY_REPORT_WEB_PAGE_FILE_PATH = LATENCY_REPORT_DEST_DIR + "/latency.inc"
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
......
......@@ -34,6 +34,12 @@ DATABASE_PASSWORD = 'redrum4x'
DATABASE_HOST = '' # Set to empty string for localhost.
DATABASE_PORT = '' # Set to empty string for default.
# Latency histograms. Where they go and max latency to bin.
LATENCY_REPORT_DEST_DIR = "/home/lars/django/data/latency"
LATENCY_MAXIMUM_CHARTED = 1800
LATENCY_REPORT_WEB_PAGE_FILE_PATH = LATENCY_REPORT_DEST_DIR + "/latency.inc"
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
......
......@@ -56,6 +56,7 @@
#home #nav-home a,
#create #nav-create a,
#search #nav-search a,
#reports #nav-reports a,
#feeds #nav-feeds a,
#about #nav-about a,
#archive #nav-archive a,
......@@ -70,6 +71,7 @@
#home #nav-home a:hover,
#create #nav-create a,
#search #nav-search a,
#reports #nav-reports a,
#feeds #nav-feeds a,
#about #nav-about a:hover,
#archive #nav-archive a:hover,
......
......@@ -131,6 +131,7 @@ a.link, a, a.active {
#create #nav-create a,
#search #nav-search a,
#doc #nav-doc a,
#reports #nav-reports a,
#feeds #nav-feeds a,
#about #nav-about a,
#archive #nav-archive a,
......@@ -146,6 +147,7 @@ a.link, a, a.active {
#create #nav-create a,
#search #nav-search a,
#doc #nav-doc a,
#reports #nav-reports a,
#feeds #nav-feeds a,
#about #nav-about a:hover,
#archive #nav-archive a:hover,
......
......@@ -13,18 +13,13 @@
{% endblock %}
{% block nav-global %}
<!--
<span id="nav-home"><a href="{% url home %}">Home</a></span>
<span id="nav-search"><a href="{% url search %}">Search</a></span>
<span id="nav-create"><a href="{% url create %}">Create</a></span>
<span id="nav-feeds"><a href="{% url feeds %}">RSS</a></span>
{% if ligouser %}<div id="nav-user">Authenticated as: {{ ligouser.name }}</div>{% endif %}
-->
<ul id="nav">
<li id="nav-home"><a href="{% url home %}">Home</a></li>
<li id="nav-search"><a href="{% url search %}">Search</a></li>
<li id="nav-create"><a href="{% url create %}">Create</a></li>
<li id="nav-reports"><a href="{% url reports %}">RSS</a></li>
<li id="nav-feeds"><a href="{% url feeds %}">RSS</a></li>
<li id="nav-userprofile"><a href="{% url userprofile-home %}">Options</a></li>
{% if ligouser %}<li id="nav-user">Authenticated as: {{ ligouser.name }}</li>{% endif %}
<ul>
{% endblock %}
......@@ -33,6 +33,7 @@ function changeTime(obj, label) {
<li id="nav-home"><a href="{% url home %}">Home</a></li>
<li id="nav-search"><a href="{% url search %}">Search</a></li>
<li id="nav-create"><a href="{% url create %}">Create</a></li>
<li id="nav-reports"><a href="{% url reports %}">Reports</a></li>
<li id="nav-feeds"><a href="{% url feeds %}">RSS</a></li>
<li id="nav-userprofile"><a href="{% url userprofile-home %}">Options</a></li>
{% if ligouser %}<li id="nav-user">Authenticated as: {{ ligouser.name }}</li>{% endif %}
......
{% extends "base.html" %}
{% block title %}Reporting Latency{% endblock %}
{% block heading %}Reporting Latency{% endblock %}
{% block pageid %}reports{% endblock %}
{% block content %}
{{ table|safe }}
{% endblock %}
from django.conf.urls.defaults import *
from django.conf import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
......@@ -27,6 +29,10 @@ urlpatterns = patterns('',
{'feed_dict': feeds}),
url (r'^feeds/$', feedview, name="feeds"),
url (r'^reports/$', 'gracedb.gracedb.reports.histo', name="reports"),
(r'^reports/(?P<path>.+)$', 'django.views.static.serve',
{'document_root': settings.LATENCY_REPORT_DEST_DIR}),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment