graphs: send service graphs
This commit is contained in:
@@ -25,7 +25,8 @@ exports = module.exports = {
|
||||
getServerIpv6,
|
||||
getLanguages,
|
||||
syncExternalLdap,
|
||||
syncDnsRecords
|
||||
syncDnsRecords,
|
||||
getSystemGraphs
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
@@ -36,6 +37,7 @@ const assert = require('assert'),
|
||||
debug = require('debug')('box:routes/cloudron'),
|
||||
eventlog = require('../eventlog.js'),
|
||||
externalLdap = require('../externalldap.js'),
|
||||
graphs = require('../graphs.js'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
safe = require('safetydance'),
|
||||
@@ -343,3 +345,14 @@ async function syncDnsRecords(req, res, next) {
|
||||
|
||||
next(new HttpSuccess(201, { taskId }));
|
||||
}
|
||||
|
||||
async function getSystemGraphs(req, res, next) {
|
||||
if (!req.query.fromMinutes || !parseInt(req.query.fromMinutes)) return next(new HttpError(400, 'fromMinutes must be a number'));
|
||||
|
||||
const fromMinutes = parseInt(req.query.fromMinutes);
|
||||
const noNullPoints = !!req.query.noNullPoints;
|
||||
const [error, result] = await safe(graphs.getSystem(fromMinutes, noNullPoints));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200, result));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user