mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 08:44:04 +00:00
removed some monitor drift in terms of imports and documentation
This commit is contained in:
parent
10ebdcacaa
commit
d74facded6
6 changed files with 10 additions and 47 deletions
|
@ -4,8 +4,7 @@ const dayjs = require("dayjs");
|
||||||
const { dnsResolve } = require("../util-server");
|
const { dnsResolve } = require("../util-server");
|
||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
|
|
||||||
class DnsMonitorType extends MonitorType {
|
export class DnsMonitorType extends MonitorType {
|
||||||
|
|
||||||
name = "dns";
|
name = "dns";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +49,3 @@ class DnsMonitorType extends MonitorType {
|
||||||
heartbeat.status = UP;
|
heartbeat.status = UP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
DnsMonitorType,
|
|
||||||
};
|
|
||||||
|
|
|
@ -3,8 +3,7 @@ const { UP } = require("../../src/util");
|
||||||
const { MongoClient } = require("mongodb");
|
const { MongoClient } = require("mongodb");
|
||||||
const jsonata = require("jsonata");
|
const jsonata = require("jsonata");
|
||||||
|
|
||||||
class MongodbMonitorType extends MonitorType {
|
export class MongodbMonitorType extends MonitorType {
|
||||||
|
|
||||||
name = "mongodb";
|
name = "mongodb";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,8 +48,7 @@ class MongodbMonitorType extends MonitorType {
|
||||||
* Connect to and run MongoDB command on a MongoDB database
|
* Connect to and run MongoDB command on a MongoDB database
|
||||||
* @param {string} connectionString The database connection string
|
* @param {string} connectionString The database connection string
|
||||||
* @param {object} command MongoDB command to run on the database
|
* @param {object} command MongoDB command to run on the database
|
||||||
* @returns {Promise<(string[] | object[] | object)>} Response from
|
* @returns {Promise<(string[] | object[] | object)>} Response from server
|
||||||
* server
|
|
||||||
*/
|
*/
|
||||||
async runMongodbCommand(connectionString, command) {
|
async runMongodbCommand(connectionString, command) {
|
||||||
let client = await MongoClient.connect(connectionString);
|
let client = await MongoClient.connect(connectionString);
|
||||||
|
@ -59,7 +57,3 @@ class MongodbMonitorType extends MonitorType {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
MongodbMonitorType,
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class MonitorType {
|
export class MonitorType {
|
||||||
name = undefined;
|
name = undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,9 +11,4 @@ class MonitorType {
|
||||||
async check(monitor, heartbeat, server) {
|
async check(monitor, heartbeat, server) {
|
||||||
throw new Error("You need to override check()");
|
throw new Error("You need to override check()");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
MonitorType,
|
|
||||||
};
|
|
||||||
|
|
|
@ -3,16 +3,11 @@ const { log, UP } = require("../../src/util");
|
||||||
const mqtt = require("mqtt");
|
const mqtt = require("mqtt");
|
||||||
const jsonata = require("jsonata");
|
const jsonata = require("jsonata");
|
||||||
|
|
||||||
class MqttMonitorType extends MonitorType {
|
export class MqttMonitorType extends MonitorType {
|
||||||
|
|
||||||
name = "mqtt";
|
name = "mqtt";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the monitoring check on the MQTT monitor
|
* @inheritdoc
|
||||||
* @param {Monitor} monitor Monitor to check
|
|
||||||
* @param {Heartbeat} heartbeat Monitor heartbeat to update
|
|
||||||
* @param {UptimeKumaServer} server Uptime Kuma server
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
async check(monitor, heartbeat, server) {
|
async check(monitor, heartbeat, server) {
|
||||||
const receivedMessage = await this.mqttAsync(monitor.hostname, monitor.mqttTopic, {
|
const receivedMessage = await this.mqttAsync(monitor.hostname, monitor.mqttTopic, {
|
||||||
|
|
|
@ -228,8 +228,7 @@ async function testRemoteBrowser(remoteBrowserURL) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class RealBrowserMonitorType extends MonitorType {
|
export class RealBrowserMonitorType extends MonitorType {
|
||||||
|
|
||||||
name = "real-browser";
|
name = "real-browser";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,7 +265,6 @@ class RealBrowserMonitorType extends MonitorType {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
RealBrowserMonitorType,
|
|
||||||
testChrome,
|
testChrome,
|
||||||
resetChrome,
|
resetChrome,
|
||||||
testRemoteBrowser,
|
testRemoteBrowser,
|
||||||
|
|
|
@ -2,23 +2,13 @@ const { MonitorType } = require("./monitor-type");
|
||||||
const { UP } = require("../../src/util");
|
const { UP } = require("../../src/util");
|
||||||
const childProcessAsync = require("promisify-child-process");
|
const childProcessAsync = require("promisify-child-process");
|
||||||
|
|
||||||
/**
|
export class TailscalePing extends MonitorType {
|
||||||
* A TailscalePing class extends the MonitorType.
|
|
||||||
* It runs Tailscale ping to monitor the status of a specific node.
|
|
||||||
*/
|
|
||||||
class TailscalePing extends MonitorType {
|
|
||||||
|
|
||||||
name = "tailscale-ping";
|
name = "tailscale-ping";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the ping status of the URL associated with the monitor.
|
* @inheritdoc
|
||||||
* It then parses the Tailscale ping command output to update the heatrbeat.
|
|
||||||
* @param {object} monitor The monitor object associated with the check.
|
|
||||||
* @param {object} heartbeat The heartbeat object to update.
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
* @throws Error if checking Tailscale ping encounters any error
|
|
||||||
*/
|
*/
|
||||||
async check(monitor, heartbeat) {
|
async check(monitor, heartbeat, _server) {
|
||||||
try {
|
try {
|
||||||
let tailscaleOutput = await this.runTailscalePing(monitor.hostname, monitor.interval);
|
let tailscaleOutput = await this.runTailscalePing(monitor.hostname, monitor.interval);
|
||||||
this.parseTailscaleOutput(tailscaleOutput, heartbeat);
|
this.parseTailscaleOutput(tailscaleOutput, heartbeat);
|
||||||
|
@ -81,7 +71,3 @@ class TailscalePing extends MonitorType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
TailscalePing,
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in a new issue