mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
Add monitoring module
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
99614f8f3a
commit
6617977a7e
6 changed files with 83 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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: [],
|
||||
|
|
8
src/monitoring/monitoring.module.ts
Normal file
8
src/monitoring/monitoring.module.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { MonitoringService } from './monitoring.service';
|
||||
|
||||
@Module({
|
||||
providers: [MonitoringService],
|
||||
exports: [MonitoringService],
|
||||
})
|
||||
export class MonitoringModule {}
|
18
src/monitoring/monitoring.service.spec.ts
Normal file
18
src/monitoring/monitoring.service.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
27
src/monitoring/monitoring.service.ts
Normal file
27
src/monitoring/monitoring.service.ts
Normal 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',
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
20
src/monitoring/server-status.dto.ts
Normal file
20
src/monitoring/server-status.dto.ts
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue