Skip to content

Node.js based forum software built for the modern web

feat: add free and total mem usage to info

Barış Soner Uşaklıa7b6d0dfe5f8
diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.js
index f3764ac7e7..36dec3a0ef 100644
--- a/src/controllers/admin/info.js
+++ b/src/controllers/admin/info.js
@@ -78,6 +78,8 @@ async function getNodeInfo() {
arch: os.arch(),
release: os.release(),
load: os.loadavg().map(function (load) { return load.toFixed(2); }).join(', '),
+ freemem: os.freemem(),
+ totalmem: os.totalmem(),
},
nodebb: {
isCluster: nconf.get('isCluster'),
@@ -91,7 +93,8 @@ async function getNodeInfo() {
data.process.cpuUsage.system /= 1000000;
data.process.cpuUsage.system = data.process.cpuUsage.system.toFixed(2);
data.process.memoryUsage.humanReadable = (data.process.memoryUsage.rss / (1024 * 1024)).toFixed(2);
-
+ data.os.freemem = (data.os.freemem / 1000000).toFixed(2);
+ data.os.totalmem = (data.os.totalmem / 1000000).toFixed(2);
const [stats, gitInfo] = await Promise.all([
rooms.getLocalStats(),
getGitInfo(),
diff --git a/src/views/admin/development/info.tpl b/src/views/admin/development/info.tpl
index 56b3b9cc67..5d4df86bd5 100644
--- a/src/views/admin/development/info.tpl
+++ b/src/views/admin/development/info.tpl
@@ -39,7 +39,7 @@
</td>
<td>{info.git.branch}@<a href="https://github.com/NodeBB/NodeBB/commit/{info.git.hash}" target="_blank">{info.git.hashShort}</a></td>
<td>{info.process.cpuUsage.user} / {info.process.cpuUsage.system}</td>
- <td>{info.process.memoryUsage.humanReadable} mb</td>
+ <td>{info.process.memoryUsage.humanReadable} mb / {info.os.freemem} mb</td>
<td>{info.os.load}</td>
<td>{info.process.uptime}</td>
</tr>