Support v4 for info widget
This commit is contained in:
parent
0af975b3d9
commit
3600f9d34f
@ -12,6 +12,7 @@ The Glances widget allows you to monitor the resources (CPU, memory, storage, te
|
|||||||
url: http://host.or.ip:port
|
url: http://host.or.ip:port
|
||||||
username: user # optional if auth enabled in Glances
|
username: user # optional if auth enabled in Glances
|
||||||
password: pass # optional if auth enabled in Glances
|
password: pass # optional if auth enabled in Glances
|
||||||
|
version: 4 # required only if running glances v4 or higher, defaults to 3
|
||||||
cpu: true # optional, enabled by default, disable by setting to false
|
cpu: true # optional, enabled by default, disable by setting to false
|
||||||
mem: true # optional, enabled by default, disable by setting to false
|
mem: true # optional, enabled by default, disable by setting to false
|
||||||
cputemp: true # disabled by default
|
cputemp: true # disabled by default
|
||||||
|
|||||||
@ -13,7 +13,7 @@ async function retrieveFromGlancesAPI(privateWidgetOptions, endpoint) {
|
|||||||
throw new Error(errorMessage);
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiUrl = `${url}/api/3/${endpoint}`;
|
const apiUrl = `${url}/api/${privateWidgetOptions.version}/${endpoint}`;
|
||||||
const headers = {
|
const headers = {
|
||||||
"Accept-Encoding": "application/json",
|
"Accept-Encoding": "application/json",
|
||||||
};
|
};
|
||||||
@ -42,9 +42,10 @@ async function retrieveFromGlancesAPI(privateWidgetOptions, endpoint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
const { index, cputemp: includeCpuTemp, uptime: includeUptime, disk: includeDisks } = req.query;
|
const { index, cputemp: includeCpuTemp, uptime: includeUptime, disk: includeDisks, version } = req.query;
|
||||||
|
|
||||||
const privateWidgetOptions = await getPrivateWidgetOptions("glances", index);
|
const privateWidgetOptions = await getPrivateWidgetOptions("glances", index);
|
||||||
|
privateWidgetOptions.version = version ?? 3;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const cpuData = await retrieveFromGlancesAPI(privateWidgetOptions, "cpu");
|
const cpuData = await retrieveFromGlancesAPI(privateWidgetOptions, "cpu");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user