feat: show connetion count on /info

This commit is contained in:
Barış Soner Uşaklı
2024-06-11 11:53:19 -04:00
parent c2f6309080
commit 60b4bc662f
4 changed files with 12 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
"ip": "IP <strong>%1</strong>",
"nodes-responded": "%1 nodes responded within %2ms!",
"host": "host",
"primary": "primary / run jobs",
"primary": "primary / jobs",
"pid": "pid",
"nodejs": "nodejs",
"online": "online",
@@ -19,6 +19,7 @@
"registered": "Registered",
"sockets": "Sockets",
"connection-count": "Connection Count",
"guests": "Guests",
"info": "Info"

View File

@@ -2,6 +2,7 @@
const topics = require('../../topics');
const io = require('..');
const webserver = require('../../webserver');
const totals = {};
@@ -94,6 +95,7 @@ SocketRooms.getLocalStats = function () {
onlineGuestCount: 0,
onlineRegisteredCount: 0,
socketCount: 0,
connectionCount: webserver.getConnectionCount(),
users: {
categories: 0,
recent: 0,

View File

@@ -19,7 +19,7 @@
<td class="fw-bold">[[admin/development/info:process-memory]]</td>
<td class="fw-bold">[[admin/development/info:system-memory]]</td>
<td class="fw-bold">[[admin/development/info:load]]</td>
<td class="fw-bold">[[admin/development/info:uptime]]</td>
<td class="fw-bold text-end">[[admin/development/info:uptime]]</td>
</tr>
</thead>
<tbody class="text-xs">
@@ -34,7 +34,8 @@
<td>
<span title="[[admin/development/info:registered]]">{info.stats.onlineRegisteredCount}</span> /
<span title="[[admin/development/info:guests]]">{info.stats.onlineGuestCount}</span> /
<span title="[[admin/development/info:sockets]]">{info.stats.socketCount}</span>
<span title="[[admin/development/info:sockets]]">{info.stats.socketCount}</span> /
<span title="[[admin/development/info:connection-count]]">{info.stats.connectionCount}</span>
</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}%</td>
@@ -46,7 +47,7 @@
<span title="[[admin/development/info:total-memory-os]]">{info.os.totalmem} gb</span>
</td>
<td>{info.os.load}</td>
<td>{info.process.uptimeHumanReadable}</td>
<td class="text-end">{info.process.uptimeHumanReadable}</td>
</tr>
{{{ end }}}
</tbody>

View File

@@ -76,6 +76,10 @@ exports.destroy = function (callback) {
}
};
exports.getConnectionCount = function () {
return Object.keys(connections).length;
};
exports.listen = async function () {
emailer.registerApp(app);
setupExpressApp(app);