diff --git a/acquire/schema.sql b/acquire/schema.sql index 8982794..6bddd5a 100644 --- a/acquire/schema.sql +++ b/acquire/schema.sql @@ -88,14 +88,14 @@ BEGIN SELECT ts - d, qdelay * 1000, (qdelay - vqnb) * 1000, owd * 1000 FROM p, o ORDER BY ts; - CREATE VIEW fbandwidth (dts, load, capacity, pktsizebytes) AS + CREATE VIEW fbandwidth (dts, load, rcapacity, vcapacity, pktsizebytes) AS WITH prefiltered AS ( SELECT ts, len FROM p WHERE NOT p.isdrop ), calculated AS ( - SELECT ts, len AS pktsizebytes, vcap as bwlim, + SELECT ts, len AS pktsizebytes, vcap, rcap, -- https://dba.stackexchange.com/a/105828/65843 count(vcap) OVER wts AS ct, -- https://stackoverflow.com/a/77051480/2171120 @@ -115,12 +115,14 @@ BEGIN ), filled AS ( SELECT ts, pktsizebytes, bps, - min(bwlim) OVER (PARTITION BY ct) AS bw + min(vcap) OVER (PARTITION BY ct) AS vbw, + min(rcap) OVER (PARTITION BY ct) AS rbw FROM calculated ) SELECT ts - d AS dts, (TRUNC(bps) / 1000000)::NUMERIC(10,6) AS load, - (TRUNC(bw) / 1000000)::NUMERIC(10,6) AS capacity, + (TRUNC(rbw) / 1000000)::NUMERIC(10,6) AS rcapacity, + (TRUNC(vbw) / 1000000)::NUMERIC(10,6) AS vcapacity, pktsizebytes FROM filled, o ORDER BY ts; RETURN sid; diff --git a/consume/diagram.js b/consume/diagram.js index 7e1ec50..fda46db 100644 --- a/consume/diagram.js +++ b/consume/diagram.js @@ -135,15 +135,15 @@ usefulJS.deferDOM(function onDOMReady() { var oldFormatter = Dygraph._require('dygraphs/src/plugins/legend.js').defaultFormatter; var newFormatter = function newFormatter(data) { if (typeof(data.x) !== 'undefined') { - data.series[2].isVisible = true; - data.series[2].y = data.dygraph.getValue(data.i, 3); - if (data.series[2].y !== null) - data.series[2].yHTML = data.series[2].y + 'b'; + data.series[3].isVisible = true; + data.series[3].y = data.dygraph.getValue(data.i, 4); + if (data.series[3].y !== null) + data.series[3].yHTML = data.series[3].y + 'b'; } return (oldFormatter(data)); }; g.gBW = new Dygraph(document.getElementById('divBandwidth'), - /* initial dummy data */ [[0,0,0,null],[1,1,1,null]], { + /* initial dummy data */ [[0,0,0,0,null],[1,1,1,1,null]], { "axes": { "x": { "valueFormatter": function (x) { @@ -159,11 +159,25 @@ usefulJS.deferDOM(function onDOMReady() { "digitsAfterDecimal": 6 } }, + "series": { + "load": { + "color": "#009DE0" + }, + "rcapacity": { + "color": "#E6ADEC" + }, + "vcapacity": { + "color": "#E20074" + }, + "pktsz": { + "color": "#E2001A" + } + }, "xlabel": "s", "xLabelHeight": 0, "ylabel": "Mbit/s", - "labels": ["time", "load", "capacity", "pktsz"], - "visibility": [true, true, false], + "labels": ["time", "load", "rcapacity", "vcapacity", "pktsz"], + "visibility": [true, true, true, false], "connectSeparatedPoints": true, "legendFormatter": newFormatter, "underlayCallback": function (ctx, area, dy) { @@ -185,10 +199,10 @@ usefulJS.deferDOM(function onDOMReady() { var cx = canvasx(point); if (cx < 0) continue; - var len = dy.getValue(point.idx, 3); + var len = dy.getValue(point.idx, 4); if (len === null) continue; - var rate = dy.getValue(point.idx, 2); + var rate = dy.getValue(point.idx, 3); var w = len * pps / rate; if (w < 3) return;