Adds widget to fetch and display system stats

This commit is contained in:
Alicia Sykes
2021-12-16 04:03:36 +00:00
parent 6e84dacd51
commit e0b09d48ee
6 changed files with 222 additions and 1 deletions

24
services/system-info.js Normal file
View File

@@ -0,0 +1,24 @@
/**
* Gets basic system info, for the resource usage widget
*/
const os = require('os');
module.exports = () => {
const meta = {
timestamp: new Date(),
uptime: os.uptime(),
hostname: os.hostname(),
username: os.userInfo().username,
system: `${os.version()} (${os.platform()})`,
};
const memory = {
total: `${Math.round(os.totalmem() / (1024 * 1024 * 1024))} GB`,
freePercent: (os.freemem() / os.totalmem()).toFixed(2),
};
const loadAv = os.loadavg();
const load = { one: loadAv[0], five: loadAv[1], fifteen: loadAv[2] };
return { meta, memory, load };
};