MikeBishop / MMM-uptimekuma

MagicMirror² Module to see uptime data from Uptime Kuma
MIT License
0 stars 1 forks source link

no Status @ /api/status-page/default #2

Open rickde92 opened 4 months ago

rickde92 commented 4 months ago

in my "/api/status-page/default" is on the list so Status item. image

sdetweil commented 4 months ago

there is a bug in the node helper

config.baseUrl + 'api/status-page/' 

the base url doesn't have a trailing '/'

so this creates a damaged url

this is what I changed

        const statusPagePromise = axios.get(config.baseUrl + (config.baseUrl.endsWith('/') ? '' : '/') + 'api/status-page/' + config.statusPage);
        const heartbeatPromise = axios.get(config.baseUrl + (config.baseUrl.endsWith('/') ? '' : '/') + 'api/status-page/heartbeat/' + config.statusPage);

or add a / to the end of the baseurl property in config

rickde92 commented 4 months ago

config

        {//MMM-uptimekuma- top_left
            module: 'MMM-uptimekuma',
                position: "top_left",
            header: "Uptime-Kuma",
            config: {
                baseUrl: "http://10.0.12.13:3001/",
            }
        },

error. 0|MagicMir | at /home/admin/MagicMirror/modules/MMM-uptimekuma/node_helper.js:61:45 0|MagicMir | at Array.map () 0|MagicMir | at Class.getData (/home/admin/MagicMirror/modules/MMM-uptimekuma/node_helper.js:59:20) 0|MagicMir | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 0|MagicMir | at async Class.socketNotificationReceived (/home/admin/MagicMirror/modules/MMM-uptimekuma/node_helper.js:29:13) 0|MagicMir | [26.02.2024 16:02.21.992] [ERROR] (node:1280) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 46) 0|MagicMir | [26.02.2024 16:03.21.297] [ERROR] (node:1280) UnhandledPromiseRejectionWarning: TypeError: Cannot read properties of undefined (reading 'status') 0|MagicMir | at /home/admin/MagicMirror/modules/MMM-uptimekuma/node_helper.js:63:68 0|MagicMir | at Array.map () 0|MagicMir | at /home/admin/MagicMirror/modules/MMM-uptimekuma/node_helper.js:61:45 0|MagicMir | at Array.map () 0|MagicMir | at Class.getData (/home/admin/MagicMirror/modules/MMM-uptimekuma/node_helper.js:59:20) 0|MagicMir | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 0|MagicMir | at async Class.socketNotificationReceived (/home/admin/MagicMirror/modules/MMM-uptimekuma/node_helper.js:29:13) 0|MagicMir | [26.02.2024 16:03.21.298] [ERROR] (node:1280) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 50)

`

rickde92 commented 4 months ago

There is no longer a status query in the "http://10.0.12.13:3001/api/status-page/default" whether the server is online or not.

sdetweil commented 4 months ago

@rickde92 I get one just fine after I created the default status page and added a monitor to it and fixed the url

{"config":{"slug":"default","title":"default","description":null,"icon":"/icon.svg","theme":"auto","published":true,"showTags":false,"customCSS":"body {\n  \n}\n","footerText":null,"showPoweredBy":true,"googleAnalyticsId":null,"showCertificateExpiry":false},"incident":null,"publicGroupList":[{"id":1,"name":"Services","weight":1,"monitorList":[{"id":1,"name":"cnsearch","sendUrl":1,"type":"http","url":"https://bbbbbbbbb"}]}],"maintenanceList":[]}
sdetweil commented 4 months ago

and my heartbeat data from

http://mac-mini:3001/api/status-page/heartbeat/

is

{"heartbeatList":{},"uptimeList":{}}

I don't have any heartbeat data in my monitor on the status page.. don't see how to get any

this is looking for the status from the heartbeat data

properties of undefined (reading 'status')
0|MagicMir | at /home/admin/MagicMirror/modules/MMM-uptimekuma/node_helper.js:63:68
MikeBishop commented 4 months ago

and my heartbeat data from

http://mac-mini:3001/api/status-page/heartbeat/

is

{"heartbeatList":{},"uptimeList":{}}

Because you're not specifying the slug for the status page. Check at http://mac-mini:3001/api/status-page/heartbeat/default and hopefully you'll see status objects.

@rickde92, I'm afraid I'm not clear on the issue you're seeing. Are you able to load the status page itself?

rickde92 commented 4 months ago

@MikeBishop The Status page works great. image

sdetweil commented 4 months ago

yes, I see the status objects... and the last is used to up/down determination

MikeBishop commented 4 months ago

@rickde92, if the status page loads, presumably that means the API endpoints are returning valid data. What is happening in the node_helper when it tries to fetch the data?

rickde92 commented 4 months ago

@MikeBishop How can I verify that? Sry, I'm new to MagicMirror :)

sdetweil commented 4 months ago

@rickde92 the module would have to provide debug output. I added some to see the heartbeat list

add a debug property pass it to the node_helper and conditionally console log important info