pull/5362/head
Eddie Fiorentine 5 days ago
parent e5477fba0d
commit b40dbf7db7

@ -1,5 +1,5 @@
const { MonitorType } = require("./monitor-type"); const { MonitorType } = require("./monitor-type");
const { UP, log } = require("../../src/util"); const { UP } = require("../../src/util");
const { exec } = require("promisify-child-process"); const { exec } = require("promisify-child-process");
class SIPMonitorType extends MonitorType { class SIPMonitorType extends MonitorType {
@ -10,7 +10,7 @@ class SIPMonitorType extends MonitorType {
* Run the monitoring check on the given monitor * Run the monitoring check on the given monitor
* @param {Monitor} monitor Monitor to check * @param {Monitor} monitor Monitor to check
* @param {Heartbeat} heartbeat Monitor heartbeat to update * @param {Heartbeat} heartbeat Monitor heartbeat to update
* @param {UptimeKumaServer} server Uptime Kuma server * @param {UptimeKumaServer} _server Uptime Kuma server
* @returns {Promise<void>} * @returns {Promise<void>}
* @throws Will throw an error if the command execution encounters any error. * @throws Will throw an error if the command execution encounters any error.
*/ */
@ -32,7 +32,7 @@ class SIPMonitorType extends MonitorType {
* @throws Will throw an error if the command execution encounters any error. * @throws Will throw an error if the command execution encounters any error.
*/ */
async runSipSak(hostname, port, timeout) { async runSipSak(hostname, port, timeout) {
const { stdout, stderr } = await exec(`sipsak -s sip:${hostname}:${port} --from sip:sipsak@${hostname} -v`,{timeout:timeout}); const { stdout, stderr } = await exec(`sipsak -s sip:${hostname}:${port} --from sip:sipsak@${hostname} -v`, { timeout: timeout });
if (!stdout && stderr && stderr.toString()) { if (!stdout && stderr && stderr.toString()) {
throw new Error(`Error in output: ${stderr.toString()}`); throw new Error(`Error in output: ${stderr.toString()}`);
} }
@ -44,22 +44,21 @@ class SIPMonitorType extends MonitorType {
} }
/** /**
* * @param {string} res response to be parsed
* @param {string} res * @param {object} heartbeat heartbeat object to update
* @param {object} heartbeat * @returns {void} returns nothing
* @returns {void}
*/ */
parseSipsakResponse(res, heartbeat){ parseSipsakResponse(res, heartbeat) {
let lines = res.split("\n"); let lines = res.split("\n");
for (let line of lines){ for (let line of lines) {
if (line.includes("200 OK")){ if (line.includes("200 OK")) {
heartbeat.status = UP; heartbeat.status = UP;
heartbeat.msg = line; heartbeat.msg = line;
break; break;
} }
} }
} }
} }
module.exports = { module.exports = {
SIPMonitorType, SIPMonitorType,

@ -93,7 +93,7 @@
</option> </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>
</optgroup> </optgroup>
</select> </select>
<i18n-t v-if="monitor.type === 'rabbitmq'" keypath="rabbitmqHelpText" tag="div" class="form-text"> <i18n-t v-if="monitor.type === 'rabbitmq'" keypath="rabbitmqHelpText" tag="div" class="form-text">

Loading…
Cancel
Save