summary refs log tree commit diff
path: root/src/api/routes/-/monitorz.ts
blob: 630a832b03be61d40121efecb674e2be7939d1e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { Session } from "@fosscord/util";
import os from "os";

const router = Router();

router.get(
	"/",
	route({ right: "OPERATOR" }),
	async (req: Request, res: Response) => {
		return res.json({
			load: os.loadavg(),
			procUptime: process.uptime(),
			sysUptime: os.uptime(),
			memPercent: 100 - (os.freemem() / os.totalmem()) * 100,
			sessions: await Session.count(),
		});
	},
);

export default router;