mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-07 14:18:47 +00:00
Add resources debug
This commit is contained in:
parent
2ee14eb94b
commit
40b0f956ae
1 changed files with 12 additions and 3 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue