Merge branch 'master' into CommanderStorm-patch-2
This commit is contained in:
commit
d7db40ba52
70
server/monitor-types/sip-options.js
Normal file
70
server/monitor-types/sip-options.js
Normal file
@ -0,0 +1,70 @@
|
||||
const { MonitorType } = require("./monitor-type");
|
||||
const { UP } = require("../../src/util");
|
||||
const { execFile } = 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) {
|
||||
let sipsakOutput = await this.runSipSak(monitor.hostname, monitor.port, 3000);
|
||||
this.parseSipsakResponse(sipsakOutput, heartbeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 execFile(
|
||||
"sipsak",
|
||||
[
|
||||
"-s", `sip:${hostname}:${port}`,
|
||||
"--from", `sip:sipsak@${hostname}`,
|
||||
"-v",
|
||||
],
|
||||
{ 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,
|
||||
};
|
||||
@ -121,6 +121,7 @@ class UptimeKumaServer {
|
||||
UptimeKumaServer.monitorTypeList["grpc-keyword"] = new GrpcKeywordMonitorType();
|
||||
UptimeKumaServer.monitorTypeList["mongodb"] = new MongodbMonitorType();
|
||||
UptimeKumaServer.monitorTypeList["rabbitmq"] = new RabbitMqMonitorType();
|
||||
UptimeKumaServer.monitorTypeList["sip-options"] = new SIPMonitorType();
|
||||
UptimeKumaServer.monitorTypeList["gamedig"] = new GameDigMonitorType();
|
||||
UptimeKumaServer.monitorTypeList["port"] = new TCPMonitorType();
|
||||
UptimeKumaServer.monitorTypeList["manual"] = new ManualMonitorType();
|
||||
@ -572,6 +573,7 @@ const { SNMPMonitorType } = require("./monitor-types/snmp");
|
||||
const { GrpcKeywordMonitorType } = require("./monitor-types/grpc");
|
||||
const { MongodbMonitorType } = require("./monitor-types/mongodb");
|
||||
const { RabbitMqMonitorType } = require("./monitor-types/rabbitmq");
|
||||
const { SIPMonitorType } = require("./monitor-types/sip-options");
|
||||
const { GameDigMonitorType } = require("./monitor-types/gamedig");
|
||||
const { TCPMonitorType } = require("./monitor-types/tcp.js");
|
||||
const { ManualMonitorType } = require("./monitor-types/manual");
|
||||
|
||||
@ -431,6 +431,7 @@
|
||||
"socket": "Socket",
|
||||
"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.",
|
||||
"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",
|
||||
"Container Name / ID": "Container Name / ID",
|
||||
"Docker Host": "Docker Host",
|
||||
|
||||
@ -102,6 +102,9 @@
|
||||
<option value="redis">
|
||||
Redis
|
||||
</option>
|
||||
<option v-if="!$root.info.isContainer" value="sip-options">
|
||||
SIP Options Ping
|
||||
</option>
|
||||
<option v-if="!$root.info.isContainer" value="tailscale-ping">
|
||||
Tailscale Ping
|
||||
</option>
|
||||
@ -120,6 +123,10 @@
|
||||
{{ $t("tailscalePingWarning") }}
|
||||
</div>
|
||||
|
||||
<div v-if="monitor.type === 'sip-options'" class="alert alert-warning" role="alert">
|
||||
{{ $t("sipsakPingWarning") }}
|
||||
</div>
|
||||
|
||||
<!-- Friendly Name -->
|
||||
<div class="my-3">
|
||||
<label for="name" class="form-label">{{ $t("Friendly Name") }}</label>
|
||||
@ -318,8 +325,8 @@
|
||||
</template>
|
||||
|
||||
<!-- Hostname -->
|
||||
<!-- TCP Port / Ping / DNS / Steam / MQTT / Radius / Tailscale Ping / SNMP / SMTP only -->
|
||||
<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 === 'smtp' || monitor.type === 'snmp'" class="my-3">
|
||||
<!-- TCP Port / Ping / DNS / Steam / MQTT / Radius / Tailscale Ping / SNMP / SMTP / SIP Options only -->
|
||||
<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 === 'smtp' || monitor.type === 'snmp' || monitor.type ==='sip-options'" class="my-3">
|
||||
<label for="hostname" class="form-label">{{ $t("Hostname") }}</label>
|
||||
<input
|
||||
id="hostname"
|
||||
@ -339,8 +346,8 @@
|
||||
</div>
|
||||
|
||||
<!-- Port -->
|
||||
<!-- For TCP Port / Steam / MQTT / Radius Type / SNMP -->
|
||||
<div v-if="monitor.type === 'port' || monitor.type === 'steam' || monitor.type === 'gamedig' || monitor.type === 'mqtt' || monitor.type === 'radius' || monitor.type === 'smtp' || monitor.type === 'snmp'" class="my-3">
|
||||
<!-- 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 === 'smtp' || monitor.type === 'snmp' || monitor.type === 'sip-options'" class="my-3">
|
||||
<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">
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user