matterbridge 2.1.6-dev.3 → 2.1.6-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -33,19 +33,22 @@ matterbridge-zigbee2mqtt v. 2.4.4
33
33
  matterbridge-somfy-tahoma v. 1.2.3
34
34
  matterbridge-hass v. 0.0.8
35
35
 
36
- ## [2.1.6] - 2025-02-13
36
+ ## [2.1.6] - 2025-02-15
37
37
 
38
38
  ### Added
39
39
 
40
- - [docker]: Added health check directly inside the docker image. No need to change configuration.
40
+ - [docker]: Added health check directly in the docker image. No need to change configuration.
41
41
  - [platform]: Saving in the storage the selects for faster loading of plugins.
42
42
  - [icon]: Added matterbridge svg icon (thanks: https://github.com/robvanoostenrijk https://github.com/stuntguy3000).
43
+ - [frontend]: Added processUptime.
43
44
  - [frontend]: Frontend v.2.4.2.
45
+ - [PluginManager]: Refactor PluginManager to optimize memory and load time.
44
46
 
45
47
  ### Changed
46
48
 
47
49
  - [package]: Update matter.js to 0.12.4-alpha.0-20250212-b2729c9eb
48
50
  - [package]: Update matter.js to 0.12.4-alpha.0-20250213-1187f81eb
51
+ - [package]: Update matter.js to 0.12.4-alpha.0-20250215-5af08a8d6
49
52
 
50
53
  <a href="https://www.buymeacoffee.com/luligugithub">
51
54
  <img src="./yellow-button.png" alt="Buy me a coffee" width="120">
package/dist/cli.js CHANGED
@@ -1,10 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { Matterbridge } from './matterbridge.js';
3
- let instance;
3
+ import { EventEmitter } from 'events';
4
+ export const cliEmitter = new EventEmitter();
5
+ export let instance;
4
6
  let session;
5
7
  let memoryCheckInterval;
6
8
  let prevCpus;
7
- let lastCpuUsage = 0;
9
+ export let lastCpuUsage = 0;
8
10
  const cli = '\u001B[32m';
9
11
  const er = '\u001B[38;5;9m';
10
12
  const rs = '\u001B[40;0m';
@@ -13,21 +15,22 @@ const CYAN = '\u001B[36m';
13
15
  const YELLOW = '\u001B[33m';
14
16
  const BRIGHT = '\u001B[1m';
15
17
  async function main() {
16
- if (process.argv.includes('-memorycheck'))
17
- await startMemoryCheck();
18
+ await startCpuMemoryCheck();
18
19
  if (process.argv.includes('-inspector'))
19
20
  await startInspector();
20
21
  if (process.argv.includes('-debug'))
21
- console.log(cli + `CLI: ${process.argv.includes('-edge') ? 'MatterbridgeEdge' : 'Matterbridge'}.loadInstance() called` + rs);
22
+ console.log(cli + `CLI: Matterbridge.loadInstance() called` + rs);
22
23
  instance = await Matterbridge.loadInstance(true);
23
24
  registerHandlers();
24
25
  if (process.argv.includes('-debug'))
25
- console.log(cli + `CLI: ${process.argv.includes('-edge') ? 'MatterbridgeEdge' : 'Matterbridge'}.loadInstance() exited` + rs);
26
+ console.log(cli + `CLI: Matterbridge.loadInstance() exited` + rs);
26
27
  }
27
- async function startMemoryCheck() {
28
+ async function startCpuMemoryCheck() {
28
29
  const os = await import('node:os');
29
- console.log(cli + `CLI: Memory check started` + rs);
30
+ if (process.argv.includes('-debug'))
31
+ console.log(cli + `CLI: Cpu memory check started` + rs);
30
32
  prevCpus = os.cpus();
33
+ clearInterval(memoryCheckInterval);
31
34
  const formatMemoryUsage = (bytes) => {
32
35
  if (bytes >= 1024 ** 3) {
33
36
  return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
@@ -39,12 +42,41 @@ async function startMemoryCheck() {
39
42
  return `${(bytes / 1024).toFixed(2)} KB`;
40
43
  }
41
44
  };
45
+ const formatOsUpTime = (seconds) => {
46
+ if (seconds >= 86400) {
47
+ const days = Math.floor(seconds / 86400);
48
+ return `${days} day${days !== 1 ? 's' : ''}`;
49
+ }
50
+ if (seconds >= 3600) {
51
+ const hours = Math.floor(seconds / 3600);
52
+ return `${hours} hour${hours !== 1 ? 's' : ''}`;
53
+ }
54
+ if (seconds >= 60) {
55
+ const minutes = Math.floor(seconds / 60);
56
+ return `${minutes} minute${minutes !== 1 ? 's' : ''}`;
57
+ }
58
+ return `${seconds} second${seconds !== 1 ? 's' : ''}`;
59
+ };
42
60
  const interval = () => {
61
+ const systemUptime = formatOsUpTime(Math.floor(os.uptime()));
62
+ const processUptime = formatOsUpTime(Math.floor(process.uptime()));
63
+ cliEmitter.emit('uptime', systemUptime, processUptime);
64
+ const totalMememory = formatMemoryUsage(os.totalmem());
65
+ const freeMemory = formatMemoryUsage(os.freemem());
66
+ const memoryUsageRaw = process.memoryUsage();
67
+ const rss = formatMemoryUsage(memoryUsageRaw.rss);
68
+ const heapTotal = formatMemoryUsage(memoryUsageRaw.heapTotal);
69
+ const heapUsed = formatMemoryUsage(memoryUsageRaw.heapUsed);
70
+ const external = formatMemoryUsage(memoryUsageRaw.external);
71
+ const arrayBuffers = formatMemoryUsage(memoryUsageRaw.arrayBuffers);
72
+ cliEmitter.emit('memory', totalMememory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers);
43
73
  const currCpus = os.cpus();
44
74
  let cpuUsageLog;
45
75
  if (currCpus.length !== prevCpus.length) {
46
76
  prevCpus = currCpus;
47
- cpuUsageLog = lastCpuUsage.toFixed(2);
77
+ if (process.argv.includes('-debug'))
78
+ console.log(cli + `CLI: Cpu check length failed, resetting previous cpus` + rs);
79
+ return;
48
80
  }
49
81
  let totalIdle = 0, totalTick = 0;
50
82
  prevCpus.forEach((prevCpu, i) => {
@@ -56,36 +88,32 @@ async function startMemoryCheck() {
56
88
  });
57
89
  const cpuUsage = 100 - (totalIdle / totalTick) * 100;
58
90
  if (totalTick === 0 || isNaN(cpuUsage) || !isFinite(cpuUsage) || cpuUsage <= 0) {
91
+ if (process.argv.includes('-debug') && lastCpuUsage != 0)
92
+ console.log(cli + `CLI: Cpu check failed, using previous cpus` + rs);
59
93
  cpuUsageLog = lastCpuUsage.toFixed(2);
60
94
  }
95
+ else {
96
+ cpuUsageLog = cpuUsage.toFixed(2);
97
+ lastCpuUsage = cpuUsage;
98
+ cliEmitter.emit('cpu', lastCpuUsage);
99
+ }
61
100
  prevCpus = currCpus;
62
- lastCpuUsage = cpuUsage;
63
- cpuUsageLog = cpuUsage.toFixed(2);
64
- const memoryUsageRaw = process.memoryUsage();
65
- const memoryUsage = {
66
- rss: formatMemoryUsage(memoryUsageRaw.rss),
67
- heapTotal: formatMemoryUsage(memoryUsageRaw.heapTotal),
68
- heapUsed: formatMemoryUsage(memoryUsageRaw.heapUsed),
69
- external: formatMemoryUsage(memoryUsageRaw.external),
70
- arrayBuffers: formatMemoryUsage(memoryUsageRaw.arrayBuffers),
71
- };
72
- console.log(`${YELLOW}${BRIGHT}Cpu usage:${db} ${CYAN}${cpuUsageLog.padStart(6, ' ')} %${db} ${YELLOW}${BRIGHT}Memory usage:${db} rss ${CYAN}${memoryUsage.rss}${db} heapTotal ${CYAN}${memoryUsage.heapTotal}${db} heapUsed ${CYAN}${memoryUsage.heapUsed}${db} external ${memoryUsage.external} arrayBuffers ${memoryUsage.arrayBuffers}` +
73
- rs);
101
+ if (process.argv.includes('-debug'))
102
+ console.log(`${YELLOW}${BRIGHT}Cpu usage:${db} ${CYAN}${cpuUsageLog.padStart(6, ' ')} %${db} ${YELLOW}${BRIGHT}Memory usage:${db} rss ${CYAN}${rss}${db} heapTotal ${CYAN}${heapTotal}${db} heapUsed ${CYAN}${heapUsed}${db} external ${external} arrayBuffers ${arrayBuffers}` +
103
+ rs);
74
104
  };
75
105
  interval();
76
- memoryCheckInterval = setInterval(interval, 1000);
106
+ memoryCheckInterval = setInterval(interval, 10 * 1000);
77
107
  }
78
- async function stopMemoryCheck() {
79
- console.log(cli + `CLI: Stopping memory check in 5 minute` + rs);
80
- instance = undefined;
81
- setTimeout(() => {
82
- console.log(cli + `CLI: Memory check stopped` + rs);
83
- clearInterval(memoryCheckInterval);
84
- process.exit(0);
85
- }, 5 * 60 * 1000);
108
+ async function stopCpuMemoryCheck() {
109
+ if (process.argv.includes('-debug'))
110
+ console.log(cli + `CLI: Cpu memory check stopped` + rs);
111
+ clearInterval(memoryCheckInterval);
86
112
  }
87
113
  async function startInspector() {
88
114
  const { Session } = await import('node:inspector');
115
+ if (process.argv.includes('-debug'))
116
+ console.log(cli + `CLI: Starting heap sampling...` + rs);
89
117
  session = new Session();
90
118
  session.connect();
91
119
  session.post('HeapProfiler.startSampling', {}, (err) => {
@@ -97,15 +125,19 @@ async function startInspector() {
97
125
  }
98
126
  async function stopInspector() {
99
127
  const { writeFileSync } = await import('node:fs');
100
- session.post('HeapProfiler.stopSampling', (err, result) => {
128
+ if (process.argv.includes('-debug'))
129
+ console.log(cli + `CLI: Stopping heap sampling...` + rs);
130
+ session?.post('HeapProfiler.stopSampling', (err, result) => {
101
131
  if (err) {
102
132
  console.error(err);
103
133
  }
104
134
  else {
105
135
  const profile = JSON.stringify(result.profile, null, 2);
106
- writeFileSync('heap-sampling-profile.heapsampling.json', profile);
136
+ writeFileSync('heap-sampling-profile.heapsnapshot', profile);
107
137
  console.log(cli + `CLI: Heap sampling profile saved to heap-sampling-profile.heapsnapshot` + rs);
108
138
  }
139
+ session?.disconnect();
140
+ session = undefined;
109
141
  });
110
142
  }
111
143
  function registerHandlers() {
@@ -115,18 +147,18 @@ function registerHandlers() {
115
147
  instance.on('restart', async () => restart());
116
148
  if (instance)
117
149
  instance.on('update', async () => update());
150
+ if (instance)
151
+ instance.on('startmemorycheck', async () => start());
152
+ if (instance)
153
+ instance.on('stopmemorycheck', async () => stop());
118
154
  }
119
155
  async function shutdown() {
120
156
  if (process.argv.includes('-debug'))
121
157
  console.log(cli + 'CLI: received shutdown event, exiting...' + rs);
122
158
  if (process.argv.includes('-inspector'))
123
159
  await stopInspector();
124
- if (process.argv.includes('-memorycheck')) {
125
- await stopMemoryCheck();
126
- }
127
- else {
128
- process.exit(0);
129
- }
160
+ await stopCpuMemoryCheck();
161
+ process.exit(0);
130
162
  }
131
163
  async function restart() {
132
164
  if (process.argv.includes('-debug'))
@@ -140,6 +172,16 @@ async function update() {
140
172
  instance = await Matterbridge.loadInstance(true);
141
173
  registerHandlers();
142
174
  }
175
+ async function start() {
176
+ if (process.argv.includes('-debug'))
177
+ console.log(cli + 'CLI: received start memory check event' + rs);
178
+ startCpuMemoryCheck();
179
+ }
180
+ async function stop() {
181
+ if (process.argv.includes('-debug'))
182
+ console.log(cli + 'CLI: received stop memory check event' + rs);
183
+ stopCpuMemoryCheck();
184
+ }
143
185
  process.title = 'matterbridge';
144
186
  main().catch((error) => {
145
187
  console.error(er + `CLI: Matterbridge.loadInstance() failed with error: ${error}` + rs);
package/dist/frontend.js CHANGED
@@ -6,15 +6,16 @@ import WebSocket, { WebSocketServer } from 'ws';
6
6
  import os from 'os';
7
7
  import path from 'path';
8
8
  import { promises as fs } from 'fs';
9
- import { AnsiLogger, CYAN, db, debugStringify, er, nf, rs, stringify, UNDERLINE, UNDERLINEOFF, wr, YELLOW } from './logger/export.js';
10
- import { createZip, deepCopy, getIntParameter, hasParameter, isValidNumber, isValidObject, isValidString } from './utils/utils.js';
9
+ import { AnsiLogger, stringify, debugStringify, CYAN, db, er, nf, rs, UNDERLINE, UNDERLINEOFF, wr, YELLOW } from './logger/export.js';
10
+ import { createZip, deepCopy, hasParameter, isValidNumber, isValidObject, isValidString } from './utils/utils.js';
11
11
  import { plg } from './matterbridgeTypes.js';
12
12
  export const WS_ID_LOG = 0;
13
13
  export const WS_ID_REFRESH_NEEDED = 1;
14
14
  export const WS_ID_RESTART_NEEDED = 2;
15
15
  export const WS_ID_CPU_UPDATE = 3;
16
16
  export const WS_ID_MEMORY_UPDATE = 4;
17
- export const WS_ID_SNACKBAR = 5;
17
+ export const WS_ID_UPTIME_UPDATE = 5;
18
+ export const WS_ID_SNACKBAR = 6;
18
19
  export class Frontend {
19
20
  matterbridge;
20
21
  log;
@@ -171,9 +172,16 @@ export class Frontend {
171
172
  this.webSocketServer.on('error', (ws, error) => {
172
173
  this.log.error(`WebSocketServer error: ${error}`);
173
174
  });
174
- if (hasParameter('memorydump')) {
175
- this.startCpuMemoryDump();
176
- }
175
+ const { cliEmitter } = await import('./cli.js');
176
+ cliEmitter.on('uptime', (systemUptime, processUptime) => {
177
+ this.wssSendUptimeUpdate(systemUptime, processUptime);
178
+ });
179
+ cliEmitter.on('memory', (totalMememory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers) => {
180
+ this.wssSendMemoryUpdate(totalMememory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers);
181
+ });
182
+ cliEmitter.on('cpu', (cpuUsage) => {
183
+ this.wssSendCpuUpdate(cpuUsage);
184
+ });
177
185
  this.expressApp.post('/api/login', express.json(), async (req, res) => {
178
186
  const { password } = req.body;
179
187
  this.log.debug('The frontend sent /api/login', password);
@@ -785,9 +793,6 @@ export class Frontend {
785
793
  });
786
794
  this.webSocketServer = undefined;
787
795
  }
788
- if (hasParameter('memorydump')) {
789
- this.stopCpuMemoryDump();
790
- }
791
796
  }
792
797
  formatMemoryUsage = (bytes) => {
793
798
  if (bytes >= 1024 ** 3) {
@@ -800,8 +805,7 @@ export class Frontend {
800
805
  return `${(bytes / 1024).toFixed(2)} KB`;
801
806
  }
802
807
  };
803
- formatOsUpTime = () => {
804
- const seconds = os.uptime();
808
+ formatOsUpTime = (seconds) => {
805
809
  if (seconds >= 86400) {
806
810
  const days = Math.floor(seconds / 86400);
807
811
  return `${days} day${days !== 1 ? 's' : ''}`;
@@ -816,84 +820,13 @@ export class Frontend {
816
820
  }
817
821
  return `${seconds} second${seconds !== 1 ? 's' : ''}`;
818
822
  };
819
- getCpuUsage = () => {
820
- const currCpus = os.cpus();
821
- if (currCpus.length !== this.prevCpus.length) {
822
- this.prevCpus = deepCopy(currCpus);
823
- this.log.debug(`***Cpu usage reset. Current cpus: ${currCpus.length}. Previous cpus: ${this.prevCpus.length}.`);
824
- return this.lastCpuUsage.toFixed(2);
825
- }
826
- let totalIdle = 0, totalTick = 0;
827
- this.prevCpus.forEach((prevCpu, i) => {
828
- const currCpu = currCpus[i];
829
- const idleDiff = currCpu.times.idle - prevCpu.times.idle;
830
- const totalDiff = Object.keys(currCpu.times).reduce((acc, key) => acc + (currCpu.times[key] - prevCpu.times[key]), 0);
831
- totalIdle += idleDiff;
832
- totalTick += totalDiff;
833
- });
834
- const cpuUsage = 100 - (totalIdle / totalTick) * 100;
835
- if (totalTick === 0 || isNaN(cpuUsage) || !isFinite(cpuUsage) || cpuUsage <= 0) {
836
- this.log.debug('***Invalid cpu usage. Returning the previous one.');
837
- return this.lastCpuUsage.toFixed(2);
838
- }
839
- this.prevCpus = deepCopy(currCpus);
840
- this.lastCpuUsage = cpuUsage;
841
- return cpuUsage.toFixed(2);
842
- };
843
- startCpuMemoryDump() {
844
- clearInterval(this.memoryInterval);
845
- clearTimeout(this.memoryTimeout);
846
- const interval = () => {
847
- const cpuUsage = this.getCpuUsage();
848
- const memoryUsageRaw = process.memoryUsage();
849
- this.memoryData.push({ ...memoryUsageRaw, cpu: cpuUsage });
850
- const memoryUsage = {
851
- rss: this.formatMemoryUsage(memoryUsageRaw.rss),
852
- heapTotal: this.formatMemoryUsage(memoryUsageRaw.heapTotal),
853
- heapUsed: this.formatMemoryUsage(memoryUsageRaw.heapUsed),
854
- external: this.formatMemoryUsage(memoryUsageRaw.external),
855
- arrayBuffers: this.formatMemoryUsage(memoryUsageRaw.arrayBuffers),
856
- };
857
- this.log.debug(`***Cpu usage: ${CYAN}${cpuUsage.padStart(6, ' ')} %${db} - Memory usage: rss ${CYAN}${memoryUsage.rss}${db} heapTotal ${CYAN}${memoryUsage.heapTotal}${db} heapUsed ${CYAN}${memoryUsage.heapUsed}${db} external ${memoryUsage.external} arrayBuffers ${memoryUsage.arrayBuffers}`);
858
- this.matterbridge.systemInformation.freeMemory = this.formatMemoryUsage(os.freemem());
859
- this.matterbridge.systemInformation.totalMemory = this.formatMemoryUsage(os.totalmem());
860
- this.matterbridge.systemInformation.systemUptime = this.formatOsUpTime();
861
- this.matterbridge.systemInformation.cpuUsed = cpuUsage;
862
- this.matterbridge.systemInformation.rss = this.formatMemoryUsage(process.memoryUsage().rss);
863
- this.matterbridge.systemInformation.heapTotal = this.formatMemoryUsage(process.memoryUsage().heapTotal);
864
- this.matterbridge.systemInformation.heapUsed = this.formatMemoryUsage(process.memoryUsage().heapUsed);
865
- this.wssSendCpuUpdate(this.matterbridge.systemInformation.cpuUsed);
866
- this.wssSendMemoryUpdate(this.matterbridge.systemInformation.freeMemory, this.matterbridge.systemInformation.totalMemory, this.matterbridge.systemInformation.systemUptime, this.matterbridge.systemInformation.rss, this.matterbridge.systemInformation.heapUsed, this.matterbridge.systemInformation.heapTotal);
867
- };
868
- interval();
869
- this.memoryInterval = setInterval(interval, getIntParameter('memoryinterval') ?? 1000).unref();
870
- this.memoryTimeout = setTimeout(() => {
871
- this.stopCpuMemoryDump();
872
- }, getIntParameter('memorytimeout') ?? 600000).unref();
873
- }
874
- stopCpuMemoryDump() {
875
- clearInterval(this.memoryInterval);
876
- this.memoryInterval = undefined;
877
- clearTimeout(this.memoryTimeout);
878
- this.memoryTimeout = undefined;
879
- for (const memory of this.memoryData) {
880
- const memoryUsage = {
881
- rss: this.formatMemoryUsage(memory.rss),
882
- heapTotal: this.formatMemoryUsage(memory.heapTotal),
883
- heapUsed: this.formatMemoryUsage(memory.heapUsed),
884
- external: this.formatMemoryUsage(memory.external),
885
- arrayBuffers: this.formatMemoryUsage(memory.arrayBuffers),
886
- };
887
- console.log(`${YELLOW}Cpu usage:${db} ${CYAN}${memory.cpu.padStart(6, ' ')} %${db} - ${YELLOW}Memory usage:${db} rss ${CYAN}${memoryUsage.rss}${db} heapTotal ${CYAN}${memoryUsage.heapTotal}${db} heapUsed ${CYAN}${memoryUsage.heapUsed}${db} external ${memoryUsage.external} arrayBuffers ${memoryUsage.arrayBuffers}${rs}`);
888
- }
889
- this.memoryData = [];
890
- this.prevCpus = [];
891
- }
892
823
  async getApiSettings() {
824
+ const { lastCpuUsage } = await import('./cli.js');
893
825
  this.matterbridge.systemInformation.totalMemory = this.formatMemoryUsage(os.totalmem());
894
826
  this.matterbridge.systemInformation.freeMemory = this.formatMemoryUsage(os.freemem());
895
- this.matterbridge.systemInformation.systemUptime = this.formatOsUpTime();
896
- this.matterbridge.systemInformation.cpuUsed = this.getCpuUsage();
827
+ this.matterbridge.systemInformation.systemUptime = this.formatOsUpTime(os.uptime());
828
+ this.matterbridge.systemInformation.processUptime = this.formatOsUpTime(Math.floor(process.uptime()));
829
+ this.matterbridge.systemInformation.cpuUsage = lastCpuUsage.toFixed(2) + ' %';
897
830
  this.matterbridge.systemInformation.rss = this.formatMemoryUsage(process.memoryUsage().rss);
898
831
  this.matterbridge.systemInformation.heapTotal = this.formatMemoryUsage(process.memoryUsage().heapTotal);
899
832
  this.matterbridge.systemInformation.heapUsed = this.formatMemoryUsage(process.memoryUsage().heapUsed);
@@ -1378,21 +1311,27 @@ export class Frontend {
1378
1311
  }
1379
1312
  });
1380
1313
  }
1381
- wssSendCpuUpdate(cpuUsed) {
1314
+ wssSendCpuUpdate(cpuUsage) {
1315
+ this.log.debug('Sending a cpu update message to all connected clients');
1316
+ this.webSocketServer?.clients.forEach((client) => {
1317
+ if (client.readyState === WebSocket.OPEN) {
1318
+ client.send(JSON.stringify({ id: WS_ID_CPU_UPDATE, src: 'Matterbridge', dst: 'Frontend', method: 'cpu_update', params: { cpuUsage } }));
1319
+ }
1320
+ });
1321
+ }
1322
+ wssSendMemoryUpdate(totalMemory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers) {
1382
1323
  this.log.debug('Sending a memory update message to all connected clients');
1383
- this.matterbridge.matterbridgeInformation.restartRequired = true;
1384
1324
  this.webSocketServer?.clients.forEach((client) => {
1385
1325
  if (client.readyState === WebSocket.OPEN) {
1386
- client.send(JSON.stringify({ id: WS_ID_CPU_UPDATE, src: 'Matterbridge', dst: 'Frontend', method: 'cpu_update', params: { cpuUsed } }));
1326
+ client.send(JSON.stringify({ id: WS_ID_MEMORY_UPDATE, src: 'Matterbridge', dst: 'Frontend', method: 'memory_update', params: { totalMemory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers } }));
1387
1327
  }
1388
1328
  });
1389
1329
  }
1390
- wssSendMemoryUpdate(freeMemory, totalMemory, systemUptime, rss, heapUsed, heapTotal) {
1391
- this.log.debug('Sending a cpu update message to all connected clients');
1392
- this.matterbridge.matterbridgeInformation.restartRequired = true;
1330
+ wssSendUptimeUpdate(systemUptime, processUptime) {
1331
+ this.log.debug('Sending a uptime update message to all connected clients');
1393
1332
  this.webSocketServer?.clients.forEach((client) => {
1394
1333
  if (client.readyState === WebSocket.OPEN) {
1395
- client.send(JSON.stringify({ id: WS_ID_MEMORY_UPDATE, src: 'Matterbridge', dst: 'Frontend', method: 'memory_update', params: { freeMemory, totalMemory, systemUptime, rss, heapUsed, heapTotal } }));
1334
+ client.send(JSON.stringify({ id: WS_ID_UPTIME_UPDATE, src: 'Matterbridge', dst: 'Frontend', method: 'uptime_update', params: { systemUptime, processUptime } }));
1396
1335
  }
1397
1336
  });
1398
1337
  }
@@ -35,7 +35,8 @@ export class Matterbridge extends EventEmitter {
35
35
  totalMemory: '',
36
36
  freeMemory: '',
37
37
  systemUptime: '',
38
- cpuUsed: '',
38
+ processUptime: '',
39
+ cpuUsage: '',
39
40
  rss: '',
40
41
  heapTotal: '',
41
42
  heapUsed: '',
@@ -126,6 +127,12 @@ export class Matterbridge extends EventEmitter {
126
127
  constructor() {
127
128
  super();
128
129
  }
130
+ emit(eventName, ...args) {
131
+ return super.emit(eventName, ...args);
132
+ }
133
+ on(eventName, listener) {
134
+ return super.on(eventName, listener);
135
+ }
129
136
  getDevices() {
130
137
  return this.devices.array();
131
138
  }