Synology widget : adding volume size
This commit is contained in:
parent
6759aec51e
commit
977965babb
@ -418,7 +418,8 @@
|
|||||||
"volumeUsage": "Volume Usage",
|
"volumeUsage": "Volume Usage",
|
||||||
"cpuLoad": "CPU Load",
|
"cpuLoad": "CPU Load",
|
||||||
"memoryUsage": "Memory Usage",
|
"memoryUsage": "Memory Usage",
|
||||||
"status": "Status"
|
"status": "Status",
|
||||||
|
"volumeTotal": "Total space"
|
||||||
},
|
},
|
||||||
"opnsense": {
|
"opnsense": {
|
||||||
"cpu": "CPU Load",
|
"cpu": "CPU Load",
|
||||||
|
|||||||
@ -20,6 +20,7 @@ export default function Component({ service }) {
|
|||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="synology.uptime" />
|
<Block label="synology.uptime" />
|
||||||
<Block label="synology.volumeUsage" />
|
<Block label="synology.volumeUsage" />
|
||||||
|
<Block label="synology.volumeTotal" />
|
||||||
<Block label="synology.cpuLoad" />
|
<Block label="synology.cpuLoad" />
|
||||||
<Block label="synology.memoryUsage" />
|
<Block label="synology.memoryUsage" />
|
||||||
</Container>
|
</Container>
|
||||||
@ -31,6 +32,7 @@ export default function Component({ service }) {
|
|||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="synology.uptime" value={ dsData.uptime } />
|
<Block label="synology.uptime" value={ dsData.uptime } />
|
||||||
<Block label="synology.volumeUsage" value={t("common.percent", { value: dsData.usedVolume })} />
|
<Block label="synology.volumeUsage" value={t("common.percent", { value: dsData.usedVolume })} />
|
||||||
|
<Block label="synology.volumeTotal" value={t("common.bytes", { value: dsData.totalSize })} />
|
||||||
<Block label="synology.cpuLoad" value={t("common.percent", { value: dsData.cpuLoad })} />
|
<Block label="synology.cpuLoad" value={t("common.percent", { value: dsData.cpuLoad })} />
|
||||||
<Block label="synology.memoryUsage" value={t("common.percent", { value: dsData.memoryUsage })} />
|
<Block label="synology.memoryUsage" value={t("common.percent", { value: dsData.memoryUsage })} />
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
@ -76,8 +76,6 @@ export default async function synologyProxyHandler(req, res) {
|
|||||||
|
|
||||||
[status, contentType, data] = await httpProxy(storageUrl );
|
[status, contentType, data] = await httpProxy(storageUrl );
|
||||||
|
|
||||||
|
|
||||||
let usedVolume = 0;
|
|
||||||
if (status !== 200) {
|
if (status !== 200) {
|
||||||
return res.status(status).set("Content-Type", contentType).send(data);
|
return res.status(status).set("Content-Type", contentType).send(data);
|
||||||
}
|
}
|
||||||
@ -85,7 +83,8 @@ export default async function synologyProxyHandler(req, res) {
|
|||||||
if (json?.success !== true) {
|
if (json?.success !== true) {
|
||||||
return res.status(401).json({ error: "Error getting volume stats" });
|
return res.status(401).json({ error: "Error getting volume stats" });
|
||||||
}
|
}
|
||||||
usedVolume = 100 * parseFloat(json.data.vol_info[0].used_size) / parseFloat(json.data.vol_info[0].total_size);
|
const totalSize = parseFloat(json.data.vol_info[0].total_size);
|
||||||
|
const usedVolume = 100 * parseFloat(json.data.vol_info[0].used_size) / parseFloat(json.data.vol_info[0].total_size);
|
||||||
|
|
||||||
const healthUrl = `${widget.url}/webapi/${path}?api=${api}&version=${maxVersion}&method=info&_sid=${sid}`;
|
const healthUrl = `${widget.url}/webapi/${path}?api=${api}&version=${maxVersion}&method=info&_sid=${sid}`;
|
||||||
[status, contentType, data] = await httpProxy(healthUrl);
|
[status, contentType, data] = await httpProxy(healthUrl);
|
||||||
@ -110,6 +109,7 @@ export default async function synologyProxyHandler(req, res) {
|
|||||||
const resdata = {
|
const resdata = {
|
||||||
uptime,
|
uptime,
|
||||||
usedVolume,
|
usedVolume,
|
||||||
|
totalSize,
|
||||||
memoryUsage,
|
memoryUsage,
|
||||||
cpuLoad,
|
cpuLoad,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user