feat: add process cpu usage to admin

v1.18.x
Barış Soner Uşaklı 6 years ago
parent 684175f7d7
commit db47753877

@ -7,7 +7,8 @@
"online": "online",
"git": "git",
"memory": "memory",
"load": "load",
"load": "system load",
"cpu-usage": "cpu usage",
"uptime": "uptime",
"registered": "Registered",

@ -65,6 +65,7 @@ function getNodeInfo(callback) {
version: process.version,
memoryUsage: process.memoryUsage(),
uptime: process.uptime(),
cpuUsage: process.cpuUsage(),
},
os: {
hostname: os.hostname(),
@ -75,7 +76,8 @@ function getNodeInfo(callback) {
load: os.loadavg().map(function (load) { return load.toFixed(2); }).join(', '),
},
};
data.process.cpuUsage.user /= 1000;
data.process.cpuUsage.system /= 1000;
data.process.memoryUsage.humanReadable = (data.process.memoryUsage.rss / (1024 * 1024)).toFixed(2);
async.waterfall([

@ -15,6 +15,7 @@
<td>[[admin/development/info:nodejs]]</td>
<td>[[admin/development/info:online]]</td>
<td>[[admin/development/info:git]]</td>
<td>[[admin/development/info:cpu-usage]]</td>
<td>[[admin/development/info:memory]]</td>
<td>[[admin/development/info:load]]</td>
<td>[[admin/development/info:uptime]]</td>
@ -32,6 +33,7 @@
<span title="[[admin/development/info:sockets]]">{info.stats.socketCount}</span>
</td>
<td>{info.git.branch}@<a href="https://github.com/NodeBB/NodeBB/commit/{info.git.hash}" target="_blank">{info.git.hash}</a></td>
<td>{info.process.cpuUsage.user} / {info.process.cpuUsage.system}</td>
<td>{info.process.memoryUsage.humanReadable} mb</td>
<td>{info.os.load}</td>
<td>{info.process.uptime}</td>

Loading…
Cancel
Save