fix network resource usage calculation
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
34de9788ba
commit
8c71ceafcf
@ -44,7 +44,7 @@
|
||||
},
|
||||
"network": {
|
||||
"type": "network",
|
||||
"multiplier": 1,
|
||||
"multiplier": 1000000,
|
||||
"compact": true,
|
||||
"unit": "MB/s"
|
||||
}
|
||||
|
7
pve.js
7
pve.js
@ -96,11 +96,14 @@ export async function getUsedResources (req, resourceMeta) {
|
||||
config = config.data.data;
|
||||
for (let key of Object.keys(config)) {
|
||||
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))) {
|
||||
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