Fixup the disk usage gathering
This commit is contained in:
+10
-4
@@ -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');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user