InfoBroker: Add cpu_live
This commit is contained in:
parent
e99ebc9732
commit
67a235ad42
1 changed files with 10 additions and 4 deletions
|
@ -13,11 +13,16 @@ const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));
|
||||||
|
|
||||||
class InfoBroker {
|
class InfoBroker {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.sym_meta = Symbol("____meta_info____")
|
|
||||||
this.allowed_tables = {
|
this.allowed_tables = {
|
||||||
// name → sysinfo name
|
// name → sysinfo name
|
||||||
cpu: "cpu",
|
cpu: "cpu",
|
||||||
meta: this.sym_meta
|
cpu_live: async () => {
|
||||||
|
return {
|
||||||
|
frequency: await sysinfo.cpuCurrentSpeed(),
|
||||||
|
temperature: await sysinfo.cpuTemperature()
|
||||||
|
};
|
||||||
|
},
|
||||||
|
meta: async () => await this.make_table_meta()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +50,9 @@ class InfoBroker {
|
||||||
}
|
}
|
||||||
|
|
||||||
let name_translated = this.allowed_tables[name];
|
let name_translated = this.allowed_tables[name];
|
||||||
if(name_translated === this.sym_meta)
|
|
||||||
return await this.make_table_meta();
|
if(typeof name_translated === "function")
|
||||||
|
return await name_translated();
|
||||||
|
|
||||||
return await sysinfo[name_translated]();
|
return await sysinfo[name_translated]();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue