mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-22 06:52:33 +02:00
Write MQTT published topic in message
So that when wildcards for monitoring are used, the full published topic is displayed.
This commit is contained in:
parent
558195ae6a
commit
a8b8a21f4c
1 changed files with 3 additions and 3 deletions
|
@ -10,7 +10,7 @@ class MqttMonitorType extends MonitorType {
|
|||
* @inheritdoc
|
||||
*/
|
||||
async check(monitor, heartbeat, server) {
|
||||
const receivedMessage = await this.mqttAsync(monitor.hostname, monitor.mqttTopic, {
|
||||
const [ messageTopic, receivedMessage ] = await this.mqttAsync(monitor.hostname, monitor.mqttTopic, {
|
||||
port: monitor.port,
|
||||
username: monitor.mqttUsername,
|
||||
password: monitor.mqttPassword,
|
||||
|
@ -24,7 +24,7 @@ class MqttMonitorType extends MonitorType {
|
|||
|
||||
if (monitor.mqttCheckType === "keyword") {
|
||||
if (receivedMessage != null && receivedMessage.includes(monitor.mqttSuccessMessage)) {
|
||||
heartbeat.msg = `Topic: ${monitor.mqttTopic}; Message: ${receivedMessage}`;
|
||||
heartbeat.msg = `Topic: ${messageTopic}; Message: ${receivedMessage}`;
|
||||
heartbeat.status = UP;
|
||||
} else {
|
||||
throw Error(`Message Mismatch - Topic: ${monitor.mqttTopic}; Message: ${receivedMessage}`);
|
||||
|
@ -103,7 +103,7 @@ class MqttMonitorType extends MonitorType {
|
|||
client.on("message", (messageTopic, message) => {
|
||||
client.end();
|
||||
clearTimeout(timeoutID);
|
||||
resolve(message.toString("utf8"));
|
||||
resolve([ messageTopic, message.toString("utf8") ]);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue