Fixup the disk usage gathering

This commit is contained in:
Johannes Zellner
2019-08-21 12:08:19 +02:00
parent a56f20584f
commit 6643b825ee
2 changed files with 12 additions and 6 deletions
+10 -4
View File
@@ -120,7 +120,7 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
const apps = Object.keys(result.apps).filter(function (appId) { return result.apps[appId] === disk.filesystem; });
apps.forEach(function (appId) {
disk.contains.push({ app: Client.getCachedAppSync(appId), id: appId });
disk.contains.push({ app: Client.getCachedAppSync(appId), id: appId, usage: 0 });
});
});
@@ -149,11 +149,17 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
return 'absolute(collectd.localhost.du-' + content.id + '.capacity-usage)';
});
Client.graphs(graphiteQueries, '-1min', {}, function (error, data) {
Client.graphs(graphiteQueries, '-2days', { noNullPoints: true }, function (error, data) {
if (error) return console.error(error);
disk.contains.forEach(function (content, index) {
content.usage = bytesToGigaBytes(data[index].datapoints[0][1]);
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');
}
});
});
});