2020-01-29 20:37:25 +01:00
|
|
|
import * as os from 'os';
|
|
|
|
import * as si from 'systeminformation';
|
|
|
|
import { getConnection } from 'typeorm';
|
2021-08-19 14:55:45 +02:00
|
|
|
import define from '../../define';
|
|
|
|
import { redisClient } from '../../../../db/redis';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
export const meta = {
|
2022-01-18 14:27:10 +01:00
|
|
|
requireCredential: true,
|
2020-10-17 13:12:00 +02:00
|
|
|
requireModerator: true,
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2020-04-03 15:42:29 +02:00
|
|
|
tags: ['admin', 'meta'],
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
params: {
|
|
|
|
},
|
2021-03-06 14:34:11 +01:00
|
|
|
|
|
|
|
res: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
properties: {
|
|
|
|
machine: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
},
|
|
|
|
os: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
example: 'linux',
|
2021-03-06 14:34:11 +01:00
|
|
|
},
|
|
|
|
node: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
},
|
|
|
|
psql: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
},
|
|
|
|
cpu: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
properties: {
|
|
|
|
model: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
},
|
|
|
|
cores: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
},
|
|
|
|
},
|
2021-03-06 14:34:11 +01:00
|
|
|
},
|
|
|
|
mem: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
properties: {
|
|
|
|
total: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
format: 'bytes',
|
2021-12-09 15:58:30 +01:00
|
|
|
},
|
|
|
|
},
|
2021-03-06 14:34:11 +01:00
|
|
|
},
|
|
|
|
fs: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
properties: {
|
|
|
|
total: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
format: 'bytes',
|
|
|
|
},
|
|
|
|
used: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'number',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
format: 'bytes',
|
2021-12-09 15:58:30 +01:00
|
|
|
},
|
|
|
|
},
|
2021-03-06 14:34:11 +01:00
|
|
|
},
|
|
|
|
net: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 14:34:11 +01:00
|
|
|
properties: {
|
|
|
|
interface: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'string',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
example: 'eth0',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
} as const;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-01-02 18:12:50 +01:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2020-01-29 20:37:25 +01:00
|
|
|
export default define(meta, async () => {
|
|
|
|
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 06:54:09 +01:00
|
|
|
redis: redisClient.server_info.redis_version,
|
2020-01-29 20:37:25 +01:00
|
|
|
cpu: {
|
|
|
|
model: os.cpus()[0].model,
|
2021-12-09 15:58:30 +01:00
|
|
|
cores: os.cpus().length,
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
mem: {
|
2021-12-09 15:58:30 +01:00
|
|
|
total: memStats.total,
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
fs: {
|
|
|
|
total: fsStats[0].size,
|
|
|
|
used: fsStats[0].used,
|
|
|
|
},
|
|
|
|
net: {
|
2021-12-09 15:58:30 +01:00
|
|
|
interface: netInterface,
|
|
|
|
},
|
2020-01-29 20:37:25 +01:00
|
|
|
};
|
|
|
|
});
|