fix network resource usage calculation
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
ce901e71d3
commit
f27ea02f10
@ -44,7 +44,7 @@
|
|||||||
},
|
},
|
||||||
"network": {
|
"network": {
|
||||||
"type": "network",
|
"type": "network",
|
||||||
"multiplier": 1,
|
"multiplier": 1000000,
|
||||||
"compact": true,
|
"compact": true,
|
||||||
"unit": "MB/s"
|
"unit": "MB/s"
|
||||||
}
|
}
|
||||||
|
7
pve.js
7
pve.js
@ -96,11 +96,14 @@ export async function getUsedResources (req, resourceMeta) {
|
|||||||
config = config.data.data;
|
config = config.data.data;
|
||||||
for (let key of Object.keys(config)) {
|
for (let key of Object.keys(config)) {
|
||||||
if (Object.keys(used).includes(key) && resourceMeta[key].type === "numeric") {
|
if (Object.keys(used).includes(key) && resourceMeta[key].type === "numeric") {
|
||||||
used[key] += config[key];
|
used[key] += Number(config[key]);
|
||||||
}
|
}
|
||||||
else if (diskprefixes.some(prefix => key.startsWith(prefix))) {
|
else if (diskprefixes.some(prefix => key.startsWith(prefix))) {
|
||||||
let diskInfo = await getDiskInfo(instance.node, instance.type, instance.vmid, key);
|
let diskInfo = await getDiskInfo(instance.node, instance.type, instance.vmid, key);
|
||||||
used[diskInfo.storage] += diskInfo.size;
|
used[diskInfo.storage] += Number(diskInfo.size);
|
||||||
|
}
|
||||||
|
else if (key.startsWith("net")) {
|
||||||
|
used.network += Number(config[key].split("rate=")[1].split(",")[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user