diff --git a/src/views/system.js b/src/views/system.js index a6324837a..e50c38a0d 100644 --- a/src/views/system.js +++ b/src/views/system.js @@ -204,7 +204,23 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati $scope.graphs[chartPropertyName] = new Chart(ctx, { type: 'line', data: graphData, options: options }); } - var threshold = 1024 * 1024 * 1024; + var cpuThreshold = 20; + var appsWithHighCPU = Object.keys(result.apps).map(function (appId) { + result.apps[appId].id = appId; + + var app = Client.getInstalledAppsByAppId()[appId]; + if (!app) result.apps[appId].label = appId; + else result.apps[appId].label = app.label || app.fqdn; + + return result.apps[appId]; + }).filter(function (app) { + if (!app.cpu) return false; // not sure why we get empty objects + return app.cpu.datapoints.some(function (d) { return d[0] > cpuThreshold; }); + }).map(function (app) { + return { data: app.cpu, label: app.label }; + }); + + var memoryThreshold = 1024 * 1024 * 1024; var appsWithHighMemory = Object.keys(result.apps).map(function (appId) { result.apps[appId].id = appId; @@ -215,12 +231,12 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati return result.apps[appId]; }).filter(function (app) { if (!app.memory) return false; // not sure why we get empty objects - return app.memory.datapoints.some(function (d) { return d[0] > threshold; }); + return app.memory.datapoints.some(function (d) { return d[0] > memoryThreshold; }); }).map(function (app) { return { data: app.memory, label: app.label }; }); - fillGraph('#graphsCPUChart', [{ data: result.cpu, label: 'CPU' }], 'cpuChart', 100, 1); + fillGraph('#graphsCPUChart', [{ data: result.cpu, label: 'CPU' }].concat(appsWithHighCPU), 'cpuChart', 1, 100); fillGraph('#graphsSystemMemoryChart', [{ data: result.memory, label: 'Memory' }].concat(appsWithHighMemory), 'memoryChart', 1024 * 1024, Number.parseInt($scope.memory.memory / 1024 / 1024)); $scope.graphs.busy = false;