* wip * Update ReactionService.ts * Update ApiCallService.ts * Update timeline.ts * Update GlobalModule.ts * Update GlobalModule.ts * Update NoteEntityService.ts * wip * wip * wip * Update ApPersonService.ts * wip * Update GlobalModule.ts * Update mock-resolver.ts * Update RoleService.ts * Update activitypub.ts * Update activitypub.ts * Update activitypub.ts * Update activitypub.ts * Update activitypub.ts * clean up * Update utils.ts * Update UtilityService.ts * Revert "Update utils.ts" This reverts commit a27d4be764b78c1b5a9eac685e261fee49331d89. * Revert "Update UtilityService.ts" This reverts commit e5fd9e004c482cf099252201c0c1aa888e001430. * vuwa- * Revert "vuwa-" This reverts commit 0c3bd12472b4b9938cdff2d6f131e6800bc3724c. * Update entry.ts * Update entry.ts * Update entry.ts * Update entry.ts * Update jest.setup.ts
115 lines
2 KiB
TypeScript
115 lines
2 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import * as os from 'node:os';
|
|
import si from 'systeminformation';
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
import { MiMeta } from '@/models/_.js';
|
|
import { DI } from '@/di-symbols.js';
|
|
|
|
export const meta = {
|
|
requireCredential: false,
|
|
allowGet: true,
|
|
cacheSec: 60 * 1,
|
|
|
|
tags: ['meta'],
|
|
res: {
|
|
type: 'object',
|
|
optional: false, nullable: false,
|
|
properties: {
|
|
machine: {
|
|
type: 'string',
|
|
nullable: false,
|
|
},
|
|
cpu: {
|
|
type: 'object',
|
|
nullable: false,
|
|
properties: {
|
|
model: {
|
|
type: 'string',
|
|
nullable: false,
|
|
},
|
|
cores: {
|
|
type: 'number',
|
|
nullable: false,
|
|
},
|
|
},
|
|
},
|
|
mem: {
|
|
type: 'object',
|
|
properties: {
|
|
total: {
|
|
type: 'number',
|
|
nullable: false,
|
|
},
|
|
},
|
|
},
|
|
fs: {
|
|
type: 'object',
|
|
nullable: false,
|
|
properties: {
|
|
total: {
|
|
type: 'number',
|
|
nullable: false,
|
|
},
|
|
used: {
|
|
type: 'number',
|
|
nullable: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {},
|
|
required: [],
|
|
} as const;
|
|
|
|
@Injectable()
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
|
constructor(
|
|
@Inject(DI.meta)
|
|
private serverSettings: MiMeta,
|
|
) {
|
|
super(meta, paramDef, async () => {
|
|
if (!this.serverSettings.enableServerMachineStats) return {
|
|
machine: '?',
|
|
cpu: {
|
|
model: '?',
|
|
cores: 0,
|
|
},
|
|
mem: {
|
|
total: 0,
|
|
},
|
|
fs: {
|
|
total: 0,
|
|
used: 0,
|
|
},
|
|
};
|
|
|
|
const memStats = await si.mem();
|
|
const fsStats = await si.fsSize();
|
|
|
|
return {
|
|
machine: os.hostname(),
|
|
cpu: {
|
|
model: os.cpus()[0].model,
|
|
cores: os.cpus().length,
|
|
},
|
|
mem: {
|
|
total: memStats.total,
|
|
},
|
|
fs: {
|
|
total: fsStats[0].size,
|
|
used: fsStats[0].used,
|
|
},
|
|
};
|
|
});
|
|
}
|
|
}
|