LSP: stats for individual streams - still WIP
This commit is contained in:
parent
f7cc5c03ec
commit
e4f86236e8
1 changed files with 79 additions and 31 deletions
110
lsp/pages.js
110
lsp/pages.js
|
@ -1293,13 +1293,19 @@ function showTab(tabName,streamName) {
|
||||||
).append(
|
).append(
|
||||||
$('<option>').text('Memory load').val('memload').addClass('axis_time')
|
$('<option>').text('Memory load').val('memload').addClass('axis_time')
|
||||||
).append(
|
).append(
|
||||||
$('<option>').text('Viewer location').val('coords').addClass('axis_coords')
|
$('<option>').text('Viewer location (LTS only)').val('coords').addClass('axis_coords')
|
||||||
).change(function(){
|
).change(function(){
|
||||||
switch ($(this).val()) {
|
switch ($(this).val()) {
|
||||||
case 'clients':
|
case 'clients':
|
||||||
|
$('#dataset-details .replace-dataset').text('amount of viewers');
|
||||||
|
$('#dataset-details').show();
|
||||||
|
break;
|
||||||
case 'upbps':
|
case 'upbps':
|
||||||
|
$('#dataset-details .replace-dataset').text('bandwidth (up)');
|
||||||
|
$('#dataset-details').show();
|
||||||
|
break;
|
||||||
case 'downbps':
|
case 'downbps':
|
||||||
$('#dataset-details .replace-dataset').text('amount of viewers')
|
$('#dataset-details .replace-dataset').text('bandwidth (down)');
|
||||||
$('#dataset-details').show();
|
$('#dataset-details').show();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1391,7 +1397,7 @@ function showTab(tabName,streamName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var which = $('#dataset-details.cumuval.'+d.cumutype).val();
|
var which = $('#dataset-details .cumuval.'+d.cumutype).val();
|
||||||
if (d.cumutype == 'stream') {
|
if (d.cumutype == 'stream') {
|
||||||
d.stream = which;
|
d.stream = which;
|
||||||
}
|
}
|
||||||
|
@ -1400,18 +1406,28 @@ function showTab(tabName,streamName) {
|
||||||
}
|
}
|
||||||
switch (d.type) {
|
switch (d.type) {
|
||||||
case 'clients':
|
case 'clients':
|
||||||
d.label = 'Viewers ('+d.stream+')';
|
d.label = 'Viewers ('+which+')';
|
||||||
d.yaxistype = 'amount';
|
d.yaxistype = 'amount';
|
||||||
break;
|
break;
|
||||||
case 'upbps':
|
case 'upbps':
|
||||||
d.label = 'Bandwidth (up) ('+d.stream+')';
|
d.label = 'Bandwidth (up) ('+which+')';
|
||||||
break;
|
break;
|
||||||
case 'downbps':
|
case 'downbps':
|
||||||
d.label = 'Bandwidth (down) ('+d.stream+')';
|
d.label = 'Bandwidth (down) ('+which+')';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'coords':
|
||||||
|
d.cumutype = $('#dataset-details input[name=cumutype]:checked').val();
|
||||||
|
if (d.cumutype == 'all') {
|
||||||
|
var which = 'all';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var which = $('#dataset-details .cumuval.'+d.cumutype).val();
|
||||||
|
}
|
||||||
|
d.label = 'Viewer location ('+which+')';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
graph.datasets.push(d);
|
graph.datasets.push(d);
|
||||||
getPlotData();
|
getPlotData();
|
||||||
|
@ -1506,6 +1522,30 @@ function showTab(tabName,streamName) {
|
||||||
},10000);
|
},10000);
|
||||||
|
|
||||||
function getPlotData() {
|
function getPlotData() {
|
||||||
|
var reqobj = {
|
||||||
|
totals: []
|
||||||
|
};
|
||||||
|
for (var g in graphs) {
|
||||||
|
for (var d in graphs[g].datasets) {
|
||||||
|
var set = graphs[g].datasets[d];
|
||||||
|
switch (set.type) {
|
||||||
|
case 'clients':
|
||||||
|
case 'upbps':
|
||||||
|
case 'downbps':
|
||||||
|
switch (set.cumutype) {
|
||||||
|
case 'all': reqobj['totals'].push({fields: [set.type]}); break;
|
||||||
|
case 'stream': reqobj['totals'].push({fields: [set.type], streams: [set.stream]}); break;
|
||||||
|
case 'protocol': reqobj['totals'].push({fields: [set.type], protocols: [set.protocol]}); break;
|
||||||
|
}
|
||||||
|
set.sourceid = reqobj['totals'].length-1;
|
||||||
|
break;
|
||||||
|
case 'cpuload':
|
||||||
|
case 'memload':
|
||||||
|
reqobj['capabilities'] = {};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
getData(function(data){
|
getData(function(data){
|
||||||
for (var j in graphs) {
|
for (var j in graphs) {
|
||||||
for (var i in graphs[j].datasets) {
|
for (var i in graphs[j].datasets) {
|
||||||
|
@ -1513,7 +1553,7 @@ function showTab(tabName,streamName) {
|
||||||
}
|
}
|
||||||
drawGraph(graphs[j]);
|
drawGraph(graphs[j]);
|
||||||
}
|
}
|
||||||
},{capabilities:true,totals:{}});
|
},reqobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function findDataset(dataobj,sourcedata) {
|
function findDataset(dataobj,sourcedata) {
|
||||||
|
@ -1549,16 +1589,16 @@ function showTab(tabName,streamName) {
|
||||||
case 'downbps':
|
case 'downbps':
|
||||||
case 'clients':
|
case 'clients':
|
||||||
//todo: depending on the stream..
|
//todo: depending on the stream..
|
||||||
if (!sourcedata.totals || !sourcedata.totals.data) {
|
if (!sourcedata.totals || !sourcedata.totals[dataobj.sourceid] || !sourcedata.totals[dataobj.sourceid].data) {
|
||||||
dataobj.data.push([(now-600)*1000,0]);
|
dataobj.data.push([(now-600)*1000,0]);
|
||||||
dataobj.data.push([now*1000,0]);
|
dataobj.data.push([now*1000,0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var fields = {};
|
var fields = {};
|
||||||
for (var index in sourcedata.totals.fields) {
|
for (var index in sourcedata.totals[dataobj.sourceid].fields) {
|
||||||
fields[sourcedata.totals.fields[index]] = index;
|
fields[sourcedata.totals[dataobj.sourceid].fields[index]] = index;
|
||||||
}
|
}
|
||||||
var time = sourcedata.totals.start;
|
var time = sourcedata.totals[dataobj.sourceid].start;
|
||||||
dataobj.data = [];
|
dataobj.data = [];
|
||||||
if (time > now-590) {
|
if (time > now-590) {
|
||||||
//prepend data with 0
|
//prepend data with 0
|
||||||
|
@ -1566,20 +1606,20 @@ function showTab(tabName,streamName) {
|
||||||
dataobj.data.push([time*1000-1,0]);
|
dataobj.data.push([time*1000-1,0]);
|
||||||
}
|
}
|
||||||
var index = 0;
|
var index = 0;
|
||||||
dataobj.data.push([[time*1000,sourcedata.totals.data[index][fields[dataobj.type]]]]);
|
dataobj.data.push([[time*1000,sourcedata.totals[dataobj.sourceid].data[index][fields[dataobj.type]]]]);
|
||||||
for (var i in sourcedata.totals.interval) {
|
for (var i in sourcedata.totals[dataobj.sourceid].interval) {
|
||||||
if ((i % 2) == 1) {
|
if ((i % 2) == 1) {
|
||||||
//fill gaps with 0
|
//fill gaps with 0
|
||||||
time += sourcedata.totals.interval[i][1];
|
time += sourcedata.totals[dataobj.sourceid].interval[i][1];
|
||||||
dataobj.data.push([time*1000,0]);
|
dataobj.data.push([time*1000,0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (var j = 0; j < sourcedata.totals.interval[i][0]; j++) {
|
for (var j = 0; j < sourcedata.totals[dataobj.sourceid].interval[i][0]; j++) {
|
||||||
time += sourcedata.totals.interval[i][1];
|
time += sourcedata.totals[dataobj.sourceid].interval[i][1];
|
||||||
index++;
|
index++;
|
||||||
dataobj.data.push([time*1000,sourcedata.totals.data[index][fields[dataobj.type]]]);
|
dataobj.data.push([time*1000,sourcedata.totals[dataobj.sourceid].data[index][fields[dataobj.type]]]);
|
||||||
}
|
}
|
||||||
if (i < sourcedata.totals.interval.length-1) {
|
if (i < sourcedata.totals[dataobj.sourceid].interval.length-1) {
|
||||||
dataobj.data.push([time*1000+1,0]);
|
dataobj.data.push([time*1000+1,0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1591,6 +1631,13 @@ function showTab(tabName,streamName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'coords':
|
||||||
|
//retrieve data
|
||||||
|
//format [lat,long]
|
||||||
|
|
||||||
|
//testing data
|
||||||
|
dataobj.data = [[-54.657438,-65.11675],[49.725719,-1.941553],[-34.425464,172.677617],[76.958669,68.494178],[0,0]];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1605,20 +1652,21 @@ function showTab(tabName,streamName) {
|
||||||
}
|
}
|
||||||
switch (graph.type) {
|
switch (graph.type) {
|
||||||
case 'coords':
|
case 'coords':
|
||||||
//format [lat,long]
|
plotsets = [];
|
||||||
var data = [[-54.657438,-65.11675],[49.725719,-1.941553],[-34.425464,172.677617],[76.958669,68.494178],[0,0]];
|
for (var d in datasets) {
|
||||||
//correct latitude according to the Miller cylindrical projection
|
//put backend data into the correct projection
|
||||||
for (var i in data) {
|
data = datasets[d].data;
|
||||||
var lat = data[i][0];
|
//correct latitude according to the Miller cylindrical projection
|
||||||
var lon = data[i][1];
|
for (var i in data) {
|
||||||
//to radians
|
var lat = data[i][0];
|
||||||
lat = Math.PI * lat / 180;
|
var lon = data[i][1];
|
||||||
var y = 1.25 * Math.log(Math.tan(0.25 * Math.PI + 0.4 * lat));
|
//to radians
|
||||||
data[i] = [lon,y];
|
lat = Math.PI * lat / 180;
|
||||||
|
var y = 1.25 * Math.log(Math.tan(0.25 * Math.PI + 0.4 * lat));
|
||||||
|
data[i] = [lon,y];
|
||||||
|
}
|
||||||
|
plotsets.push({data:data});
|
||||||
}
|
}
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
plotsets = [{data:data}];
|
|
||||||
//make sure the plot area has the correct height/width ratio
|
//make sure the plot area has the correct height/width ratio
|
||||||
if ($('#'+graph.id+' .graphbackground').length == 0) {
|
if ($('#'+graph.id+' .graphbackground').length == 0) {
|
||||||
var parent = $('#'+graph.id+' .graph');
|
var parent = $('#'+graph.id+' .graph');
|
||||||
|
|
Loading…
Add table
Reference in a new issue