Compare commits

...

10 commits

Author SHA1 Message Date
Eddie Fiorentine
ed43bad8a0
Merge 4ab6db3c5d into 03beef8006 2025-01-22 18:03:54 +00:00
DayShift
03beef8006
BugFix:Regular Expression in parseDuration Function (#5563)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / check-linters (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
validate / json-yaml-validate (push) Has been cancelled
validate / validate (push) Has been cancelled
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20, ARM64) (push) Has been cancelled
Auto Test / auto-test (20, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20, windows-latest) (push) Has been cancelled
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2025-01-22 19:03:38 +01:00
Eddie Fiorentine
4ab6db3c5d
Merge branch 'master' into master 2025-01-02 17:06:23 -05:00
Eddie Fiorentine
8985c5e96a
Merge branch 'master' into master 2024-12-02 18:35:31 -05:00
Eddie Fiorentine
30cfa8a435
Merge branch 'master' into master 2024-11-26 18:54:41 -05:00
Eddie Fiorentine
b40dbf7db7 lint fixes 2024-11-19 20:13:06 -05:00
Eddie Fiorentine
e5477fba0d add newline 2024-11-19 19:55:18 -05:00
Eddie Fiorentine
5cff54e52d fix: cleanup JSdocs 2024-11-19 19:52:37 -05:00
Eddie Fiorentine
783e228406 fix: SIP Options monitor would always write an error to log because sipsak by default writes DEBUG to stderr 2024-11-19 19:42:45 -05:00
Eddie Fiorentine
c40f8e7ba5 Feature: SIP options ping Monitor Type using sipsak binary 2024-11-19 19:40:23 -05:00
5 changed files with 81 additions and 5 deletions

View file

@ -485,7 +485,7 @@ function ApiCache() {
} }
if (typeof duration === "string") { if (typeof duration === "string") {
let split = duration.match(/^([\d\.,]+)\s?(\w+)$/); let split = duration.match(/^([\d\.,]+)\s?([a-zA-Z]+)$/);
if (split.length === 3) { if (split.length === 3) {
let len = parseFloat(split[1]); let len = parseFloat(split[1]);

View file

@ -0,0 +1,65 @@
const { MonitorType } = require("./monitor-type");
const { UP } = require("../../src/util");
const { exec } = require("promisify-child-process");
class SIPMonitorType extends MonitorType {
name = "sip-options";
supportsConditions = false;
/**
* Run the monitoring check on the given monitor
* @param {Monitor} monitor Monitor to check
* @param {Heartbeat} heartbeat Monitor heartbeat to update
* @param {UptimeKumaServer} _server Uptime Kuma server
* @returns {Promise<void>}
* @throws Will throw an error if the command execution encounters any error.
*/
async check(monitor, heartbeat, _server) {
try {
let sipsakOutput = await this.runSipSak(monitor.hostname, monitor.port, 3000);
this.parseSipsakResponse(sipsakOutput, heartbeat);
} catch (err) {
throw new Error(`Error checking Sipsak: ${err} ${err.message} ${err.stack}`);
}
}
/**
* Runs Sipsak options ping
* @param {string} hostname SIP server address to send options.
* @param {number} port SIP server port
* @param {number} timeout timeout of options reply
* @returns {Promise<string>} A Promise that resolves to the output of the Sipsak options ping
* @throws Will throw an error if the command execution encounters any error.
*/
async runSipSak(hostname, port, timeout) {
const { stdout, stderr } = await exec(`sipsak -s sip:${hostname}:${port} --from sip:sipsak@${hostname} -v`, { timeout: timeout });
if (!stdout && stderr && stderr.toString()) {
throw new Error(`Error in output: ${stderr.toString()}`);
}
if (stdout && stdout.toString()) {
return stdout.toString();
} else {
throw new Error("No output from sipsak");
}
}
/**
* @param {string} res response to be parsed
* @param {object} heartbeat heartbeat object to update
* @returns {void} returns nothing
*/
parseSipsakResponse(res, heartbeat) {
let lines = res.split("\n");
for (let line of lines) {
if (line.includes("200 OK")) {
heartbeat.status = UP;
heartbeat.msg = line;
break;
}
}
}
}
module.exports = {
SIPMonitorType,
};

View file

@ -116,6 +116,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["sip-options"] = new SIPMonitorType();
// Allow all CORS origins (polling) in development // Allow all CORS origins (polling) in development
let cors = undefined; let cors = undefined;
@ -554,4 +555,6 @@ const { MqttMonitorType } = require("./monitor-types/mqtt");
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 { SIPMonitorType } = require("./monitor-types/sip-options");
const Monitor = require("./model/monitor"); const Monitor = require("./model/monitor");

View file

@ -405,6 +405,7 @@
"socket": "Socket", "socket": "Socket",
"tcp": "TCP / HTTP", "tcp": "TCP / HTTP",
"tailscalePingWarning": "In order to use the Tailscale Ping monitor, you need to install Uptime Kuma without Docker and also install Tailscale client on your server.", "tailscalePingWarning": "In order to use the Tailscale Ping monitor, you need to install Uptime Kuma without Docker and also install Tailscale client on your server.",
"sipsakPingWarning": "In order to use the SIP Options Ping monitor, you need to install Uptime Kuma without Docker and also install Sipsak client on your server.",
"Docker Container": "Docker Container", "Docker Container": "Docker Container",
"Container Name / ID": "Container Name / ID", "Container Name / ID": "Container Name / ID",
"Docker Host": "Docker Host", "Docker Host": "Docker Host",

View file

@ -88,6 +88,9 @@
<option value="redis"> <option value="redis">
Redis Redis
</option> </option>
<option v-if="!$root.info.isContainer" value="sip-options">
SIP Options Ping
</option>
<option v-if="!$root.info.isContainer" value="tailscale-ping"> <option v-if="!$root.info.isContainer" value="tailscale-ping">
Tailscale Ping Tailscale Ping
</option> </option>
@ -106,6 +109,10 @@
{{ $t("tailscalePingWarning") }} {{ $t("tailscalePingWarning") }}
</div> </div>
<div v-if="monitor.type === 'sip-options'" class="alert alert-warning" role="alert">
{{ $t("sipsakPingWarning") }}
</div>
<!-- Friendly Name --> <!-- Friendly Name -->
<div class="my-3"> <div class="my-3">
<label for="name" class="form-label">{{ $t("Friendly Name") }}</label> <label for="name" class="form-label">{{ $t("Friendly Name") }}</label>
@ -281,8 +288,8 @@
</template> </template>
<!-- Hostname --> <!-- Hostname -->
<!-- TCP Port / Ping / DNS / Steam / MQTT / Radius / Tailscale Ping / SNMP only --> <!-- TCP Port / Ping / DNS / Steam / MQTT / Radius / Tailscale Ping / SNMP only / SIP Options -->
<div v-if="monitor.type === 'port' || monitor.type === 'ping' || monitor.type === 'dns' || monitor.type === 'steam' || monitor.type === 'gamedig' || monitor.type === 'mqtt' || monitor.type === 'radius' || monitor.type === 'tailscale-ping' || monitor.type === 'snmp'" class="my-3"> <div v-if="monitor.type === 'port' || monitor.type === 'ping' || monitor.type === 'dns' || monitor.type === 'steam' || monitor.type === 'gamedig' || monitor.type === 'mqtt' || monitor.type === 'radius' || monitor.type === 'tailscale-ping' || monitor.type === 'snmp' || monitor.type ==='sip-options'" class="my-3">
<label for="hostname" class="form-label">{{ $t("Hostname") }}</label> <label for="hostname" class="form-label">{{ $t("Hostname") }}</label>
<input <input
id="hostname" id="hostname"
@ -296,8 +303,8 @@
</div> </div>
<!-- Port --> <!-- Port -->
<!-- For TCP Port / Steam / MQTT / Radius Type / SNMP --> <!-- For TCP Port / Steam / MQTT / Radius Type / SNMP / SIP Options -->
<div v-if="monitor.type === 'port' || monitor.type === 'steam' || monitor.type === 'gamedig' || monitor.type === 'mqtt' || monitor.type === 'radius' || monitor.type === 'snmp'" class="my-3"> <div v-if="monitor.type === 'port' || monitor.type === 'steam' || monitor.type === 'gamedig' || monitor.type === 'mqtt' || monitor.type === 'radius' || monitor.type === 'snmp' || monitor.type === 'sip-options'" class="my-3">
<label for="port" class="form-label">{{ $t("Port") }}</label> <label for="port" class="form-label">{{ $t("Port") }}</label>
<input id="port" v-model="monitor.port" type="number" class="form-control" required min="0" max="65535" step="1"> <input id="port" v-model="monitor.port" type="number" class="form-control" required min="0" max="65535" step="1">
</div> </div>