Skip to content

Commit

Permalink
New systeminfo features (#17)
Browse files Browse the repository at this point in the history
- InfoView got reworked. It will now show some system information about the backend host system.
- Show and warn if backend version and app version are not in sync.
  • Loading branch information
schech1 authored Oct 21, 2024
1 parent a963767 commit f1d57b1
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
45 changes: 17 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
<table>
<tr>
<td style="text-align: center;">
<img src="images/sysinfo-2.png" alt="Circular" style="width: 100%;">
<p>Systeminfo</p>
</td>
<td style="text-align: center;">
<img src="images/sysinfo-1.png" alt="Corner" style="width: 100%;">
<p>Systeminfo Details</p>

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
```

</tr>
</table>

## 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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.0
v1.1.3
15 changes: 0 additions & 15 deletions backend/Dockerfile

This file was deleted.

54 changes: 54 additions & 0 deletions backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import datetime
from waitress import serve
import platform,json,psutil,cpuinfo

class Main:
def __init__(self):
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Binary file added images/sysinfo-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/sysinfo-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f1d57b1

Please sign in to comment.