diff --git a/.github/workflows/build-experimental.yml b/.github/workflows/build-experimental.yml index b13071d..e12bf9b 100644 --- a/.github/workflows/build-experimental.yml +++ b/.github/workflows/build-experimental.yml @@ -36,7 +36,7 @@ jobs: - name: Build and push Experimental Docker image uses: docker/build-push-action@v5 with: - context: ./backend + context: . platforms: linux/amd64,linux/arm64 push: true tags: | diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 5c637fa..adbe964 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -42,7 +42,7 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@v5 with: - context: ./backend + context: . platforms: linux/amd64,linux/arm64 push: true tags: | diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d70716e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.11-slim + +# Upgrade pip +RUN python -m pip install --upgrade pip + +# Set the working directory inside the container +WORKDIR /app + +# Copy everything from the current build context to /app +COPY backend /app +COPY VERSION /app/VERSION + +# Install Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Expose the port the app will run on +EXPOSE 5005 + +# Set FLASK_APP environment variable +ENV FLASK_APP=app.py + +# Command to run the Flask app +CMD ["python", "app.py"] diff --git a/README.md b/README.md index 13aa455..7ce8b15 100644 --- a/README.md +++ b/README.md @@ -29,42 +29,31 @@ Uptime Mate, requires a lightweight docker backend to run. ## Last Update Changelog -### Changes **App Version 1.1.0** +### Changes **App Version 1.1.3** -**IMPORTANT!** +With version 1.1.4 of backend and app, the InfoView got reworked. +It will now show some system information about the backend host system. +It will also show and warn if backendversion and appversion are not in sync. -The update 1.1.0 of the app and the backend is not backwards compatible. -Make sure you update the iOS-App to 1.1.0 from the AppStore and pull the lastest docker image from: `schech1/uptime-buddy-api:latest` -- Added an option to exclude paused monitors to the list. The setting is available in the info menu on the AppleWatch App. -- Support for MFA implemented. Uptime Kuma instances with 2FA activated can now be monitored too. - -To add support for MFA, add the MFA variable to the docker-compose and turn on MFA in the iOS-App and apply the authenticator code. - -**Example** - -```yaml -version: '3.8' - -services: - uptime-buddy-api: + + + + +
+ Circular +

Systeminfo

+
+ Corner +

Systeminfo Details

- image: schech1/uptime-buddy-api:latest - ports: - - "5005:5005" - environment: - - UPTIME_KUMA_URL=http://192.168.1.20:3002/ - - USERNAME=admin - - PASSWORD=admin - - TOKEN=gkd4el - - MFA=true/false -``` +
## Backend Compatibility **Be sure to pull the latest docker image** -The current version (1.1.0) in the App Store is compatible with `schech1/uptime-buddy-api:latest` +The current version (1.1.4) in the App Store is compatible with `schech1/uptime-buddy-api:latest` ## Prerequisites in the Uptime Mate iOS-App @@ -123,7 +112,7 @@ services: - USERNAME=YOUR_UPTIME_KUMA_USERNAME # Optional: remove line if auth is disabled in Uptime Kuma - PASSWORD=YOUR_UPTIME_KUMA_PASSWORD # Optional: remove line if auth is disabled in Uptime Kuma - TOKEN=SECRET_TOKEN # Created by iOS-App - - MFA=true/false + - MFA=true # Is MFA enabled in Uptime Kuma? ``` Docker image on [DockerHub](https://hub.docker.com/repository/docker/schech1/uptime-buddy-api/general) diff --git a/VERSION b/VERSION index 795460f..99a4aef 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v1.1.0 +v1.1.3 diff --git a/backend/Dockerfile b/backend/Dockerfile deleted file mode 100644 index 925b758..0000000 --- a/backend/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM python:3.11-slim - -RUN python -m pip install --upgrade pip - -WORKDIR /app - -COPY . /app - -RUN pip install --no-cache-dir -r requirements.txt - -EXPOSE 5005 - -ENV FLASK_APP=app.py - -CMD ["python", "app.py"] diff --git a/backend/app.py b/backend/app.py index 77c3923..9d1a8a2 100644 --- a/backend/app.py +++ b/backend/app.py @@ -4,6 +4,7 @@ import os import datetime from waitress import serve +import platform,json,psutil,cpuinfo class Main: def __init__(self): @@ -162,6 +163,59 @@ def get_monitor(monitor_id): self.logger.error("Error in /monitor/%d: %s", monitor_id, str(e)) return jsonify({"error": str(e)}), 500 + + + + @self.app.route('/system', methods=['GET']) + @self.require_api_token + def getSystemInfo(): + self.logger.info("Accessing /system endpoint") + systemInfo = {} + + # Determine OS name + pName = platform.uname().system + if "darwin" in pName.lower(): + pName = "macOS" + + # System Information + systemInfo["os"] = pName + systemInfo["osArch"] = platform.uname().machine + + # CPU Information + systemInfo["cpu"] = cpuinfo.get_cpu_info()["brand_raw"] + systemInfo["cpuCores"] = psutil.cpu_count(logical=False) + systemInfo["cpuThreads"] = psutil.cpu_count(logical=True) + + # RAM Information + ram = psutil.virtual_memory() + systemInfo["ram"] = round(ram.total / 1024**3, 2) + systemInfo["ramPercent"] = round(ram.percent, 2) + + # Disk Information + disk = psutil.disk_usage("/") + systemInfo["disk"] = round(disk.total / 1024**3, 2) + systemInfo["diskUsed"] = round((disk.total - disk.free) / 1024**3, 2) + systemInfo["diskFree"] = round(disk.free / 1024**3, 2) + systemInfo["diskPercent"] = round((disk.total - disk.free) / disk.total * 100, 2) + + # Backend version + version_file_path = '/app/VERSION' + + try: + with open(version_file_path) as version_file: + app_version = version_file.read().strip() + systemInfo["version"] = app_version[1:] + + except FileNotFoundError: + self.logger.info(f"VERSION file not found at {version_file_path}") + + + return jsonify(systemInfo) + + + + + def run(self): self.logger.info("Starting the backend...") serve(self.app, host="0.0.0.0", port=self.port, threads=8) diff --git a/backend/requirements.txt b/backend/requirements.txt index 8f20757..91e20fd 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,3 +1,5 @@ Flask==3.0.3 waitress==3.0.0 uptime-kuma-api==1.2.1 +psutil==6.1.0 +py-cpuinfo==9.0.0 diff --git a/images/sysinfo-1.png b/images/sysinfo-1.png new file mode 100644 index 0000000..7bbeb9d Binary files /dev/null and b/images/sysinfo-1.png differ diff --git a/images/sysinfo-2.png b/images/sysinfo-2.png new file mode 100644 index 0000000..591551c Binary files /dev/null and b/images/sysinfo-2.png differ