Repository: louislam/uptime-kuma
File: server/monitor-types/rabbitmq.js (JavaScript)

Code before:
    /**
     * @inheritdoc
     */
    async check(monitor, heartbeat, server) {
        let baseUrls = [];
        try {
            baseUrls = JSON.parse(monitor.rabbitmqNodes);
        } catch (error) {
            throw new Error("Invalid RabbitMQ Nodes");
        }

        if (baseUrls.length === 0) {
            throw new Error("No RabbitMQ nodes configured");
        }

        const errors = [];

        for (let i = 0; i < baseUrls.length; i++) {
            const baseUrl = baseUrls[i];
            const nodeIndex = i + 1;

            try {
                await this.checkSingleNode(monitor, baseUrl, `${nodeIndex}/${baseUrls.length}`);
                // If checkSingleNode succeeds (doesn't throw), set heartbeat to UP
                heartbeat.status = UP;
                heartbeat.msg = baseUrls.length == 1 ? "Node is reachable and there are no alerts in the cluster" : `One of the ${baseUrls.length} nodes is reachable and there are no alerts in the cluster`;
                return;
            } catch (error) {
                log.warn(this.name, `Node ${nodeIndex}: ${error.message}`);
                errors.push(`Node ${nodeIndex}: ${error.message}`);
            }
        }

        // If we reach here, all nodes failed
        throw new Error(`All ${errors.length} nodes failed because ${errors.join("; ")}`);
    }

    /**
     * Check a single RabbitMQ node
     * @param {object} monitor Monitor configuration
     * @param {string} baseUrl Base URL of the RabbitMQ node
     * @param {string} nodeInfo Node index info for logging (e.g., "1/3")
     * @returns {Promise<void>}
     * @throws {Error} If the node check fails
     */
    async checkSingleNode(monitor, baseUrl, nodeInfo) {
        // Without a trailing slash, path in baseUrl will be removed. https://example.com/api -> https://example.com
        let normalizedUrl = baseUrl;
        if (!normalizedUrl.endsWith("/")) {
            normalizedUrl += "/";
        }

Review comment (suggestion):
```suggestion
                heartbeat.msg = baseUrls.length === 1 ? "Node is reachable and there are no alerts in the cluster" : `One of the ${baseUrls.length} nodes is reachable and there are no alerts in the cluster`;
```

Code after:
    /**
     * @inheritdoc
     */
    async check(monitor, heartbeat, server) {
        let baseUrls = [];
        try {
            baseUrls = JSON.parse(monitor.rabbitmqNodes);
        } catch (error) {
            throw new Error("Invalid RabbitMQ Nodes");
        }

        if (baseUrls.length === 0) {
            throw new Error("No RabbitMQ nodes configured");
        }

        const errors = [];

        for (let i = 0; i < baseUrls.length; i++) {
            const baseUrl = baseUrls[i];
            const nodeIndex = i + 1;

            try {
                await this.checkSingleNode(monitor, baseUrl, `${nodeIndex}/${baseUrls.length}`);
                // If checkSingleNode succeeds (doesn't throw), set heartbeat to UP
                heartbeat.status = UP;
                heartbeat.msg = baseUrls.length === 1 ? "Node is reachable and there are no alerts in the cluster" : `One of the ${baseUrls.length} nodes is reachable and there are no alerts in the cluster`;
                return;
            } catch (error) {
                log.warn(this.name, `Node ${nodeIndex}: ${error.message}`);
                errors.push(`Node ${nodeIndex}: ${error.message}`);
            }
        }

        // If we reach here, all nodes failed
        throw new Error(`All ${errors.length} nodes failed because ${errors.join("; ")}`);
    }

    /**
     * Check a single RabbitMQ node
     * @param {object} monitor Monitor configuration
     * @param {string} baseUrl Base URL of the RabbitMQ node
     * @param {string} nodeInfo Node index info for logging (e.g., "1/3")
     * @returns {Promise<void>}
     * @throws {Error} If the node check fails
     */
    async checkSingleNode(monitor, baseUrl, nodeInfo) {
        // Without a trailing slash, path in baseUrl will be removed. https://example.com/api -> https://example.com
        let normalizedUrl = baseUrl;
        if (!normalizedUrl.endsWith("/")) {
            normalizedUrl += "/";
        }