mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-11 23:58:46 +00:00
Convert resources widget to systeminformation dependency
Update resources.js
This commit is contained in:
parent
bffda3240a
commit
d4a3ba84e9
5 changed files with 24 additions and 18 deletions
|
@ -1,15 +1,16 @@
|
|||
import { existsSync } from "fs";
|
||||
|
||||
import { cpu, drive, mem } from "node-os-utils";
|
||||
const si = require('systeminformation');
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const { type, target } = req.query;
|
||||
|
||||
if (type === "cpu") {
|
||||
const load = await si.currentLoad();
|
||||
return res.status(200).json({
|
||||
cpu: {
|
||||
usage: await cpu.usage(1000),
|
||||
load: cpu.loadavgTime(5),
|
||||
usage: load.currentLoad,
|
||||
load: load.avgLoad,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -21,14 +22,16 @@ export default async function handler(req, res) {
|
|||
});
|
||||
}
|
||||
|
||||
const fsSize = await si.fsSize();
|
||||
|
||||
return res.status(200).json({
|
||||
drive: await drive.info(target || "/"),
|
||||
drive: fsSize.find(fs => fs.mount === target) ?? fsSize.find(fs => fs.mount === "/")
|
||||
});
|
||||
}
|
||||
|
||||
if (type === "memory") {
|
||||
return res.status(200).json({
|
||||
memory: await mem.info(),
|
||||
memory: await si.mem(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue