|
|
@ -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, mssqlQuery, mqttAsync, setSetting } = require("../util-server");
|
|
|
|
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, mqttAsync, setSetting, httpNtlm } = 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");
|
|
|
@ -96,6 +96,9 @@ class Monitor extends BeanModel {
|
|
|
|
mqttSuccessMessage: this.mqttSuccessMessage,
|
|
|
|
mqttSuccessMessage: this.mqttSuccessMessage,
|
|
|
|
databaseConnectionString: this.databaseConnectionString,
|
|
|
|
databaseConnectionString: this.databaseConnectionString,
|
|
|
|
databaseQuery: this.databaseQuery,
|
|
|
|
databaseQuery: this.databaseQuery,
|
|
|
|
|
|
|
|
authMethod: this.authMethod,
|
|
|
|
|
|
|
|
authWorkstation: this.authWorkstation,
|
|
|
|
|
|
|
|
authDomain: this.authDomain,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (includeSensitiveData) {
|
|
|
|
if (includeSensitiveData) {
|
|
|
@ -221,7 +224,7 @@ class Monitor extends BeanModel {
|
|
|
|
|
|
|
|
|
|
|
|
// HTTP basic auth
|
|
|
|
// HTTP basic auth
|
|
|
|
let basicAuthHeader = {};
|
|
|
|
let basicAuthHeader = {};
|
|
|
|
if (this.basic_auth_user) {
|
|
|
|
if (this.auth_method === "basic") {
|
|
|
|
basicAuthHeader = {
|
|
|
|
basicAuthHeader = {
|
|
|
|
"Authorization": "Basic " + this.encodeBase64(this.basic_auth_user, this.basic_auth_pass),
|
|
|
|
"Authorization": "Basic " + this.encodeBase64(this.basic_auth_user, this.basic_auth_pass),
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -272,7 +275,21 @@ class Monitor extends BeanModel {
|
|
|
|
log.debug("monitor", `[${this.name}] Axios Options: ${JSON.stringify(options)}`);
|
|
|
|
log.debug("monitor", `[${this.name}] Axios Options: ${JSON.stringify(options)}`);
|
|
|
|
log.debug("monitor", `[${this.name}] Axios Request`);
|
|
|
|
log.debug("monitor", `[${this.name}] Axios Request`);
|
|
|
|
|
|
|
|
|
|
|
|
let res = await axiosClient.request(options);
|
|
|
|
let res;
|
|
|
|
|
|
|
|
if (this.auth_method === "ntlm") {
|
|
|
|
|
|
|
|
options.httpsAgent.keepAlive = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = await httpNtlm(options, {
|
|
|
|
|
|
|
|
username: this.basic_auth_user,
|
|
|
|
|
|
|
|
password: this.basic_auth_pass,
|
|
|
|
|
|
|
|
domain: this.authDomain,
|
|
|
|
|
|
|
|
workstation: this.authWorkstation,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
res = await axiosClient.request(options);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bean.msg = `${res.status} - ${res.statusText}`;
|
|
|
|
bean.msg = `${res.status} - ${res.statusText}`;
|
|
|
|
bean.ping = dayjs().valueOf() - startTime;
|
|
|
|
bean.ping = dayjs().valueOf() - startTime;
|
|
|
|
|
|
|
|
|
|
|
|