Skip to content

Commit

Permalink
Add resources debug
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon committed Aug 14, 2024
1 parent 2ee14eb commit 40b0f95
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/pages/api/widgets/resources.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { existsSync } from "fs";

import createLogger from "utils/logger";

const logger = createLogger("resources");

const si = require("systeminformation");

export default async function handler(req, res) {
Expand All @@ -23,26 +27,31 @@ export default async function handler(req, res) {
}

const fsSize = await si.fsSize();

logger.debug("fsSize:", JSON.stringify(fsSize));
return res.status(200).json({
drive: fsSize.find((fs) => fs.mount === target) ?? fsSize.find((fs) => fs.mount === "/"),
});
}

if (type === "memory") {
const memory = await si.mem();
logger.debug("memory:", JSON.stringify(memory));
return res.status(200).json({
memory: await si.mem(),
memory,
});
}

if (type === "cputemp") {
const cputemp = await si.cpuTemperature();
logger.debug("cputemp:", JSON.stringify(cputemp));
return res.status(200).json({
cputemp: await si.cpuTemperature(),
cputemp,
});
}

if (type === "uptime") {
const timeData = await si.time();
logger.debug("timeData:", JSON.stringify(timeData));
return res.status(200).json({
uptime: timeData.uptime,
});
Expand Down

0 comments on commit 40b0f95

Please sign in to comment.