mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-19 18:56:48 +02: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:
parent
f282422b22
commit
18cfa901ad
6 changed files with 68 additions and 1 deletions
12
db/knex_migrations/2025-06-11-0000-add-manual-monitor.js
Normal file
12
db/knex_migrations/2025-06-11-0000-add-manual-monitor.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("monitor", function (table) {
|
||||||
|
table.string("manual_status").defaultTo(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
return knex.schema.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("manual_status");
|
||||||
|
});
|
||||||
|
};
|
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.rabbitmqUsername = monitor.rabbitmqUsername;
|
||||||
bean.rabbitmqPassword = monitor.rabbitmqPassword;
|
bean.rabbitmqPassword = monitor.rabbitmqPassword;
|
||||||
bean.conditions = JSON.stringify(monitor.conditions);
|
bean.conditions = JSON.stringify(monitor.conditions);
|
||||||
|
bean.manual_status = monitor.manual_status;
|
||||||
|
|
||||||
// ping advanced options
|
// ping advanced options
|
||||||
bean.ping_numeric = monitor.ping_numeric;
|
bean.ping_numeric = monitor.ping_numeric;
|
||||||
|
|
|
@ -118,6 +118,7 @@ class UptimeKumaServer {
|
||||||
UptimeKumaServer.monitorTypeList["snmp"] = new SNMPMonitorType();
|
UptimeKumaServer.monitorTypeList["snmp"] = new SNMPMonitorType();
|
||||||
UptimeKumaServer.monitorTypeList["mongodb"] = new MongodbMonitorType();
|
UptimeKumaServer.monitorTypeList["mongodb"] = new MongodbMonitorType();
|
||||||
UptimeKumaServer.monitorTypeList["rabbitmq"] = new RabbitMqMonitorType();
|
UptimeKumaServer.monitorTypeList["rabbitmq"] = new RabbitMqMonitorType();
|
||||||
|
UptimeKumaServer.monitorTypeList["manual"] = new ManualMonitorType();
|
||||||
|
|
||||||
// Allow all CORS origins (polling) in development
|
// Allow all CORS origins (polling) in development
|
||||||
let cors = undefined;
|
let cors = undefined;
|
||||||
|
@ -558,4 +559,5 @@ const { GroupMonitorType } = require("./monitor-types/group");
|
||||||
const { SNMPMonitorType } = require("./monitor-types/snmp");
|
const { SNMPMonitorType } = require("./monitor-types/snmp");
|
||||||
const { MongodbMonitorType } = require("./monitor-types/mongodb");
|
const { MongodbMonitorType } = require("./monitor-types/mongodb");
|
||||||
const { RabbitMqMonitorType } = require("./monitor-types/rabbitmq");
|
const { RabbitMqMonitorType } = require("./monitor-types/rabbitmq");
|
||||||
|
const { ManualMonitorType } = require("./monitor-types/manual");
|
||||||
const Monitor = require("./model/monitor");
|
const Monitor = require("./model/monitor");
|
||||||
|
|
|
@ -1122,5 +1122,6 @@
|
||||||
"Add Another Tag": "Add Another Tag",
|
"Add Another Tag": "Add Another Tag",
|
||||||
"Staged Tags for Batch Add": "Staged Tags for Batch Add",
|
"Staged Tags for Batch Add": "Staged Tags for Batch Add",
|
||||||
"Clear Form": "Clear Form",
|
"Clear Form": "Clear Form",
|
||||||
"pause": "Pause"
|
"pause": "Pause",
|
||||||
|
"Manual": "Manual"
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,9 @@
|
||||||
<option value="push">
|
<option value="push">
|
||||||
Push
|
Push
|
||||||
</option>
|
</option>
|
||||||
|
<option value="manual">
|
||||||
|
{{ $t("Manual") }}
|
||||||
|
</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
|
||||||
<optgroup :label="$t('Specific Monitor Type')">
|
<optgroup :label="$t('Specific Monitor Type')">
|
||||||
|
@ -115,6 +118,18 @@
|
||||||
<input id="name" v-model="monitor.name" type="text" class="form-control" data-testid="friendly-name-input" :placeholder="defaultFriendlyName">
|
<input id="name" v-model="monitor.name" type="text" class="form-control" data-testid="friendly-name-input" :placeholder="defaultFriendlyName">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Manual Status switcher -->
|
||||||
|
<div v-if="monitor.type === 'manual'" class="mb-3">
|
||||||
|
<div class="btn-group w-100 mb-3">
|
||||||
|
<button class="btn btn-success" @click="monitor.manual_status = 1">
|
||||||
|
<i class="fas fa-check"></i> {{ $t("Up") }}
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-danger" @click="monitor.manual_status = 0">
|
||||||
|
<i class="fas fa-times"></i> {{ $t("Down") }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- URL -->
|
<!-- URL -->
|
||||||
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'real-browser' " class="my-3">
|
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'real-browser' " class="my-3">
|
||||||
<label for="url" class="form-label">{{ $t("URL") }}</label>
|
<label for="url" class="form-label">{{ $t("URL") }}</label>
|
||||||
|
|
Loading…
Add table
Reference in a new issue