mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-30 10:14:03 +00:00
Compare commits
1 commit
ea8f209cab
...
15a8abb9f7
Author | SHA1 | Date | |
---|---|---|---|
|
15a8abb9f7 |
2 changed files with 7 additions and 14 deletions
|
@ -13,20 +13,16 @@ class RabbitMqMonitorType extends MonitorType {
|
||||||
let baseUrls = [];
|
let baseUrls = [];
|
||||||
try {
|
try {
|
||||||
baseUrls = JSON.parse(monitor.rabbitmqNodes);
|
baseUrls = JSON.parse(monitor.rabbitmqNodes);
|
||||||
} catch (error) {
|
}
|
||||||
|
catch (error) {
|
||||||
throw new Error("Invalid RabbitMQ Nodes");
|
throw new Error("Invalid RabbitMQ Nodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
heartbeat.status = DOWN;
|
heartbeat.status = DOWN;
|
||||||
for (let baseUrl of baseUrls) {
|
for (const baseUrl of baseUrls) {
|
||||||
try {
|
try {
|
||||||
// Without a trailing slash, path in baseUrl will be removed. https://example.com/api -> https://example.com
|
|
||||||
if ( !baseUrl.endsWith("/") ) {
|
|
||||||
baseUrl += "/";
|
|
||||||
}
|
|
||||||
const options = {
|
const options = {
|
||||||
// Do not start with slash, it will strip the trailing slash from baseUrl
|
url: new URL("/api/health/checks/alarms", baseUrl).href,
|
||||||
url: new URL("api/health/checks/alarms/", baseUrl).href,
|
|
||||||
method: "get",
|
method: "get",
|
||||||
timeout: monitor.timeout * 1000,
|
timeout: monitor.timeout * 1000,
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -35,8 +31,7 @@ class RabbitMqMonitorType extends MonitorType {
|
||||||
},
|
},
|
||||||
// Use axios signal to handle connection timeouts https://stackoverflow.com/a/74739938
|
// Use axios signal to handle connection timeouts https://stackoverflow.com/a/74739938
|
||||||
signal: axiosAbortSignal((monitor.timeout + 10) * 1000),
|
signal: axiosAbortSignal((monitor.timeout + 10) * 1000),
|
||||||
// Capture reason for 503 status
|
validateStatus: () => true,
|
||||||
validateStatus: (status) => status === 200 || status === 503,
|
|
||||||
};
|
};
|
||||||
log.debug("monitor", `[${monitor.name}] Axios Request: ${JSON.stringify(options)}`);
|
log.debug("monitor", `[${monitor.name}] Axios Request: ${JSON.stringify(options)}`);
|
||||||
const res = await axios.request(options);
|
const res = await axios.request(options);
|
||||||
|
@ -45,8 +40,6 @@ class RabbitMqMonitorType extends MonitorType {
|
||||||
heartbeat.status = UP;
|
heartbeat.status = UP;
|
||||||
heartbeat.msg = "OK";
|
heartbeat.msg = "OK";
|
||||||
break;
|
break;
|
||||||
} else if (res.status === 503) {
|
|
||||||
heartbeat.msg = res.data.reason;
|
|
||||||
} else {
|
} else {
|
||||||
heartbeat.msg = `${res.status} - ${res.statusText}`;
|
heartbeat.msg = `${res.status} - ${res.statusText}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const { describe, test } = require("node:test");
|
const { describe, test } = require("node:test");
|
||||||
const assert = require("node:assert");
|
const assert = require("node:assert");
|
||||||
const { RabbitMQContainer } = require("@testcontainers/rabbitmq");
|
const { RabbitMQContainer } = require("@testcontainers/rabbitmq");
|
||||||
const { RabbitMqMonitorType } = require("../../server/monitor-types/rabbitmq");
|
const { RabbitMqMonitorType } = require("../../../server/monitor-types/rabbitmq");
|
||||||
const { UP, DOWN, PENDING } = require("../../src/util");
|
const { UP, DOWN, PENDING } = require("../../../src/util");
|
||||||
|
|
||||||
describe("RabbitMQ Single Node", {
|
describe("RabbitMQ Single Node", {
|
||||||
skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64"),
|
skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64"),
|
||||||
|
|
Loading…
Reference in a new issue