Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:eastein/chillmon

  • Loading branch information...
commit ba9958916841e00d0191755f5ecec8fad2503dd8 2 parents f13b5e9 + eea565d
@eastein authored
Showing with 44 additions and 17 deletions.
  1. +27 −9 interface.html
  2. +17 −8 web.py
View
36 interface.html
@@ -18,25 +18,40 @@
<script type="text/javascript">
function init() {
+ $.ajax({
+ url: '/trace',
+ dataType: 'json',
+ success: function(data) {
+ trace_set = data.data;
+ for (var tracetype in trace_set) {
+ var tl = new SmoothieChart({ millisPerPixel: 4500, grid: { strokeStyle: '#555555', lineWidth: 1, millisPerLine: 300000, verticalSections: 4 }});
+ traces = trace_set[tracetype];
+ for (var id in traces) {
+ setup_traces(tl, tracetype, traces[id], id);
+ }
+ }
+ }
+ });
+}
+
+function setup_traces(tl, tracetype, tracename, id) {
var dataset = new TimeSeries();
- var now = new Date().getTime();
+ var rgb = ['rgba(255, 0, 0, 1)', 'rgba(0, 255, 0, 1)', 'rgba(0, 0, 255, 1)', 'rgba(220, 0, 220, 1)', 'rgba(2, 183, 98, 1)']
// Every second, get the total trace
setInterval(function() {
- update_dataset(dataset);
+ update_dataset(dataset, tracetype, tracename);
}, 1000);
- var timeline = new SmoothieChart({ millisPerPixel: 4500, grid: { strokeStyle: '#555555', lineWidth: 1, millisPerLine: 300000, verticalSections: 4 }});
+ tl.addTimeSeries(dataset, {strokeStyle: rgb[id], fillStyle: 'rgba(10, 10, 10, 0.1)', lineWidth: 2});
- timeline.addTimeSeries(dataset, { strokeStyle: 'rgba(255, 0, 0, 1)', fillStyle: 'rgba(255, 0, 0, 0.1)', lineWidth: 3 });
-
- timeline.streamTo(document.getElementById('temps'), 1000);
+ tl.streamTo(document.getElementById(tracetype), 1000);
}
-function update_dataset(dataset) {
+function update_dataset(dataset, tt, tn) {
$.ajax({
- url: '/trace/all',
+ url: '/trace/' + tt + '/' + tn,
dataType: 'json',
success: function(data) {
dataset.data = data['data'];
@@ -53,7 +68,10 @@
<h1>Chillmon</h1>
<h4>Temps</h4>
- <canvas id="temps" width="800" height="100"></canvas>
+ <canvas id="temps" width="900" height="200"></canvas>
+
+ <h4>PID States</h4>
+ <canvas id="pidstate" width="900" height="200"></canvas>
</body>
</html>
View
25 web.py
@@ -44,12 +44,11 @@ def __init__(self, sock, sample_cap=3600) :
def stop(self) :
self.ok = False
- @property
- def temps(self) :
+ def get_trace(self, a, b) :
r = []
for samp in self.samples :
ts, sample = samp
- r.append((ts, sample['temps']['beer']))
+ r.append((ts, sample[a][b]))
return r
def run(self) :
@@ -147,21 +146,27 @@ def handle_response(self, result) :
self.wj(status, resp)
+class TraceListHandler(JSONHandler):
+ def process_request(self):
+ ts, i = self.application.__traces__.samples[0]
+ return dict([(k,i[k].keys()) for k in i])
+
class TraceHandler(JSONHandler):
- def process_request(self, tracename):
- return self.application.__traces__[tracename].temps
+ def process_request(self, tracetype, tracename):
+ return self.application.__traces__.get_trace(tracetype, tracename)
if __name__ == '__main__' :
handler_set = [
(r"/$", InterfaceHandler),
(r"/([a-z0-9\.\-]+\.js)$", JSHandler),
- (r"/trace/([a-z0-9\.\-]+)$", TraceHandler)
+ (r"/trace$", TraceListHandler),
+ (r"/trace/([a-z0-9\.\-]+)/([a-z0-9\.\-]+)$", TraceHandler)
]
sock = zmqsub.JSONZMQSub(sys.argv[1])
tt = TraceThread(sock)
tt.start()
- traces = {'all' : tt}
+ traces = tt
application = tornado.web.Application(handler_set)
application.__traces__ = traces
@@ -170,4 +175,8 @@ def process_request(self, tracename):
application.listen(8000)
application.__io_instance__ = tornado.ioloop.IOLoop.instance()
- application.__io_instance__.start()
+
+ try :
+ application.__io_instance__.start()
+ finally :
+ tt.stop()
Please sign in to comment.
Something went wrong with that request. Please try again.