forked from mirror/MCSM-Daemon
新增 兼容性字段
This commit is contained in:
parent
08334f4983
commit
8c9eebb5ee
@ -95,16 +95,18 @@ function setLinuxSystemInfo() {
|
|||||||
list.forEach((line) => {
|
list.forEach((line) => {
|
||||||
const kv = line.split(":");
|
const kv = line.split(":");
|
||||||
if (kv.length === 2) {
|
if (kv.length === 2) {
|
||||||
const k = kv[0].replace(/ /gim, "").replace(/\t/gim, "").trim();
|
const k = kv[0].replace(/ /gim, "").replace(/\t/gim, "").trim().toLowerCase();
|
||||||
let v = kv[1].replace(/ /gim, "").replace(/\t/gim, "").trim();
|
let v = kv[1].replace(/ /gim, "").replace(/\t/gim, "").trim().toLowerCase();
|
||||||
v = v.replace(/KB/gim, "").replace(/MB/gim, "").replace(/GB/gim, "");
|
v = v.replace(/kb/gim, "").replace(/mb/gim, "").replace(/gb/gim, "");
|
||||||
let vNumber = parseInt(v);
|
let vNumber = parseInt(v);
|
||||||
if (isNaN(vNumber)) vNumber = 0;
|
if (isNaN(vNumber)) vNumber = 0;
|
||||||
infoTable[k] = vNumber;
|
infoTable[k] = vNumber;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
info.freemem = infoTable["MemAvailable"] * 1024;
|
const memAvailable = infoTable["memavailable"] ?? infoTable["memfree"];
|
||||||
info.totalmem = infoTable["MemTotal"] * 1024;
|
const memTotal = infoTable["memtotal"];
|
||||||
|
info.freemem = memAvailable * 1024;
|
||||||
|
info.totalmem = memTotal * 1024;
|
||||||
info.memUsage = (info.totalmem - info.freemem) / info.totalmem;
|
info.memUsage = (info.totalmem - info.freemem) / info.totalmem;
|
||||||
osUtils.cpuUsage((p) => (info.cpuUsage = p));
|
osUtils.cpuUsage((p) => (info.cpuUsage = p));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user