|
@ -1,5 +1,6 @@ |
|
|
const https = require("https"); |
|
|
const https = require("https"); |
|
|
const dayjs = require("dayjs"); |
|
|
const dayjs = require("dayjs"); |
|
|
|
|
|
const mqtt = require("mqtt"); |
|
|
const utc = require("dayjs/plugin/utc"); |
|
|
const utc = require("dayjs/plugin/utc"); |
|
|
let timezone = require("dayjs/plugin/timezone"); |
|
|
let timezone = require("dayjs/plugin/timezone"); |
|
|
dayjs.extend(utc); |
|
|
dayjs.extend(utc); |
|
@ -7,7 +8,7 @@ dayjs.extend(timezone); |
|
|
const axios = require("axios"); |
|
|
const axios = require("axios"); |
|
|
const { Prometheus } = require("../prometheus"); |
|
|
const { Prometheus } = require("../prometheus"); |
|
|
const { debug, UP, DOWN, PENDING, flipStatus, TimeLogger } = require("../../src/util"); |
|
|
const { debug, UP, DOWN, PENDING, flipStatus, TimeLogger } = require("../../src/util"); |
|
|
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, errorLog } = require("../util-server"); |
|
|
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, errorLog, mqttAsync } = require("../util-server"); |
|
|
const { R } = require("redbean-node"); |
|
|
const { R } = require("redbean-node"); |
|
|
const { BeanModel } = require("redbean-node/dist/bean-model"); |
|
|
const { BeanModel } = require("redbean-node/dist/bean-model"); |
|
|
const { Notification } = require("../notification"); |
|
|
const { Notification } = require("../notification"); |
|
@ -319,6 +320,14 @@ class Monitor extends BeanModel { |
|
|
throw new Error("Server not found on Steam"); |
|
|
throw new Error("Server not found on Steam"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else if (this.type === "mqtt") { |
|
|
|
|
|
try { |
|
|
|
|
|
bean.msg = await mqttAsync(this.url, this.topic, this.successMessage); |
|
|
|
|
|
bean.status = UP; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
bean.status = DOWN; |
|
|
|
|
|
bean.msg = error.message; |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
bean.msg = "Unknown Monitor Type"; |
|
|
bean.msg = "Unknown Monitor Type"; |
|
|
bean.status = PENDING; |
|
|
bean.status = PENDING; |
|
|