fix
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
from fastapi.responses import FileResponse
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
@@ -36,6 +37,10 @@ WEB_SERVICES = [
|
|||||||
{"name": "Board", "url": "https://board.nabd-co.com/"},
|
{"name": "Board", "url": "https://board.nabd-co.com/"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
async def read_index():
|
||||||
|
return FileResponse("monitor.html")
|
||||||
|
|
||||||
@app.get("/api/status")
|
@app.get("/api/status")
|
||||||
async def get_status():
|
async def get_status():
|
||||||
# Run SSH checks in parallel
|
# Run SSH checks in parallel
|
||||||
|
|||||||
@@ -40,19 +40,6 @@
|
|||||||
animation: fadeInDown 0.8s ease-out;
|
animation: fadeInDown 0.8s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: 2.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
background: linear-gradient(to right, var(--accent-blue), var(--accent-purple));
|
|
||||||
-webkit-background-clip: text;
|
|
||||||
-webkit-text-fill-color: transparent;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
header p {
|
header p {
|
||||||
color: var(--text-dim);
|
color: var(--text-dim);
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
|
|||||||
45
asf-cloud-server/monitor/readme.md
Normal file
45
asf-cloud-server/monitor/readme.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
Infrastructure Monitor Dashboard Walkthrough
|
||||||
|
I have successfully created a real-time infrastructure monitor dashboard.
|
||||||
|
|
||||||
|
Features
|
||||||
|
Real-time Monitoring: Pings local servers (PC and Raspberry Pi) via SSH and web services via HTTP.
|
||||||
|
System Metrics: Displays CPU usage, RAM usage, Temperature, and Disk space for servers.
|
||||||
|
Premium UI: Modern, dark-themed dashboard with glassmorphism effects and dynamic charts.
|
||||||
|
Dockerized: Easy deployment using Docker Compose.
|
||||||
|
Components
|
||||||
|
Backend (FastAPI)
|
||||||
|
main.py
|
||||||
|
: Handles API requests and orchestrates monitoring tasks.
|
||||||
|
monitor_logic.py
|
||||||
|
: Contains the logic for SSH commands and web pings.
|
||||||
|
requirements.txt
|
||||||
|
: Python dependencies.
|
||||||
|
Frontend (HTML/JS)
|
||||||
|
monitor.html
|
||||||
|
: A single-page application that fetches data from the backend and updates the UI every minute.
|
||||||
|
Deployment
|
||||||
|
Dockerfile
|
||||||
|
: Build instructions for the container.
|
||||||
|
docker-compose.yml
|
||||||
|
: Service definition.
|
||||||
|
.env
|
||||||
|
: Environment variables for SSH passwords.
|
||||||
|
How to Deploy
|
||||||
|
Copy files to your cloud server: Copy the contents of the monitor directory to your server.
|
||||||
|
|
||||||
|
Run with Docker Compose:
|
||||||
|
|
||||||
|
docker-compose up -d --build
|
||||||
|
Update Caddyfile: Add the following to your Caddyfile:
|
||||||
|
|
||||||
|
asf.monitor.nabd-co.com {
|
||||||
|
reverse_proxy monitor-app:8000
|
||||||
|
}
|
||||||
|
Then reload Caddy:
|
||||||
|
|
||||||
|
docker exec caddy caddy reload --config /etc/caddy/Caddyfile
|
||||||
|
Verification
|
||||||
|
Access asf.monitor.nabd-co.com in your browser.
|
||||||
|
You should see the dashboard with real-time stats.
|
||||||
|
The "Web Services" section will show the status and latency of your services.
|
||||||
|
The PC and Raspberry Pi sections will show their health metrics.
|
||||||
Reference in New Issue
Block a user