mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
Compare commits
4 commits
7961ebb43b
...
6380df93c0
Author | SHA1 | Date | |
---|---|---|---|
|
6380df93c0 | ||
|
444661e77c | ||
|
73ee62810d | ||
|
bf32550f86 |
2 changed files with 14 additions and 7 deletions
|
@ -13,16 +13,20 @@ 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 (const baseUrl of baseUrls) {
|
for (let 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 = {
|
||||||
url: new URL("/api/health/checks/alarms", baseUrl).href,
|
// Do not start with slash, it will strip the trailing slash from baseUrl
|
||||||
|
url: new URL("api/health/checks/alarms/", baseUrl).href,
|
||||||
method: "get",
|
method: "get",
|
||||||
timeout: monitor.timeout * 1000,
|
timeout: monitor.timeout * 1000,
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -31,7 +35,8 @@ 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),
|
||||||
validateStatus: () => true,
|
// Capture reason for 503 status
|
||||||
|
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);
|
||||||
|
@ -40,6 +45,8 @@ 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