Show disk content separately inside the usage graph
This commit is contained in:
@@ -140,26 +140,42 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
], '-1min', {}, function (error, data) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
disk.size = bytesToGigaBytes(data[2].datapoints[0][0] + data[1].datapoints[0][0] + data[0].datapoints[0][0]);
|
||||
disk.free = bytesToGigaBytes(data[0].datapoints[0][0]);
|
||||
disk.occupied = bytesToGigaBytes(data[2].datapoints[0][0] + data[1].datapoints[0][0]);
|
||||
disk.size = data[2].datapoints[0][0] + data[1].datapoints[0][0] + data[0].datapoints[0][0];
|
||||
disk.free = data[0].datapoints[0][0];
|
||||
disk.occupied = data[2].datapoints[0][0] + data[1].datapoints[0][0];
|
||||
|
||||
disk.contains.forEach(function (content) {
|
||||
content.color = getRandomColor();
|
||||
});
|
||||
|
||||
// get disk usage data
|
||||
const graphiteQueries = disk.contains.map(function (content) {
|
||||
return 'absolute(collectd.localhost.du-' + content.id + '.capacity-usage)';
|
||||
});
|
||||
|
||||
Client.graphs(graphiteQueries, '-2days', { noNullPoints: true }, function (error, data) {
|
||||
Client.graphs(graphiteQueries, '-1day', { noNullPoints: true }, function (error, data) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
var usageOther = disk.occupied;
|
||||
|
||||
data.forEach(function (d) {
|
||||
var content = disk.contains.find(function (content) { return d.target.indexOf(content.id) !== -1; });
|
||||
if (!content) {
|
||||
content.usage = 'no data available yet';
|
||||
} else {
|
||||
var tmp = d.datapoints[d.datapoints.length-1][0];
|
||||
content.usage = tmp < 1000000 ? (bytesToMegaBytes(tmp) + ' MB') : (bytesToGigaBytes(tmp) + ' GB');
|
||||
}
|
||||
if (!content) return; // didn't match any content
|
||||
|
||||
var tmp = d.datapoints[d.datapoints.length-1][0];
|
||||
content.usage = tmp;
|
||||
|
||||
// deduct from overal disk usage to track other
|
||||
usageOther -= tmp;
|
||||
});
|
||||
|
||||
|
||||
// add content container for other non tracked data
|
||||
disk.contains.push({
|
||||
label: 'Other',
|
||||
id: 'other',
|
||||
color: '#27CE65',
|
||||
usage: usageOther
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user