get_monitor_status for all monitors #62

Open
opened 2023-12-13 10:03:15 +01:00 by kafisatz · 2 comments
kafisatz commented 2023-12-13 10:03:15 +01:00 (Migrated from github.com)

Great project, thanks!
I would like to get the status of all monitors (number of up, down, pending, ....)
I am not using any status pages right now.

The uptime kuma main webpage shows 'quick stats'. This is exactly what I want to get via API.

the snippet below takes about 15 seconds for 50 monitors, which is a bit inefficient.

    id = monitor["id"]
    st = api.get_monitor_status(id)

is there a better way to get all stati? I am only interested in the number of monitors that are up. I don't need the IDs.

Great project, thanks! I would like to get the status of all monitors (number of up, down, pending, ....) I am not using any status pages right now. The uptime kuma main webpage shows 'quick stats'. This is exactly what I want to get via API. the snippet below takes about 15 seconds for 50 monitors, which is a bit inefficient. ```for monitor in monitors: id = monitor["id"] st = api.get_monitor_status(id) ``` is there a better way to get all stati? I am only interested in the number of monitors that are up. I don't need the IDs.
Noschvie commented 2024-03-01 18:09:42 +01:00 (Migrated from github.com)

Hello
same here, want to get the "Quick Stats" overview too.

Maybe using the /metrics end point of uptime-kuma is a workaround.
Passing metrics to other platforms

Find all lines starting with "monitor_status" and have a look to the latest character of the line.
# HELP monitor_status Monitor Status (1 = UP, 0= DOWN, 2= PENDING, 3= MAINTENANCE)

Hello same here, want to get the "Quick Stats" overview too. Maybe using the /metrics end point of uptime-kuma is a workaround. [Passing metrics to other platforms](https://github.com/louislam/uptime-kuma/wiki/Prometheus-Integration#passing-metrics-to-other-platforms) Find all lines starting with "monitor_status" and have a look to the latest character of the line. `# HELP monitor_status Monitor Status (1 = UP, 0= DOWN, 2= PENDING, 3= MAINTENANCE)`
kafisatz commented 2024-03-04 09:31:53 +01:00 (Migrated from github.com)

FYI, I am now using a small python snippet to achieve this:

consider pip install playwright
followed by playwright install

UPK_PW = "abcd"
UPK_USER = "uptimekuma"
UPK_URL = "https://uptimekuma.myurl.ch"

from time import sleep
import traceback
from playwright.sync_api import sync_playwright

def py_playwright_get_summary(UPK_PW,UPK_URL,UPK_USER):
    txt = "Up0Down999Maintenance0Unknown0Pause0"
    with sync_playwright() as p:
        browser_type = p.chromium
        browser = browser_type.launch()
        page = browser.new_page()
        page.goto(UPK_URL)
        
        page.get_by_label("Username").fill(UPK_USER)
        page.get_by_label("Password").fill(UPK_PW)
        page.get_by_role("button" ).click()
        sleep(3)
                
        txt = page.locator("#app > div > main > div > div > div.col-12.col-md-7.col-xl-8.mb-3 > div > div.shadow-box.big-padding.text-center.mb-4 > div").text_content()
        
        browser.close()
    return txt

abc = py_playwright_get_summary(UPK_PW,UPK_URL,UPK_USER)
print(abc)
FYI, I am now using a small python snippet to achieve this: consider `pip install playwright` followed by `playwright install` ``` UPK_PW = "abcd" UPK_USER = "uptimekuma" UPK_URL = "https://uptimekuma.myurl.ch" from time import sleep import traceback from playwright.sync_api import sync_playwright def py_playwright_get_summary(UPK_PW,UPK_URL,UPK_USER): txt = "Up0Down999Maintenance0Unknown0Pause0" with sync_playwright() as p: browser_type = p.chromium browser = browser_type.launch() page = browser.new_page() page.goto(UPK_URL) page.get_by_label("Username").fill(UPK_USER) page.get_by_label("Password").fill(UPK_PW) page.get_by_role("button" ).click() sleep(3) txt = page.locator("#app > div > main > div > div > div.col-12.col-md-7.col-xl-8.mb-3 > div > div.shadow-box.big-padding.text-center.mb-4 > div").text_content() browser.close() return txt abc = py_playwright_get_summary(UPK_PW,UPK_URL,UPK_USER) print(abc) ```
Sign in to join this conversation.
No description provided.