Add monitoring module

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-07-26 21:36:28 +02:00
parent f98bf0d32d
commit eab06c0296
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB
6 changed files with 83 additions and 1 deletions

View file

@ -1,5 +1,6 @@
import { Module } from '@nestjs/common';
import { HistoryModule } from '../../history/history.module';
import { MonitoringModule } from '../../monitoring/monitoring.module';
import { NotesModule } from '../../notes/notes.module';
import { RevisionsModule } from '../../revisions/revisions.module';
import { UsersModule } from '../../users/users.module';
@ -9,7 +10,13 @@ import { MediaController } from './media/media.controller';
import { MonitoringController } from './monitoring/monitoring.controller';
@Module({
imports: [UsersModule, HistoryModule, NotesModule, RevisionsModule],
imports: [
UsersModule,
HistoryModule,
NotesModule,
RevisionsModule,
MonitoringModule,
],
controllers: [
MeController,
NotesController,

View file

@ -6,6 +6,7 @@ import { UsersModule } from './users/users.module';
import { RevisionsModule } from './revisions/revisions.module';
import { AuthorsModule } from './authors/authors.module';
import { HistoryModule } from './history/history.module';
import { MonitoringModule } from './monitoring/monitoring.module';
@Module({
imports: [
@ -21,6 +22,7 @@ import { HistoryModule } from './history/history.module';
AuthorsModule,
PublicApiModule,
HistoryModule,
MonitoringModule,
],
controllers: [],
providers: [],

View file

@ -0,0 +1,8 @@
import { Module } from '@nestjs/common';
import { MonitoringService } from './monitoring.service';
@Module({
providers: [MonitoringService],
exports: [MonitoringService],
})
export class MonitoringModule {}

View file

@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { MonitoringService } from './monitoring.service';
describe('MonitoringService', () => {
let service: MonitoringService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [MonitoringService],
}).compile();
service = module.get<MonitoringService>(MonitoringService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View file

@ -0,0 +1,27 @@
import { Injectable } from '@nestjs/common';
import { ServerStatusDto } from './server-status.dto';
@Injectable()
export class MonitoringService {
getServerStatus(): ServerStatusDto {
return {
connectionSocketQueueLenght: 0,
destictOnlineUsers: 0,
disconnectSocketQueueLength: 0,
distictOnlineRegisteredUsers: 0,
isConnectionBusy: false,
isDisconnectBusy: false,
notesCount: 0,
onlineNotes: 0,
onlineRegisteredUsers: 0,
onlineUsers: 0,
registeredUsers: 0,
serverVersion: {
major: 2,
minor: 0,
patch: 0,
preRelease: 'dev',
},
};
}
}

View file

@ -0,0 +1,20 @@
export class ServerStatusDto {
serverVersion: {
major: number;
minor: number;
patch: number;
preRelease?: string;
commit?: string;
};
onlineNotes: number;
onlineUsers: number;
destictOnlineUsers: number;
notesCount: number;
registeredUsers: number;
onlineRegisteredUsers: number;
distictOnlineRegisteredUsers: number;
isConnectionBusy: boolean;
connectionSocketQueueLenght: number;
isDisconnectBusy: boolean;
disconnectSocketQueueLength: number;
}