Peter Ward avatar Peter Ward committed 2d9a720

Order data series.

Comments (0)

Files changed (3)

 import re
 from subprocess import Popen, PIPE
 
+from brownie.datastructures import OrderedDict
 from flask import (
     Flask,
     abort, current_app, g, jsonify, request, render_template,
     step = data['meta']['step']
 
     # we then return per-series information
-    series = {}
+    series = OrderedDict()
 
-    for sname, sdata in zip(
+    for sname, sdata in sorted(zip(
         data['meta']['legend'],
         zip(*data['data'])
-    ):
+    )):
         when = start
         series[sname] = ssdata = []
         for value in sdata:
     end = request.args.get('end', 0)
     end = int(end)
 
-    return jsonify(
-        get_rrd_data(
-            hostname, graph,
-            start, end, step,
-        )
+    series = get_rrd_data(
+        hostname, graph,
+        start, end, step,
     )
+    return jsonify({"series": series.items()})
 
 if __name__ == '__main__':
     app.run(debug=True, host='0.0.0.0', port=5001)
 {
     "types": {
-        "load": [
-            "DEF:shortterm=<file>:shortterm:AVERAGE",
-            "DEF:midterm=<file>:midterm:AVERAGE",
-            "DEF:longterm=<file>:longterm:AVERAGE",
-            "XPORT:shortterm:shortterm (1m)",
-            "XPORT:midterm:midterm (3m)",
-            "XPORT:longterm:longterm (5m)"
-        ],
-
         "cpu-summary": [
             "DEF:idle-<num>=<idle>:value:AVERAGE",
             "DEF:nice-<num>=<nice>:value:AVERAGE",
             "XPORT:steal:steal"
         ],
 
+        "df": [
+            "DEF:free=<file>:free:AVERAGE",
+            "DEF:used=<file>:used:AVERAGE",
+            "XPORT:used:used",
+            "XPORT:free:free"
+        ],
+
+        "load": [
+            "DEF:shortterm=<file>:shortterm:AVERAGE",
+            "DEF:midterm=<file>:midterm:AVERAGE",
+            "DEF:longterm=<file>:longterm:AVERAGE",
+            "XPORT:shortterm:shortterm (1m)",
+            "XPORT:midterm:midterm (3m)",
+            "XPORT:longterm:longterm (5m)"
+        ],
+
         "packets": [
             "DEF:<var>-rx=<file>:rx:AVERAGE",
             "DEF:<var>-tx=<file>:tx:AVERAGE",
             }
         }],
 
+        "df/<var>": [{
+            "graph": {
+                "type": "areaspline",
+                "stacking": "normal"
+            },
+            "type": "df",
+            "files": {"file": "df/df-<var>.rrd"}
+        }],
+
         "load": [{
             "graph": {},
             "type": "load",

static/js/charts.js

                 setTimeout(refresh_data, 5000);
             },
             success: function(data) {
-                for (var name in data) {
+                for (var i = 0; i < data.series.length; i++) {
+                    var name = data.series[i][0];
+                    var series_data = data.series[i][1];
+
                     var series = null;
                     for (var i = 0; i < chart.series.length; i++) {
                         if (chart.series[i].name == name) {
                         }
                     }
 
-                    var series_data = data[name];
-
                     if (series === null) {
                         chart.addSeries({
                             name: name,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.