From 300d6589d626080e8abfab87ed3d9bd8bb923cc1 Mon Sep 17 00:00:00 2001 From: marcel Date: Sun, 13 Aug 2023 16:05:20 +0200 Subject: [PATCH] Script for generating list of services from Uptime Kuma --- .gitignore | 2 ++ example.env | 4 ++++ uptime-kuma-homepage.py | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 example.env create mode 100755 uptime-kuma-homepage.py diff --git a/.gitignore b/.gitignore index 3432817..0d23ef8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,7 @@ !/root !/.gitignore +!/uptime-kuma-homepage.py +!/example.env /root/homepagehtml.html diff --git a/example.env b/example.env new file mode 100644 index 0000000..e624351 --- /dev/null +++ b/example.env @@ -0,0 +1,4 @@ +UPTIME_KUMA_ADMIN_USER='admin' +UPTIME_KUMA_ADMIN_PASSWORD='admin' +UPTIME_KUMA_URL='https://status.example.com' +UPTIME_KUMA_OUT='/path/to/file.html' diff --git a/uptime-kuma-homepage.py b/uptime-kuma-homepage.py new file mode 100755 index 0000000..ea1f0cf --- /dev/null +++ b/uptime-kuma-homepage.py @@ -0,0 +1,34 @@ +#! /bin/python3 +import json,os.environ.get +from uptime_kuma_api import UptimeKumaApi, MonitorType + +descriptions = { + "Jellyfin":"Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.", + "Element Web":"A secure communications platform built around the Matrix protocol.", + "Uptime Kuma":"Uptime Kuma is an easy-to-use self-hosted monitoring tool.", + "Jellyseerr":"Jellyseerr is a free and open source software application for managing requests for your media library.", + "Pixelfed":"Pixelfed is a free and open-source image sharing social network service.", + "EteSync":"Secure, end-to-end encrypted, and privacy respecting sync for your contacts, calendars, tasks and notes.", + "Gitea":"Gitea is a lightweight DevOps platform. It brings teams and developers high-efficiency but easy operations from planning to production.", + "IPFS Gateway":""} + +exclude=('Synapse','Mailserver') +HTMLTEMPLATE='

{item}

{desc}

' +htmllist=[] +htmllist.append(HTMLTEMPLATE.format(link=os.environ.get('UPTIME_KUMA_URL'),item="Uptime Kuma",desc=descriptions["Uptime Kuma"])) + +with UptimeKumaApi(os.environ.get('UPTIME_KUMA_URL') as api: + api.login(os.environ.get('UPTIME_KUMA_ADMIN_USER'),os.environ.get('UPTIME_KUMA_ADMIN_PASSWORD')) + for item in api.get_monitors(): + if item["name"] in exclude or item["type"] == MonitorType.GROUP: + continue + print(item["name"]) + # save every formatted entry in a list + try: + htmllist.append(HTMLTEMPLATE.format(link=item["url"],item=item["name"],desc=descriptions[item["name"]])) + except Exception: + htmllist.append(HTMLTEMPLATE.format(link=item["url"],item=item["name"],desc="")) + + +with open(os.environ.get('UPTIME_KUMA_OUT'),"w") as htmlfile: + htmlfile.write("\n".join(htmllist))