mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-10-04 14:39:19 +08:00
feat: Add a "manual" (static/fixed) monitor (#5897)
Co-authored-by: Maksim Kachynski <max.kachinsky@rocketdata.io> Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
36
server/monitor-types/manual.js
Normal file
36
server/monitor-types/manual.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const { MonitorType } = require("./monitor-type");
|
||||
const { UP, DOWN, PENDING } = require("../../src/util");
|
||||
|
||||
class ManualMonitorType extends MonitorType {
|
||||
name = "Manual";
|
||||
type = "manual";
|
||||
description = "A monitor that allows manual control of the status";
|
||||
supportsConditions = false;
|
||||
conditionVariables = [];
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async check(monitor, heartbeat) {
|
||||
if (monitor.manual_status !== null) {
|
||||
heartbeat.status = monitor.manual_status;
|
||||
switch (monitor.manual_status) {
|
||||
case UP:
|
||||
heartbeat.msg = "Up";
|
||||
break;
|
||||
case DOWN:
|
||||
heartbeat.msg = "Down";
|
||||
break;
|
||||
default:
|
||||
heartbeat.msg = "Pending";
|
||||
}
|
||||
} else {
|
||||
heartbeat.status = PENDING;
|
||||
heartbeat.msg = "Manual monitoring - No status set";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ManualMonitorType
|
||||
};
|
@@ -876,6 +876,7 @@ let needSetup = false;
|
||||
bean.rabbitmqUsername = monitor.rabbitmqUsername;
|
||||
bean.rabbitmqPassword = monitor.rabbitmqPassword;
|
||||
bean.conditions = JSON.stringify(monitor.conditions);
|
||||
bean.manual_status = monitor.manual_status;
|
||||
|
||||
// ping advanced options
|
||||
bean.ping_numeric = monitor.ping_numeric;
|
||||
|
@@ -118,6 +118,7 @@ class UptimeKumaServer {
|
||||
UptimeKumaServer.monitorTypeList["snmp"] = new SNMPMonitorType();
|
||||
UptimeKumaServer.monitorTypeList["mongodb"] = new MongodbMonitorType();
|
||||
UptimeKumaServer.monitorTypeList["rabbitmq"] = new RabbitMqMonitorType();
|
||||
UptimeKumaServer.monitorTypeList["manual"] = new ManualMonitorType();
|
||||
|
||||
// Allow all CORS origins (polling) in development
|
||||
let cors = undefined;
|
||||
@@ -558,4 +559,5 @@ const { GroupMonitorType } = require("./monitor-types/group");
|
||||
const { SNMPMonitorType } = require("./monitor-types/snmp");
|
||||
const { MongodbMonitorType } = require("./monitor-types/mongodb");
|
||||
const { RabbitMqMonitorType } = require("./monitor-types/rabbitmq");
|
||||
const { ManualMonitorType } = require("./monitor-types/manual");
|
||||
const Monitor = require("./model/monitor");
|
||||
|
Reference in New Issue
Block a user