louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
60k stars 5.37k forks source link

Mass Add Sites via Command Line Interface (CLI) #4308

Open Xliff opened 10 months ago

Xliff commented 10 months ago

⚠️ Please verify that this feature request has NOT been suggested before.

🏷️ Feature Request Type

API, Other

🔖 Feature description

Is there a way that one can add sites from the command line? The UI is well done and useful, but I have dozens of sites I'd like to add (I'm a new Kuma user, and this is a new install), but I'd rather not have to maintain them, en-mass, by hand.

✔️ Solution

I'll probably end up attempting to reverse engineer this, as I have an Immediate need for it. Are there technical documentations that I can use to assist in this?

❓ Alternatives

No response

📝 Additional Context

No response

CommanderStorm commented 10 months ago

Currently, there is no CLI and adding one is blocked by #118 imo. See PR #3854 for further details on planned progress.

CommanderStorm commented 10 months ago

I'll probably end up attempting to reverse engineer this, as I have an Immediate need for it. Are there technical documentations that I can use to assist in this?

Note that third partys have created an api wrapper around our websockets: https://uptime-kuma-api.readthedocs.io/en/latest/

Xliff commented 10 months ago

Where can I find details on the WebSocket messaging? Has this been documented?

UPDATE: Given that using the WebSockets appears to not be the preferred method, and that I do not know Python (yet), is there a way to add monitors via accessing the kuma.db file and adding information to the tables therein?

Please note, I am not looking for something permanent. I just need to get our sites into some form of monitoring now and am willing to look, code, document methods for formally adding them later.

Thanks for your hard work in developing this tool! Works nicely!

CommanderStorm commented 10 months ago

is there a way to add monitors via accessing the kuma.db file and adding information to the tables therein?

You can do that, but I would recomend using the third party python api instead.

see https://uptime-kuma-api.readthedocs.io/en/latest/api.html

from uptime_kuma_api import UptimeKumaApi
api = UptimeKumaApi('INSERT_URL')
api.login('INSERT_USERNAME', 'INSERT_PASSWORD')
api.add_monitor(
    type=MonitorType.HTTP,
    name="Google",
    url="https://google.com"
)
api.disconnect()
Xliff commented 10 months ago

I did manage to write something in Raku that worked out. Would you like me to share that code?

CommanderStorm commented 10 months ago

Given the scarily complex syntax of said language, I am a bit doubtful that we could use that code, but sure share it ^^

(Why I am doubtful https://www.youtube.com/watch?v=9J0vCQ36020)

Xliff commented 9 months ago

ROFLMAO!!!

Don't believe the hype.

I was able to do the addition script in less than a day. If said syntax was so scarily complex, I wouldn't have been able to do half of the things I've been able to accomplish in it.

(And I have over 1 million lines in over 65 separate projects in less than 6 years to prove it...)