2022-02-27 11:07:39 +09:00
|
|
|
import * as os from 'node:os';
|
|
|
|
import si from 'systeminformation';
|
2020-01-30 04:37:25 +09:00
|
|
|
import { getConnection } from 'typeorm';
|
2022-02-27 11:07:39 +09:00
|
|
|
import define from '../../define.js';
|
|
|
|
import { redisClient } from '../../../../db/redis.js';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
export const meta = {
|
2022-01-18 22:27:10 +09:00
|
|
|
requireCredential: true,
|
2020-10-17 20:12:00 +09:00
|
|
|
requireModerator: true,
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-04-03 22:42:29 +09:00
|
|
|
tags: ['admin', 'meta'],
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-03-06 22:34:11 +09:00
|
|
|
res: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
properties: {
|
|
|
|
machine: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
os: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 23:58:30 +09:00
|
|
|
example: 'linux',
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
node: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
psql: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
cpu: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
properties: {
|
|
|
|
model: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
cores: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
|
|
|
},
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
mem: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
properties: {
|
|
|
|
total: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
format: 'bytes',
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
|
|
|
},
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
fs: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
properties: {
|
|
|
|
total: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
format: 'bytes',
|
|
|
|
},
|
|
|
|
used: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
format: 'bytes',
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
|
|
|
},
|
2021-03-06 22:34:11 +09:00
|
|
|
},
|
|
|
|
net: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
properties: {
|
|
|
|
interface: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 23:58:30 +09:00
|
|
|
example: 'eth0',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-01-18 22:27:10 +09:00
|
|
|
} as const;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2022-02-20 13:15:40 +09:00
|
|
|
export const paramDef = {
|
2022-02-19 14:05:32 +09:00
|
|
|
type: 'object',
|
|
|
|
properties: {},
|
|
|
|
required: [],
|
|
|
|
} as const;
|
|
|
|
|
2022-01-03 02:12:50 +09:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-02-19 14:05:32 +09:00
|
|
|
export default define(meta, paramDef, async () => {
|
2020-01-30 04:37:25 +09:00
|
|
|
const memStats = await si.mem();
|
|
|
|
const fsStats = await si.fsSize();
|
|
|
|
const netInterface = await si.networkInterfaceDefault();
|
|
|
|
|
|
|
|
return {
|
|
|
|
machine: os.hostname(),
|
|
|
|
os: os.platform(),
|
|
|
|
node: process.version,
|
|
|
|
psql: await getConnection().query('SHOW server_version').then(x => x[0].server_version),
|
2021-03-23 14:54:09 +09:00
|
|
|
redis: redisClient.server_info.redis_version,
|
2020-01-30 04:37:25 +09:00
|
|
|
cpu: {
|
|
|
|
model: os.cpus()[0].model,
|
2021-12-09 23:58:30 +09:00
|
|
|
cores: os.cpus().length,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
mem: {
|
2021-12-09 23:58:30 +09:00
|
|
|
total: memStats.total,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
fs: {
|
|
|
|
total: fsStats[0].size,
|
|
|
|
used: fsStats[0].used,
|
|
|
|
},
|
|
|
|
net: {
|
2021-12-09 23:58:30 +09:00
|
|
|
interface: netInterface,
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
};
|
|
|
|
});
|