mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Add resources debug
This commit is contained in:
parent
2ee14eb94b
commit
40b0f956ae
@ -1,5 +1,9 @@
|
|||||||
import { existsSync } from "fs";
|
import { existsSync } from "fs";
|
||||||
|
|
||||||
|
import createLogger from "utils/logger";
|
||||||
|
|
||||||
|
const logger = createLogger("resources");
|
||||||
|
|
||||||
const si = require("systeminformation");
|
const si = require("systeminformation");
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
@ -23,26 +27,31 @@ export default async function handler(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fsSize = await si.fsSize();
|
const fsSize = await si.fsSize();
|
||||||
|
logger.debug("fsSize:", JSON.stringify(fsSize));
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
drive: fsSize.find((fs) => fs.mount === target) ?? fsSize.find((fs) => fs.mount === "/"),
|
drive: fsSize.find((fs) => fs.mount === target) ?? fsSize.find((fs) => fs.mount === "/"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === "memory") {
|
if (type === "memory") {
|
||||||
|
const memory = await si.mem();
|
||||||
|
logger.debug("memory:", JSON.stringify(memory));
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
memory: await si.mem(),
|
memory,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === "cputemp") {
|
if (type === "cputemp") {
|
||||||
|
const cputemp = await si.cpuTemperature();
|
||||||
|
logger.debug("cputemp:", JSON.stringify(cputemp));
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
cputemp: await si.cpuTemperature(),
|
cputemp,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === "uptime") {
|
if (type === "uptime") {
|
||||||
const timeData = await si.time();
|
const timeData = await si.time();
|
||||||
|
logger.debug("timeData:", JSON.stringify(timeData));
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
uptime: timeData.uptime,
|
uptime: timeData.uptime,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user