Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require("./alias-resolver");

const fs = require("node:fs");
const path = require("node:path");
const Spawn = require("node:child_process").spawn;
const envsub = require("envsub");
const Log = require("logger");

Expand All @@ -25,7 +26,7 @@ global.mmTestMode = process.env.mmTestMode === "true";
Log.log(`Starting MagicMirror: v${global.version}`);

// Log system information.
Utils.logSystemInformation(global.version);
Spawn("node ./js/systeminformation.js", { cwd: this.root_path, shell: true, detached: true, stdio: "inherit" });

if (process.env.MM_CONFIG_FILE) {
global.configuration_file = process.env.MM_CONFIG_FILE.replace(`${global.root_path}/`, "");
Expand Down
39 changes: 39 additions & 0 deletions js/systeminformation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const os = require("node:os");
const si = require("systeminformation");
// needed with relative path because logSystemInformation is called in an own process in app.js:
const mmVersion = require("../package").version;
const Log = require("./logger");

const logSystemInformation = async () => {
try {
const system = await si.system();
const osInfo = await si.osInfo();
const versions = await si.versions();

const usedNodeVersion = process.version.replace("v", "");
const installedNodeVersion = versions.node;
const totalRam = (os.totalmem() / 1024 / 1024).toFixed(2);
const freeRam = (os.freemem() / 1024 / 1024).toFixed(2);
const usedRam = ((os.totalmem() - os.freemem()) / 1024 / 1024).toFixed(2);

let systemDataString = [
"\n#### System Information ####",
`- SYSTEM: manufacturer: ${system.manufacturer}; model: ${system.model}; virtual: ${system.virtual}; MM: v${mmVersion}`,
`- OS: platform: ${osInfo.platform}; distro: ${osInfo.distro}; release: ${osInfo.release}; arch: ${osInfo.arch}; kernel: ${versions.kernel}`,
`- VERSIONS: electron: ${process.versions.electron}; used node: ${usedNodeVersion}; installed node: ${installedNodeVersion}; npm: ${versions.npm}; pm2: ${versions.pm2}`,
`- ENV: XDG_SESSION_TYPE: ${process.env.XDG_SESSION_TYPE}; MM_CONFIG_FILE: ${process.env.MM_CONFIG_FILE}`,
` WAYLAND_DISPLAY: ${process.env.WAYLAND_DISPLAY}; DISPLAY: ${process.env.DISPLAY}; ELECTRON_ENABLE_GPU: ${process.env.ELECTRON_ENABLE_GPU}`,
`- RAM: total: ${totalRam} MB; free: ${freeRam} MB; used: ${usedRam} MB`,
`- OTHERS: uptime: ${Math.floor(os.uptime() / 60)} minutes; timeZone: ${Intl.DateTimeFormat().resolvedOptions().timeZone}`
].join("\n");
Log.info(systemDataString);

// Return is currently only for tests
return systemDataString;
} catch (error) {
Log.error(error);
}
};

module.exports = logSystemInformation;
logSystemInformation();
33 changes: 0 additions & 33 deletions js/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const os = require("node:os");
const fs = require("node:fs");
const si = require("systeminformation");
const Log = require("logger");

const modulePositions = []; // will get list from index.html
Expand All @@ -10,37 +8,6 @@ const discoveredPositionsJSFilename = "js/positions.js";

module.exports = {

async logSystemInformation (mirrorVersion) {
try {
const system = await si.system();
const osInfo = await si.osInfo();
const versions = await si.versions();

const usedNodeVersion = process.version.replace("v", "");
const installedNodeVersion = versions.node;
const totalRam = (os.totalmem() / 1024 / 1024).toFixed(2);
const freeRam = (os.freemem() / 1024 / 1024).toFixed(2);
const usedRam = ((os.totalmem() - os.freemem()) / 1024 / 1024).toFixed(2);

let systemDataString = [
"\n#### System Information ####",
`- SYSTEM: manufacturer: ${system.manufacturer}; model: ${system.model}; virtual: ${system.virtual}; MM: ${mirrorVersion}`,
`- OS: platform: ${osInfo.platform}; distro: ${osInfo.distro}; release: ${osInfo.release}; arch: ${osInfo.arch}; kernel: ${versions.kernel}`,
`- VERSIONS: electron: ${process.versions.electron}; used node: ${usedNodeVersion}; installed node: ${installedNodeVersion}; npm: ${versions.npm}; pm2: ${versions.pm2}`,
`- ENV: XDG_SESSION_TYPE: ${process.env.XDG_SESSION_TYPE}; MM_CONFIG_FILE: ${process.env.MM_CONFIG_FILE}`,
` WAYLAND_DISPLAY: ${process.env.WAYLAND_DISPLAY}; DISPLAY: ${process.env.DISPLAY}; ELECTRON_ENABLE_GPU: ${process.env.ELECTRON_ENABLE_GPU}`,
`- RAM: total: ${totalRam} MB; free: ${freeRam} MB; used: ${usedRam} MB`,
`- OTHERS: uptime: ${Math.floor(os.uptime() / 60)} minutes; timeZone: ${Intl.DateTimeFormat().resolvedOptions().timeZone}`
].join("\n");
Log.info(systemDataString);

// Return is currently only for tests
return systemDataString;
} catch (error) {
Log.error(error);
}
},

// return all available module positions
getAvailableModulePositions () {
return modulePositions;
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/classes/systeminformation_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const SystemInformation = require("../../../js/systeminformation");

describe("SystemInformation", () => {
it("should output system information", async () => {
await expect(SystemInformation()).resolves.toContain("platform: linux");
});
});
7 changes: 0 additions & 7 deletions tests/unit/classes/utils_spec.js

This file was deleted.