|
|
|
@ -7,7 +7,7 @@ dayjs.extend(timezone);
|
|
|
|
|
const axios = require("axios");
|
|
|
|
|
const { Prometheus } = require("../prometheus");
|
|
|
|
|
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 { BeanModel } = require("redbean-node/dist/bean-model");
|
|
|
|
|
const { Notification } = require("../notification");
|
|
|
|
@ -87,7 +87,12 @@ class Monitor extends BeanModel {
|
|
|
|
|
mqttUsername: this.mqttUsername,
|
|
|
|
|
mqttPassword: this.mqttPassword,
|
|
|
|
|
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) {
|
|
|
|
@ -435,6 +440,30 @@ class Monitor extends BeanModel {
|
|
|
|
|
interval: this.interval,
|
|
|
|
|
});
|
|
|
|
|
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 {
|
|
|
|
|
bean.msg = "Unknown Monitor Type";
|
|
|
|
|
bean.status = PENDING;
|
|
|
|
|