|
|
@ -7,7 +7,7 @@ dayjs.extend(timezone);
|
|
|
|
const axios = require("axios");
|
|
|
|
const axios = require("axios");
|
|
|
|
const { Prometheus } = require("../prometheus");
|
|
|
|
const { Prometheus } = require("../prometheus");
|
|
|
|
const { log, UP, DOWN, PENDING, flipStatus, TimeLogger } = require("../../src/util");
|
|
|
|
const { log, UP, DOWN, PENDING, flipStatus, TimeLogger } = require("../../src/util");
|
|
|
|
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mqttAsync } = require("../util-server");
|
|
|
|
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, radius, setting, 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");
|
|
|
@ -87,7 +87,12 @@ class Monitor extends BeanModel {
|
|
|
|
mqttUsername: this.mqttUsername,
|
|
|
|
mqttUsername: this.mqttUsername,
|
|
|
|
mqttPassword: this.mqttPassword,
|
|
|
|
mqttPassword: this.mqttPassword,
|
|
|
|
mqttTopic: this.mqttTopic,
|
|
|
|
mqttTopic: this.mqttTopic,
|
|
|
|
mqttSuccessMessage: this.mqttSuccessMessage
|
|
|
|
mqttSuccessMessage: this.mqttSuccessMessage,
|
|
|
|
|
|
|
|
radiusUsername: this.radiusUsername,
|
|
|
|
|
|
|
|
radiusPassword: this.radiusPassword,
|
|
|
|
|
|
|
|
radiusCalledStationId: this.radiusCalledStationId,
|
|
|
|
|
|
|
|
radiusCallingStationId: this.radiusCallingStationId,
|
|
|
|
|
|
|
|
radiusSecret: this.radiusSecret
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (includeSensitiveData) {
|
|
|
|
if (includeSensitiveData) {
|
|
|
@ -435,6 +440,30 @@ class Monitor extends BeanModel {
|
|
|
|
interval: this.interval,
|
|
|
|
interval: this.interval,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
bean.status = UP;
|
|
|
|
bean.status = UP;
|
|
|
|
|
|
|
|
} else if (this.type === "radius") {
|
|
|
|
|
|
|
|
let startTime = dayjs().valueOf();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const resp = await radius(
|
|
|
|
|
|
|
|
this.hostname,
|
|
|
|
|
|
|
|
this.radiusUsername,
|
|
|
|
|
|
|
|
this.radiusPassword,
|
|
|
|
|
|
|
|
this.radiusCalledStationId,
|
|
|
|
|
|
|
|
this.radiusCallingStationId,
|
|
|
|
|
|
|
|
this.radiusSecret
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
if (resp.code) {
|
|
|
|
|
|
|
|
bean.msg = resp.code;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bean.status = UP;
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
bean.status = DOWN;
|
|
|
|
|
|
|
|
if (error.response?.code) {
|
|
|
|
|
|
|
|
bean.msg = error.response.code;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
bean.msg = error.message;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bean.ping = dayjs().valueOf() - startTime;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
bean.msg = "Unknown Monitor Type";
|
|
|
|
bean.msg = "Unknown Monitor Type";
|
|
|
|
bean.status = PENDING;
|
|
|
|
bean.status = PENDING;
|
|
|
|