init
This commit is contained in:
41
docs/architecture.md
Normal file
41
docs/architecture.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Architecture Overview
|
||||
|
||||
The ASF Infrastructure Monitor is a lightweight, real-time monitoring solution designed to track the health of local servers and web services.
|
||||
|
||||
## System Components
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
User((User Browser))
|
||||
Caddy[Caddy Proxy]
|
||||
MonitorApp[Monitor App Container]
|
||||
|
||||
subgraph "Local Network / Internet"
|
||||
PC[Ubuntu Server PC]
|
||||
PI[Raspberry Pi]
|
||||
WebServices[Web Services]
|
||||
end
|
||||
|
||||
User -->|HTTPS| Caddy
|
||||
Caddy -->|HTTP| MonitorApp
|
||||
|
||||
MonitorApp -->|SSH| PC
|
||||
MonitorApp -->|SSH| PI
|
||||
MonitorApp -->|HTTP/Ping| WebServices
|
||||
```
|
||||
|
||||
### 1. Frontend (Client-Side)
|
||||
- **Technology**: HTML5, Vanilla CSS, JavaScript (ES6+).
|
||||
- **Libraries**: Chart.js for gauges, FontAwesome for icons.
|
||||
- **Functionality**: Fetches data from the backend every 60 seconds and updates the UI dynamically without page reloads.
|
||||
|
||||
### 2. Backend (Server-Side)
|
||||
- **Technology**: Python 3.11, FastAPI.
|
||||
- **Monitoring Logic**:
|
||||
- **SSH**: Uses `paramiko` to execute remote commands on the PC and Raspberry Pi.
|
||||
- **Web**: Uses `requests` to check the status and latency of web services.
|
||||
- **Concurrency**: Uses `asyncio` to perform all monitoring checks in parallel, ensuring fast response times.
|
||||
|
||||
### 3. Deployment
|
||||
- **Containerization**: Docker & Docker Compose.
|
||||
- **Proxy**: Caddy handles SSL termination and routes traffic to the container.
|
||||
30
docs/backend.md
Normal file
30
docs/backend.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# 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 the `monitor.html` file.
|
||||
- `GET /api/status`: Orchestrates the monitoring tasks and returns a JSON response.
|
||||
- **Parallel Execution**: Uses `asyncio.gather` and `asyncio.to_thread` to 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/temp` or `vcgencmd`.
|
||||
- **`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.
|
||||
36
docs/deployment.md
Normal file
36
docs/deployment.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Deployment Documentation
|
||||
|
||||
The application is designed to be deployed as a Docker container behind a Caddy reverse proxy.
|
||||
|
||||
## Docker Setup
|
||||
|
||||
### `Dockerfile`
|
||||
- Based on `python:3.11-slim`.
|
||||
- Installs `iputils-ping` for network diagnostics.
|
||||
- Uses `uvicorn` to serve the FastAPI app.
|
||||
|
||||
### `docker-compose.yml`
|
||||
- Defines the `monitor-app` service.
|
||||
- Connects to `caddy_network` for external access.
|
||||
- Passes SSH credentials via environment variables.
|
||||
|
||||
## Caddy Configuration
|
||||
Add this to your `Caddyfile`:
|
||||
|
||||
```caddy
|
||||
asf.monitor.nabd-co.com {
|
||||
reverse_proxy monitor-app:8000
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### `KeyError: 'ContainerConfig'`
|
||||
This error occurs when using `docker-compose` V1 with images built by newer Docker versions.
|
||||
**Solution**: Use `docker compose` (V2) or disable BuildKit:
|
||||
```bash
|
||||
DOCKER_BUILDKIT=0 COMPOSE_DOCKER_CLI_BUILD=0 docker-compose up -d --build
|
||||
```
|
||||
|
||||
### SSH Connectivity
|
||||
Ensure the cloud server can reach the target IPs/hostnames on the specified ports (49152 and 2222).
|
||||
19
docs/frontend.md
Normal file
19
docs/frontend.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Frontend Documentation
|
||||
|
||||
The frontend is a modern, responsive dashboard designed for high visibility and aesthetic appeal.
|
||||
|
||||
## Design Principles
|
||||
- **Glassmorphism**: Uses semi-transparent backgrounds with blur effects (`backdrop-filter`).
|
||||
- **Dark Mode**: Optimized for low-light environments (NOC/Dashboard style).
|
||||
- **Vibrant Accents**: Uses gradients and neon colors to highlight status and metrics.
|
||||
|
||||
## Key Features
|
||||
- **Dynamic Gauges**: Built with `Chart.js` to show CPU and RAM usage.
|
||||
- **Status Badges**: Real-time color-coded badges (Online/Offline).
|
||||
- **Auto-Refresh**: Polls the `/api/status` endpoint every 1 minute.
|
||||
- **Loading State**: A smooth loading overlay that disappears once the first data batch is received.
|
||||
|
||||
## UI Components
|
||||
- **Server Cards**: Detailed metrics for PC and Raspberry Pi.
|
||||
- **Web Services List**: Compact list of external services with latency tracking.
|
||||
- **Responsive Grid**: Automatically adjusts layout based on screen size.
|
||||
Reference in New Issue
Block a user