Browse Source

Add active webhooks amount to server status

pull/1/head
rozetko 6 years ago
parent
commit
a536bf0a6d
  1. 4
      server/src/controllers/analytics_controller.ts
  2. 6
      server/src/index.ts

4
server/src/controllers/analytics_controller.ts

@ -369,6 +369,10 @@ export function isAnalyticReady(): boolean {
return analyticsService.ready;
}
export async function getActiveWebhooks() {
const analyticUnits = await AnalyticUnit.findMany({ alert: true });
return analyticUnits.map(analyticUnit => analyticUnit.id);
}
export async function createAnalyticUnitFromObject(obj: any): Promise<AnalyticUnit.AnalyticUnitId> {
if(obj.datasource !== undefined) {

6
server/src/index.ts

@ -42,6 +42,9 @@ rootRouter.use('/panel', panelRouter.routes(), panelRouter.allowedMethods());
rootRouter.use('/threshold', thresholdRouter.routes(), thresholdRouter.allowedMethods());
rootRouter.get('/', async (ctx) => {
const activeWebhooks = await AnalyticsController.getActiveWebhooks();
const activeWebhooksAmount = activeWebhooks.length;
ctx.response.body = {
server: 'OK',
analyticsReady: AnalyticsController.isAnalyticReady(),
@ -51,7 +54,8 @@ rootRouter.get('/', async (ctx) => {
docker: process.env.INSIDE_DOCKER !== undefined,
zmqConectionString: ZMQ_CONNECTION_STRING,
serverPort: HASTIC_PORT,
git: GIT_INFO
git: GIT_INFO,
activeWebhooksAmount
};
});

Loading…
Cancel
Save