1.0 KiB
1.0 KiB
Backend Documentation
The backend is built with FastAPI, providing a high-performance API to serve system metrics.
Core Files
main.py
- Entry point of the application.
- Defines the FastAPI app and CORS middleware.
- Endpoints:
GET /: Serves themonitor.htmlfile.GET /api/status: Orchestrates the monitoring tasks and returns a JSON response.
- Parallel Execution: Uses
asyncio.gatherandasyncio.to_threadto run blocking SSH/HTTP calls concurrently.
monitor_logic.py
- Contains the low-level monitoring functions.
get_ssh_data():- Connects via SSH using
paramiko. - Executes commands to fetch:
- CPU Usage:
top - RAM Usage:
free - Disk Space:
df - Temperature:
/sys/class/thermal/thermal_zone0/temporvcgencmd.
- CPU Usage:
- Connects via SSH using
check_web_service():- Performs an HTTP GET request.
- Calculates latency in milliseconds.
Environment Variables
PC_PASS: SSH password for the Ubuntu Server.PI_PASS: SSH password for the Raspberry Pi.