graphs: add app response in system graphs
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
|
||||
exports = module.exports = {
|
||||
getSystem,
|
||||
getByApp
|
||||
getApp
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
const apps = require('./apps.js'),
|
||||
assert = require('assert'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
docker = require('./docker.js'),
|
||||
safe = require('safetydance'),
|
||||
@@ -24,7 +25,7 @@ async function getGraphiteUrl() {
|
||||
return `http://${ip}:8000/graphite-web/render`;
|
||||
}
|
||||
|
||||
async function getByApp(app, fromMinutes, noNullPoints) {
|
||||
async function getApp(app, fromMinutes, noNullPoints) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof fromMinutes, 'number');
|
||||
assert.strictEqual(typeof noNullPoints, 'boolean');
|
||||
@@ -91,5 +92,10 @@ async function getSystem(fromMinutes, noNullPoints) {
|
||||
if (memCpuError) throw new BoxError(BoxError.NETWORK_ERROR, memCpuError.message);
|
||||
if (memCpuResponse.status !== 200) throw new BoxError(BoxError.EXTERNAL_ERROR, `Unknown error: ${memCpuResponse.status} ${memCpuResponse.text}`);
|
||||
|
||||
return { cpu: memCpuResponse.body[0], memory: memCpuResponse.body[1] };
|
||||
const appResponses = {};
|
||||
for (const app of await apps.list()) {
|
||||
appResponses[app.id] = await getApp(app, fromMinutes, noNullPoints);
|
||||
}
|
||||
|
||||
return { cpu: memCpuResponse.body[0], memory: memCpuResponse.body[1], apps: appResponses };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user