Compare commits
13 Commits
7bbde43878
...
v0.2.5
| Author | SHA1 | Date | |
|---|---|---|---|
| 96c481c4c1 | |||
| f8961320c5 | |||
| 23cac83061 | |||
| 2576604a4a | |||
| 8a753ca9ba | |||
| 6429489f80 | |||
| ef51e95483 | |||
| e5b17d0daf | |||
| c2aac1a3a3 | |||
| 3c6bd2fa56 | |||
| 6c7d31d189 | |||
| 454d651d4d | |||
| 70eec04327 |
16
Dockerfile
16
Dockerfile
@@ -18,19 +18,29 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
# Build-Argument für Version (wird zur Build-Zeit vom CI/CD gesetzt)
|
||||
ARG VERSION=latest
|
||||
|
||||
# Install curl for health checks
|
||||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user
|
||||
RUN groupadd -r watcher -g 1000 && useradd -r -g watcher -u 1000 watcher
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/publish .
|
||||
|
||||
# Stelle sicher, dass Verzeichnisse existieren
|
||||
RUN mkdir -p /app/persistence /app/wwwroot/downloads/sqlite /app/logs
|
||||
# Stelle sicher, dass Verzeichnisse existieren und Berechtigungen gesetzt sind
|
||||
RUN mkdir -p /app/persistence /app/wwwroot/downloads/sqlite /app/logs && \
|
||||
chown -R watcher:watcher /app
|
||||
|
||||
# Volumes
|
||||
VOLUME ["/app/persistence", "/app/wwwroot/downloads/sqlite", "/app/logs"]
|
||||
|
||||
# Switch to non-root user
|
||||
USER watcher
|
||||
|
||||
# Expose Port 5000
|
||||
EXPOSE 5000
|
||||
ENV ASPNETCORE_URLS=http://*:5000
|
||||
ENV ASPNETCORE_ENVIRONMENT=Development
|
||||
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||
|
||||
# Version als Environment Variable setzen
|
||||
ENV WATCHER_VERSION=${VERSION}
|
||||
|
||||
212
README.md
212
README.md
@@ -1,34 +1,202 @@
|
||||
# 🖥️ Server Monitoring Software
|
||||
# Watcher - Server Monitoring Solution
|
||||
|
||||
Dieses Projekt ist eine umfassende Monitoring-Lösung für Server und Host-Geräte.
|
||||
Die Software besteht aus zwei Teilen:
|
||||
- **Host Agent**: Sammelt Hardware-Daten von den Hosts
|
||||
- **Zentrale Monitoring-Software**: Visualisiert und verwaltet die gesammelten Daten
|
||||
[](https://git.triggermeelmo.com/Watcher/watcher/actions)
|
||||
[](https://dotnet.microsoft.com/)
|
||||
[](https://git.triggermeelmo.com/watcher/-/packages/container/watcher-server)
|
||||
[](https://git.triggermeelmo.com/watcher/watcher-server)
|
||||
|
||||
Die Lösung unterstützt moderne Authentifizierungsverfahren und flexible Datenbankanbindungen – alles bequem verteilt als Docker Image.
|
||||
**Watcher** ist eine umfassende Server- und Host-Monitoring-Lösung mit verteilter Architektur, die Echtzeit-Hardware-Metriken erfasst und über ein zentrales Web-Dashboard visualisiert.
|
||||
|
||||
---
|
||||
## 📋 Überblick
|
||||
|
||||
## ✨ Features
|
||||
Die Software besteht aus zwei Hauptkomponenten:
|
||||
|
||||
- Erfassung von Hardware-Daten aller wichtigen Komponenten
|
||||
- Lokale Authentifizierung oder OIDC (OpenID Connect)
|
||||
- Wahlweise Speicherung der Daten in:
|
||||
- Lokaler SQLite-Datenbank
|
||||
- Remote MySQL-Datenbank
|
||||
- Einfache Bereitstellung via Docker & docker-compose
|
||||
- **Host Agent**: Sammelt Hardware-Metriken (CPU, GPU, RAM, Festplatte, Netzwerk) von den überwachten Servern
|
||||
- **Zentrale Monitoring-Software**: Web-basiertes Dashboard zur Visualisierung und Verwaltung der gesammelten Daten mit konfigurierbaren Alarmschwellen
|
||||
|
||||
---
|
||||
## ✨ Hauptfunktionen
|
||||
|
||||
## ⚙️ Installation & Start
|
||||
### Server-Management
|
||||
- Hinzufügen, bearbeiten und löschen von Servern
|
||||
- Hardware-Spezifikationen erfassen (CPU, GPU, RAM, Festplatte)
|
||||
- Server-Verifikationssystem
|
||||
- Online/Offline-Status-Tracking via Heartbeat
|
||||
- Konfigurierbare Alarmschwellen pro Server
|
||||
|
||||
Voraussetzung:
|
||||
### Monitoring & Metriken
|
||||
- Echtzeit-Metrikerfassung: CPU, GPU, RAM, Festplatte, Netzwerk
|
||||
- Automatische Datenaufbewahrung mit konfigurierbarer Retention (Standard: 30 Tage)
|
||||
- Historische Datenspeicherung mit Zeitstempel
|
||||
- REST API-Endpunkte für Metrik-Submission
|
||||
- Swagger/OpenAPI-Dokumentation unter `/api/v1/swagger`
|
||||
|
||||
### Container-Management
|
||||
- Docker-Container-Tracking pro Server
|
||||
- Container-Image-Registry
|
||||
- Container-Status-Überwachung
|
||||
- Service Discovery für Docker-Container
|
||||
|
||||
### Sicherheit & Authentifizierung
|
||||
- Lokale Benutzerauthentifizierung mit BCrypt-Hashing
|
||||
- Cookie-basierte Session-Verwaltung
|
||||
- Rollenbasierte Zugriffskontrolle
|
||||
- Standard-Admin-Benutzer (Username: `admin`, Passwort: `changeme` - bitte ändern!)
|
||||
|
||||
### Logging & Diagnostik
|
||||
- Strukturiertes Logging mit Serilog
|
||||
- Tägliche Log-Dateien: `logs/watcher-<datum>.log`
|
||||
- Health-Check-Endpunkte
|
||||
- Datenbank-Export-Funktionalität (SQL-Dumps)
|
||||
|
||||
## 🛠️ Technologie-Stack
|
||||
|
||||
**Backend:**
|
||||
- ASP.NET Core 8.0 (C#)
|
||||
- Entity Framework Core 8.0
|
||||
- Serilog 9.0 für Logging
|
||||
|
||||
**Datenbank:**
|
||||
- SQLite (Standard, dateibasiert)
|
||||
- MySQL-Unterstützung (konfigurierbar)
|
||||
|
||||
**Frontend:**
|
||||
- Razor Views (CSHTML)
|
||||
- Bootstrap / CSS
|
||||
- jQuery, jQuery Validation
|
||||
|
||||
**API & Dokumentation:**
|
||||
- Swagger/Swashbuckle 9.0.6
|
||||
- REST API
|
||||
|
||||
**Container & Deployment:**
|
||||
- Docker (Multi-Arch: AMD64, ARM64)
|
||||
- Docker Compose
|
||||
- Gitea CI/CD
|
||||
|
||||
## 🚀 Installation & Start
|
||||
|
||||
### Voraussetzungen
|
||||
- [Docker](https://www.docker.com/)
|
||||
- [docker-compose](https://docs.docker.com/compose/)
|
||||
- [Docker Compose](https://docs.docker.com/compose/)
|
||||
|
||||
1. Image herunterladen:
|
||||
```bash
|
||||
docker pull git.triggermeelmo.com/daniel-hbn/watcher/watcher:latest
|
||||
2. Docker Container starten
|
||||
### Schnellstart
|
||||
|
||||
1. **docker-compose.yaml erstellen** oder die bereitgestellte verwenden:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
watcher:
|
||||
image: git.triggermeelmo.com/watcher/watcher-server:latest
|
||||
container_name: watcher
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 200M
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- WATCHER_VERSION=latest
|
||||
- UPDATE_CHECK_ENABLED=true
|
||||
- UPDATE_CHECK_INTERVAL_HOURS=24
|
||||
- METRIC_RETENTION_DAYS=30
|
||||
- METRIC_CLEANUP_ENABLED=true
|
||||
- METRIC_CLEANUP_INTERVAL_HOURS=24
|
||||
ports:
|
||||
- "5000:5000"
|
||||
volumes:
|
||||
- ./watcher-volumes/data:/app/persistence
|
||||
- ./watcher-volumes/dumps:/app/wwwroot/downloads/sqlite
|
||||
- ./watcher-volumes/logs:/app/logs
|
||||
```
|
||||
|
||||
2. **Container starten:**
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
3. **Dashboard aufrufen:**
|
||||
```
|
||||
http://localhost:5000
|
||||
```
|
||||
|
||||
4. **Standardanmeldung:**
|
||||
- Benutzername: `admin`
|
||||
- Passwort: `changeme`
|
||||
- ⚠️ **Wichtig:** Bitte Passwort nach dem ersten Login ändern!
|
||||
|
||||
## ⚙️ Konfiguration
|
||||
|
||||
### Umgebungsvariablen
|
||||
|
||||
| Variable | Beschreibung | Standard |
|
||||
|----------|--------------|----------|
|
||||
| `WATCHER_VERSION` | Anwendungsversion | `latest` |
|
||||
| `UPDATE_CHECK_ENABLED` | Update-Prüfung aktivieren | `true` |
|
||||
| `UPDATE_CHECK_INTERVAL_HOURS` | Update-Prüfungs-Intervall | `24` |
|
||||
| `METRIC_RETENTION_DAYS` | Datenspeicherdauer (Tage) | `30` |
|
||||
| `METRIC_CLEANUP_ENABLED` | Automatische Datenbereinigung | `true` |
|
||||
| `METRIC_CLEANUP_INTERVAL_HOURS` | Bereinigungs-Intervall | `24` |
|
||||
| `DATABASE:CONNECTIONSTRINGS:SQLITE` | Benutzerdefinierter SQLite-Pfad | - |
|
||||
|
||||
### Volumes
|
||||
|
||||
- `/app/persistence` - SQLite-Datenbank
|
||||
- `/app/wwwroot/downloads/sqlite` - Datenbank-Exports
|
||||
- `/app/logs` - Anwendungslogs
|
||||
|
||||
## 🔧 Entwicklung
|
||||
|
||||
### Lokales Build
|
||||
|
||||
```bash
|
||||
# Dependencies wiederherstellen
|
||||
dotnet restore
|
||||
|
||||
# Build
|
||||
dotnet build --configuration Release
|
||||
|
||||
# Tests ausführen
|
||||
dotnet test
|
||||
|
||||
# Anwendung starten
|
||||
dotnet run --project Watcher
|
||||
```
|
||||
|
||||
### Docker-Build
|
||||
|
||||
```bash
|
||||
# Multi-Arch Build
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-t watcher-server:latest \
|
||||
--push .
|
||||
```
|
||||
|
||||
## 📁 Projektstruktur
|
||||
|
||||
```
|
||||
/Watcher
|
||||
├── Controllers/ # MVC & API Controllers
|
||||
├── Models/ # Entity-Modelle
|
||||
├── Views/ # Razor-Templates
|
||||
├── Services/ # Background-Services & Stores
|
||||
├── Data/ # Entity Framework Context
|
||||
├── Migrations/ # EF Core Migrations
|
||||
├── ViewModels/ # View Models
|
||||
├── wwwroot/ # Statische Assets
|
||||
├── persistence/ # SQLite-Datenbank
|
||||
└── logs/ # Anwendungslogs
|
||||
```
|
||||
|
||||
## 📝 Lizenz
|
||||
|
||||
Dieses Projekt ist unter einer proprietären Lizenz lizenziert.
|
||||
|
||||
## 🔗 Links
|
||||
|
||||
- **Repository:** [https://git.triggermeelmo.com/Watcher/watcher](https://git.triggermeelmo.com/Watcher/watcher)
|
||||
- **Container Registry:** [https://git.triggermeelmo.com/watcher/-/packages/container/watcher-server](https://git.triggermeelmo.com/watcher/-/packages/container/watcher-server)
|
||||
- **Issue Tracker:** [https://git.triggermeelmo.com/Watcher/watcher/issues](https://git.triggermeelmo.com/Watcher/watcher/issues)
|
||||
|
||||
---
|
||||
|
||||
**Entwickelt mit ❤️ unter Verwendung von .NET 8.0**
|
||||
412
Tests/populate_testdata.py
Normal file
412
Tests/populate_testdata.py
Normal file
@@ -0,0 +1,412 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Watcher Database Test Data Population Script
|
||||
Füllt die SQLite-Datenbank mit realistischen Testdaten für lokale Entwicklung
|
||||
"""
|
||||
|
||||
import sqlite3
|
||||
import random
|
||||
from datetime import datetime, timedelta
|
||||
import os
|
||||
|
||||
# Datenbankpfad
|
||||
DB_PATH = "Watcher\persistence\watcher.db"
|
||||
|
||||
# Prüfe ob Datenbank existiert
|
||||
if not os.path.exists(DB_PATH):
|
||||
print(f"❌ Datenbank nicht gefunden: {DB_PATH}")
|
||||
print("Bitte stelle sicher, dass die Anwendung einmal gestartet wurde, um die Datenbank zu erstellen.")
|
||||
exit(1)
|
||||
|
||||
print(f"📊 Verbinde mit Datenbank: {DB_PATH}")
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Lösche vorhandene Daten (optional - auskommentieren wenn bestehende Daten behalten werden sollen)
|
||||
print("\n🗑️ Lösche vorhandene Testdaten...")
|
||||
cursor.execute("DELETE FROM ContainerMetrics")
|
||||
cursor.execute("DELETE FROM Metrics")
|
||||
cursor.execute("DELETE FROM LogEvents")
|
||||
cursor.execute("DELETE FROM Containers")
|
||||
cursor.execute("DELETE FROM Images")
|
||||
cursor.execute("DELETE FROM Tags")
|
||||
cursor.execute("DELETE FROM Servers")
|
||||
# Users werden NICHT gelöscht
|
||||
conn.commit()
|
||||
|
||||
print("✅ Alte Daten gelöscht (Users bleiben erhalten)\n")
|
||||
|
||||
# ============================================================================
|
||||
# 2. SERVERS - Test-Server erstellen
|
||||
# ============================================================================
|
||||
print("\n🖥️ Erstelle Server...")
|
||||
|
||||
servers_data = [
|
||||
{
|
||||
"name": "Production-Web-01",
|
||||
"ip": "192.168.1.10",
|
||||
"type": "Ubuntu 22.04",
|
||||
"description": "Haupt-Webserver für Production",
|
||||
"cpu_type": "Intel Core i7-12700K",
|
||||
"cpu_cores": 12,
|
||||
"gpu_type": None,
|
||||
"ram_size": 34359738368, # 32 GB in Bytes
|
||||
"disk_space": "512 GB NVMe SSD",
|
||||
"is_online": True
|
||||
},
|
||||
{
|
||||
"name": "Dev-Server",
|
||||
"ip": "192.168.1.20",
|
||||
"type": "Debian 12",
|
||||
"description": "Entwicklungs- und Testserver",
|
||||
"cpu_type": "AMD Ryzen 9 5900X",
|
||||
"cpu_cores": 12,
|
||||
"gpu_type": None,
|
||||
"ram_size": 68719476736, # 64 GB in Bytes
|
||||
"disk_space": "1 TB NVMe SSD",
|
||||
"is_online": True
|
||||
},
|
||||
{
|
||||
"name": "GPU-Server-ML",
|
||||
"ip": "192.168.1.30",
|
||||
"type": "Ubuntu 22.04 LTS",
|
||||
"description": "Machine Learning Training Server",
|
||||
"cpu_type": "AMD Ryzen Threadripper 3970X",
|
||||
"cpu_cores": 32,
|
||||
"gpu_type": "NVIDIA RTX 4090",
|
||||
"ram_size": 137438953472, # 128 GB in Bytes
|
||||
"disk_space": "2 TB NVMe SSD",
|
||||
"is_online": True
|
||||
},
|
||||
{
|
||||
"name": "Backup-Server",
|
||||
"ip": "192.168.1.40",
|
||||
"type": "Ubuntu 20.04",
|
||||
"description": "Backup und Storage Server",
|
||||
"cpu_type": "Intel Xeon E5-2680 v4",
|
||||
"cpu_cores": 14,
|
||||
"gpu_type": None,
|
||||
"ram_size": 17179869184, # 16 GB in Bytes
|
||||
"disk_space": "10 TB HDD RAID5",
|
||||
"is_online": False
|
||||
},
|
||||
{
|
||||
"name": "Docker-Host-01",
|
||||
"ip": "192.168.1.50",
|
||||
"type": "Ubuntu 22.04",
|
||||
"description": "Docker Container Host",
|
||||
"cpu_type": "Intel Xeon Gold 6248R",
|
||||
"cpu_cores": 24,
|
||||
"gpu_type": None,
|
||||
"ram_size": 68719476736, # 64 GB in Bytes
|
||||
"disk_space": "2 TB NVMe SSD",
|
||||
"is_online": True
|
||||
}
|
||||
]
|
||||
|
||||
server_ids = []
|
||||
for server in servers_data:
|
||||
last_seen = datetime.utcnow() - timedelta(minutes=random.randint(0, 30)) if server["is_online"] else datetime.utcnow() - timedelta(hours=random.randint(2, 48))
|
||||
|
||||
cursor.execute("""
|
||||
INSERT INTO Servers (
|
||||
Name, IPAddress, Type, Description,
|
||||
CpuType, CpuCores, GpuType, RamSize, DiskSpace,
|
||||
CPU_Load_Warning, CPU_Load_Critical,
|
||||
CPU_Temp_Warning, CPU_Temp_Critical,
|
||||
RAM_Load_Warning, RAM_Load_Critical,
|
||||
GPU_Load_Warning, GPU_Load_Critical,
|
||||
GPU_Temp_Warning, GPU_Temp_Critical,
|
||||
Disk_Usage_Warning, Disk_Usage_Critical,
|
||||
DISK_Temp_Warning, DISK_Temp_Critical,
|
||||
CreatedAt, IsOnline, LastSeen, IsVerified
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", (
|
||||
server["name"], server["ip"], server["type"], server["description"],
|
||||
server["cpu_type"], server["cpu_cores"], server["gpu_type"], server["ram_size"], server["disk_space"],
|
||||
75.0, 90.0, # CPU Load
|
||||
80.0, 90.0, # CPU Temp
|
||||
85.0, 95.0, # RAM Load
|
||||
75.0, 90.0, # GPU Load
|
||||
70.0, 80.0, # GPU Temp
|
||||
75.0, 90.0, # Disk Usage
|
||||
34.0, 36.0, # Disk Temp
|
||||
datetime.utcnow() - timedelta(days=random.randint(30, 365)),
|
||||
server["is_online"], last_seen, True
|
||||
))
|
||||
server_ids.append(cursor.lastrowid)
|
||||
print(f" ✓ Server '{server['name']}' erstellt (ID: {cursor.lastrowid})")
|
||||
|
||||
conn.commit()
|
||||
|
||||
# ============================================================================
|
||||
# 3. METRICS - Server-Metriken erstellen (letzte 48 Stunden)
|
||||
# ============================================================================
|
||||
print("\n📈 Erstelle Server-Metriken (letzte 48 Stunden)...")
|
||||
|
||||
metrics_count = 0
|
||||
for server_id in server_ids:
|
||||
# Finde den Server
|
||||
cursor.execute("SELECT IsOnline FROM Servers WHERE Id = ?", (server_id,))
|
||||
is_online = cursor.fetchone()[0]
|
||||
|
||||
if not is_online:
|
||||
continue # Keine Metriken für offline Server
|
||||
|
||||
# Erstelle Metriken für die letzten 48 Stunden (alle 5 Minuten)
|
||||
start_time = datetime.utcnow() - timedelta(hours=48)
|
||||
current_time = start_time
|
||||
|
||||
# Basis-Werte für realistische Schwankungen
|
||||
base_cpu = random.uniform(20, 40)
|
||||
base_ram = random.uniform(40, 60)
|
||||
base_gpu = random.uniform(10, 30) if server_id == server_ids[2] else 0 # Nur GPU-Server
|
||||
|
||||
while current_time <= datetime.utcnow():
|
||||
# Realistische Schwankungen
|
||||
cpu_load = max(0, min(100, base_cpu + random.gauss(0, 15)))
|
||||
cpu_temp = 30 + (cpu_load * 0.5) + random.gauss(0, 3)
|
||||
|
||||
ram_load = max(0, min(100, base_ram + random.gauss(0, 10)))
|
||||
|
||||
gpu_load = max(0, min(100, base_gpu + random.gauss(0, 20))) if base_gpu > 0 else 0
|
||||
gpu_temp = 25 + (gpu_load * 0.6) + random.gauss(0, 3) if gpu_load > 0 else 0
|
||||
gpu_vram_usage = gpu_load * 0.8 if gpu_load > 0 else 0
|
||||
|
||||
disk_usage = random.uniform(40, 75)
|
||||
disk_temp = random.uniform(28, 35)
|
||||
|
||||
net_in = random.uniform(1000000, 10000000) # 1-10 Mbps in Bits
|
||||
net_out = random.uniform(500000, 5000000) # 0.5-5 Mbps in Bits
|
||||
|
||||
cursor.execute("""
|
||||
INSERT INTO Metrics (
|
||||
ServerId, Timestamp,
|
||||
CPU_Load, CPU_Temp,
|
||||
GPU_Load, GPU_Temp, GPU_Vram_Size, GPU_Vram_Usage,
|
||||
RAM_Size, RAM_Load,
|
||||
DISK_Size, DISK_Usage, DISK_Temp,
|
||||
NET_In, NET_Out
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", (
|
||||
server_id, current_time,
|
||||
cpu_load, cpu_temp,
|
||||
gpu_load, gpu_temp, 24.0, gpu_vram_usage, # 24 GB VRAM
|
||||
64.0, ram_load,
|
||||
512.0, disk_usage, disk_temp,
|
||||
net_in, net_out
|
||||
))
|
||||
|
||||
metrics_count += 1
|
||||
current_time += timedelta(minutes=5)
|
||||
|
||||
print(f" ✓ Server {server_id}: {metrics_count} Metriken erstellt")
|
||||
|
||||
conn.commit()
|
||||
print(f"✅ Insgesamt {metrics_count} Metriken erstellt")
|
||||
|
||||
# ============================================================================
|
||||
# 4. IMAGES - Docker Images
|
||||
# ============================================================================
|
||||
print("\n🐳 Erstelle Docker Images...")
|
||||
|
||||
images_data = [
|
||||
("nginx", "latest"),
|
||||
("nginx", "alpine"),
|
||||
("postgres", "15"),
|
||||
("postgres", "14-alpine"),
|
||||
("redis", "7-alpine"),
|
||||
("node", "18-alpine"),
|
||||
("python", "3.11-slim"),
|
||||
("mysql", "8.0"),
|
||||
("traefik", "v2.10"),
|
||||
("portainer", "latest")
|
||||
]
|
||||
|
||||
image_ids = {}
|
||||
for name, tag in images_data:
|
||||
cursor.execute("""
|
||||
INSERT INTO Images (Name, Tag)
|
||||
VALUES (?, ?)
|
||||
""", (name, tag))
|
||||
image_ids[f"{name}:{tag}"] = cursor.lastrowid
|
||||
print(f" ✓ Image '{name}:{tag}' erstellt")
|
||||
|
||||
conn.commit()
|
||||
|
||||
# ============================================================================
|
||||
# 5. CONTAINERS - Docker Container
|
||||
# ============================================================================
|
||||
print("\n📦 Erstelle Docker Container...")
|
||||
|
||||
# Nur für Server, die online sind
|
||||
online_server_ids = [sid for sid in server_ids[:2]] # Erste 2 Server haben Container
|
||||
|
||||
containers_data = [
|
||||
# Production-Web-01
|
||||
("nginx-web", "abc123def456", "nginx:latest", online_server_ids[0], True),
|
||||
("postgres-db", "def456ghi789", "postgres:15", online_server_ids[0], True),
|
||||
("redis-cache", "ghi789jkl012", "redis:7-alpine", online_server_ids[0], True),
|
||||
("traefik-proxy", "jkl012mno345", "traefik:v2.10", online_server_ids[0], True),
|
||||
|
||||
# Dev-Server
|
||||
("dev-nginx", "mno345pqr678", "nginx:alpine", online_server_ids[1], True),
|
||||
("dev-postgres", "pqr678stu901", "postgres:14-alpine", online_server_ids[1], False),
|
||||
("dev-redis", "stu901vwx234", "redis:7-alpine", online_server_ids[1], True),
|
||||
("test-app", "vwx234yz567", "node:18-alpine", online_server_ids[1], True),
|
||||
("portainer", "yz567abc890", "portainer:latest", online_server_ids[1], True),
|
||||
]
|
||||
|
||||
container_ids = []
|
||||
for name, container_id, image, server_id, is_running in containers_data:
|
||||
cursor.execute("""
|
||||
INSERT INTO Containers (Name, ContainerId, Image, ServerId, IsRunning)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
""", (name, container_id, image, server_id, is_running))
|
||||
container_ids.append(cursor.lastrowid)
|
||||
status = "🟢 Running" if is_running else "🔴 Stopped"
|
||||
print(f" ✓ Container '{name}' erstellt - {status}")
|
||||
|
||||
conn.commit()
|
||||
|
||||
# ============================================================================
|
||||
# 6. CONTAINER METRICS - Container-Metriken (letzte 24 Stunden)
|
||||
# ============================================================================
|
||||
print("\n📊 Erstelle Container-Metriken (letzte 24 Stunden)...")
|
||||
|
||||
container_metrics_count = 0
|
||||
for container_id in container_ids:
|
||||
# Prüfe ob Container läuft
|
||||
cursor.execute("SELECT IsRunning FROM Containers WHERE Id = ?", (container_id,))
|
||||
is_running = cursor.fetchone()[0]
|
||||
|
||||
if not is_running:
|
||||
continue # Keine Metriken für gestoppte Container
|
||||
|
||||
# Erstelle Metriken für die letzten 24 Stunden (alle 5 Minuten)
|
||||
start_time = datetime.utcnow() - timedelta(hours=24)
|
||||
current_time = start_time
|
||||
|
||||
# Basis-Werte für Container (meist niedriger als Host)
|
||||
base_cpu = random.uniform(5, 15)
|
||||
base_ram = random.uniform(10, 30)
|
||||
|
||||
while current_time <= datetime.utcnow():
|
||||
cpu_load = max(0, min(100, base_cpu + random.gauss(0, 8)))
|
||||
cpu_temp = 30 + (cpu_load * 0.5) + random.gauss(0, 2)
|
||||
|
||||
ram_load = max(0, min(100, base_ram + random.gauss(0, 5)))
|
||||
ram_size = random.uniform(0.5, 4.0) # Container nutzen weniger RAM
|
||||
|
||||
cursor.execute("""
|
||||
INSERT INTO ContainerMetrics (
|
||||
ContainerId, Timestamp,
|
||||
CPU_Load, CPU_Temp,
|
||||
RAM_Size, RAM_Load
|
||||
) VALUES (?, ?, ?, ?, ?, ?)
|
||||
""", (
|
||||
container_id, current_time,
|
||||
cpu_load, cpu_temp,
|
||||
ram_size, ram_load
|
||||
))
|
||||
|
||||
container_metrics_count += 1
|
||||
current_time += timedelta(minutes=5)
|
||||
|
||||
conn.commit()
|
||||
print(f"✅ Insgesamt {container_metrics_count} Container-Metriken erstellt")
|
||||
|
||||
# ============================================================================
|
||||
# 7. LOG EVENTS - Log-Einträge erstellen
|
||||
# ============================================================================
|
||||
print("\n📝 Erstelle Log Events...")
|
||||
|
||||
log_messages = [
|
||||
("Info", "Server erfolgreich gestartet", None, None),
|
||||
("Info", "Backup abgeschlossen", server_ids[3], None),
|
||||
("Warning", "CPU-Auslastung über 80%", server_ids[0], None),
|
||||
("Info", "Container gestartet", server_ids[0], container_ids[0]),
|
||||
("Error", "Datenbank-Verbindung fehlgeschlagen", server_ids[1], container_ids[5]),
|
||||
("Warning", "Speicherplatz unter 25%", server_ids[1], None),
|
||||
("Info", "Update installiert", server_ids[2], None),
|
||||
("Info", "Container neu gestartet", server_ids[0], container_ids[2]),
|
||||
("Warning", "GPU-Temperatur über 75°C", server_ids[2], None),
|
||||
("Info", "Netzwerk-Check erfolgreich", server_ids[0], None),
|
||||
]
|
||||
|
||||
for level, message, server_id, container_id in log_messages:
|
||||
timestamp = datetime.utcnow() - timedelta(hours=random.randint(0, 48))
|
||||
cursor.execute("""
|
||||
INSERT INTO LogEvents (Timestamp, Message, Level, ServerId, ContainerId)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
""", (timestamp, message, level, server_id, container_id))
|
||||
print(f" ✓ Log: [{level}] {message}")
|
||||
|
||||
conn.commit()
|
||||
|
||||
# ============================================================================
|
||||
# 8. TAGS - Tags für Server/Container
|
||||
# ============================================================================
|
||||
print("\n🏷️ Erstelle Tags...")
|
||||
|
||||
tags_data = ["production", "development", "backup", "docker", "monitoring", "critical"]
|
||||
|
||||
for tag_name in tags_data:
|
||||
cursor.execute("""
|
||||
INSERT INTO Tags (Name)
|
||||
VALUES (?)
|
||||
""", (tag_name,))
|
||||
print(f" ✓ Tag '{tag_name}' erstellt")
|
||||
|
||||
conn.commit()
|
||||
|
||||
# ============================================================================
|
||||
# Abschluss
|
||||
# ============================================================================
|
||||
print("\n" + "="*60)
|
||||
print("✅ Testdaten erfolgreich erstellt!")
|
||||
print("="*60)
|
||||
|
||||
# Statistiken ausgeben
|
||||
cursor.execute("SELECT COUNT(*) FROM Servers")
|
||||
server_count = cursor.fetchone()[0]
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM Containers")
|
||||
container_count = cursor.fetchone()[0]
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM Metrics")
|
||||
metrics_count = cursor.fetchone()[0]
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM ContainerMetrics")
|
||||
container_metrics_count = cursor.fetchone()[0]
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM LogEvents")
|
||||
log_count = cursor.fetchone()[0]
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM Images")
|
||||
image_count = cursor.fetchone()[0]
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM Tags")
|
||||
tag_count = cursor.fetchone()[0]
|
||||
|
||||
print(f"""
|
||||
📊 STATISTIK:
|
||||
🖥️ Server: {server_count}
|
||||
📦 Container: {container_count}
|
||||
📈 Server-Metriken: {metrics_count}
|
||||
📊 Container-Metriken: {container_metrics_count}
|
||||
📝 Log Events: {log_count}
|
||||
🐳 Images: {image_count}
|
||||
🏷️ Tags: {tag_count}
|
||||
|
||||
💡 HINWEIS:
|
||||
- User-Tabelle wurde nicht verändert
|
||||
- Metriken wurden für die letzten 48 Stunden generiert
|
||||
- Server 'Backup-Server' ist offline (für Tests)
|
||||
- Container 'dev-postgres' ist gestoppt (für Tests)
|
||||
- Die Datenbank befindet sich unter: {DB_PATH}
|
||||
""")
|
||||
|
||||
# Verbindung schließen
|
||||
conn.close()
|
||||
print("🔒 Datenbankverbindung geschlossen\n")
|
||||
@@ -1,19 +0,0 @@
|
||||
# Application Version
|
||||
# Bei lokalem Development wird "development" angezeigt, im Docker-Container die Image-Version
|
||||
WATCHER_VERSION=development
|
||||
|
||||
# Update Check
|
||||
# Überprüft täglich, ob eine neue Version verfügbar ist
|
||||
UPDATE_CHECK_ENABLED=true
|
||||
UPDATE_CHECK_INTERVAL_HOURS=24
|
||||
UPDATE_CHECK_REPOSITORY_URL=https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest
|
||||
|
||||
# Data Retention Policy
|
||||
# Wie lange sollen Metriken gespeichert werden (in Tagen)?
|
||||
METRIC_RETENTION_DAYS=30
|
||||
|
||||
# Wie oft soll der Cleanup-Prozess laufen (in Stunden)?
|
||||
METRIC_CLEANUP_INTERVAL_HOURS=24
|
||||
|
||||
# Soll der Cleanup-Service aktiviert sein?
|
||||
METRIC_CLEANUP_ENABLED=true
|
||||
@@ -27,6 +27,6 @@ public class ApiController : Controller
|
||||
public async Task<IActionResult> GetAllServers()
|
||||
{
|
||||
var Servers = await _context.Servers.OrderBy(s => s.Id).ToListAsync();
|
||||
return Ok();
|
||||
return Ok(Servers);
|
||||
}
|
||||
}
|
||||
@@ -19,14 +19,18 @@ namespace Watcher.Controllers
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
// Daten der Backgroundchecks abrufen
|
||||
private IDashboardStore _DashboardStore;
|
||||
private IDashboardStore _dashboardStore;
|
||||
|
||||
// System Store für Konfigurationen
|
||||
private ISystemStore _systemStore;
|
||||
|
||||
// HomeController Constructor
|
||||
public HomeController(AppDbContext context, ILogger<HomeController> logger, IDashboardStore dashboardStore)
|
||||
public HomeController(AppDbContext context, ILogger<HomeController> logger, IDashboardStore dashboardStore, ISystemStore systemStore)
|
||||
{
|
||||
_context = context;
|
||||
_logger = logger;
|
||||
_DashboardStore = dashboardStore;
|
||||
_dashboardStore = dashboardStore;
|
||||
_systemStore = systemStore;
|
||||
|
||||
}
|
||||
|
||||
@@ -58,8 +62,9 @@ namespace Watcher.Controllers
|
||||
Containers = await _context.Containers
|
||||
.OrderBy(s => s.Name)
|
||||
.ToListAsync(),
|
||||
NetworkStatus = _DashboardStore.NetworkStatus,
|
||||
DatabaseStatus = _DashboardStore.DatabaseStatus
|
||||
NetworkStatus = _dashboardStore.NetworkStatus,
|
||||
DatabaseStatus = _dashboardStore.DatabaseStatus,
|
||||
RefreshIntervalMilliseconds = _systemStore.FrontendRefreshIntervalMilliseconds
|
||||
};
|
||||
//ViewBag.NetworkConnection = _NetworkCheckStore.NetworkStatus;
|
||||
return View(viewModel);
|
||||
@@ -90,14 +95,14 @@ namespace Watcher.Controllers
|
||||
Containers = await _context.Containers
|
||||
.OrderBy(s => s.Name)
|
||||
.ToListAsync(),
|
||||
NetworkStatus = _DashboardStore.NetworkStatus,
|
||||
DatabaseStatus = _DashboardStore.DatabaseStatus
|
||||
NetworkStatus = _dashboardStore.NetworkStatus,
|
||||
DatabaseStatus = _dashboardStore.DatabaseStatus
|
||||
};
|
||||
|
||||
return PartialView("_DashboardStats", model);
|
||||
}
|
||||
|
||||
public String ReturnNetworkStatus()
|
||||
public string ReturnNetworkStatus()
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ public class MetricDto
|
||||
|
||||
public class DockerServiceDto
|
||||
{
|
||||
public required int Server_id { get; set; } // Vom Watcher-Server zugewiesene ID des Hosts
|
||||
public int Server_id { get; set; } // Vom Watcher-Server zugewiesene ID des Hosts (optional, falls der Agent diese bereits kennt)
|
||||
public string? IpAddress { get; set; } // IP-Adresse des Servers (wird verwendet, falls Server_id nicht gesetzt oder 0 ist)
|
||||
public required JsonElement Containers { get; set; }
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ public class MonitoringController : Controller
|
||||
}
|
||||
|
||||
|
||||
// Endpoint, an den der Agent seine Hardwareinformationen schickt
|
||||
// Endpoint, an den der Agent seine Hardwareinformationen schickt (Registrierung Schritt 2)
|
||||
[HttpPost("hardware-info")]
|
||||
public async Task<IActionResult> Register([FromBody] HardwareDto dto)
|
||||
{
|
||||
@@ -138,15 +139,19 @@ public class MonitoringController : Controller
|
||||
// Änderungen in Datenbank speichern
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
// Success
|
||||
// Success - Server-ID und IP-Adresse zurückgeben
|
||||
_logger.LogInformation("Agent für '{server}' erfolgreich registriert.", server.Name);
|
||||
return Ok();
|
||||
return Ok(new
|
||||
{
|
||||
id = server.Id,
|
||||
ipAddress = server.IPAddress
|
||||
});
|
||||
}
|
||||
_logger.LogError("Kein Server für Registrierung gefunden");
|
||||
return NotFound("No Matching Server found.");
|
||||
}
|
||||
|
||||
// Endpoint, an dem sich ein Agent initial registriert
|
||||
// Endpoint, an dem sich ein Agent seine ID abholt (Registrierung Schritt 1)
|
||||
[HttpGet("register")]
|
||||
public async Task<IActionResult> GetServerIdByIp([FromQuery] string IpAddress)
|
||||
{
|
||||
@@ -181,34 +186,38 @@ public class MonitoringController : Controller
|
||||
}
|
||||
|
||||
// Server in Datenbank finden
|
||||
var server = await _context.Servers
|
||||
.FirstOrDefaultAsync(s => s.IPAddress == dto.IpAddress);
|
||||
// DEBUG
|
||||
Console.WriteLine("RECEIVED ID ${ID}", dto.ServerId);
|
||||
Server? server = await _context.Servers.FirstOrDefaultAsync(s => s.Id == dto.ServerId);
|
||||
|
||||
// DEBUG
|
||||
Console.WriteLine("FOUND SERVER ${ServerName}", server.Name);
|
||||
|
||||
if (server != null)
|
||||
{
|
||||
// neues Metric-Objekt erstellen
|
||||
var NewMetric = new Metric
|
||||
var newMetric = new Metric
|
||||
{
|
||||
Timestamp = DateTime.UtcNow,
|
||||
ServerId = dto.ServerId,
|
||||
CPU_Load = sanitizeInput(dto.CPU_Load),
|
||||
CPU_Temp = sanitizeInput(dto.CPU_Temp),
|
||||
GPU_Load = sanitizeInput(dto.GPU_Load),
|
||||
GPU_Temp = sanitizeInput(dto.GPU_Temp),
|
||||
GPU_Vram_Size = calculateGigabyte(dto.GPU_Vram_Size),
|
||||
GPU_Vram_Usage = sanitizeInput(dto.GPU_Vram_Load),
|
||||
RAM_Load = sanitizeInput(dto.RAM_Load),
|
||||
RAM_Size = calculateGigabyte(dto.RAM_Size),
|
||||
DISK_Size = calculateGigabyte(dto.DISK_Size),
|
||||
DISK_Usage = calculateGigabyte(dto.DISK_Usage),
|
||||
DISK_Temp = sanitizeInput(dto.DISK_Temp),
|
||||
NET_In = calculateMegabit(dto.NET_In),
|
||||
NET_Out = calculateMegabit(dto.NET_Out)
|
||||
CPU_Load = SanitizeInput(dto.CPU_Load),
|
||||
CPU_Temp = SanitizeInput(dto.CPU_Temp),
|
||||
GPU_Load = SanitizeInput(dto.GPU_Load),
|
||||
GPU_Temp = SanitizeInput(dto.GPU_Temp),
|
||||
GPU_Vram_Size = CalculateGigabyte(dto.GPU_Vram_Size),
|
||||
GPU_Vram_Usage = SanitizeInput(dto.GPU_Vram_Load),
|
||||
RAM_Load = SanitizeInput(dto.RAM_Load),
|
||||
RAM_Size = CalculateGigabyte(dto.RAM_Size),
|
||||
DISK_Size = CalculateGigabyte(dto.DISK_Size),
|
||||
DISK_Usage = CalculateGigabyte(dto.DISK_Usage),
|
||||
DISK_Temp = SanitizeInput(dto.DISK_Temp),
|
||||
NET_In = CalculateMegabit(dto.NET_In),
|
||||
NET_Out = CalculateMegabit(dto.NET_Out)
|
||||
};
|
||||
try
|
||||
{
|
||||
// Metric Objekt in Datenbank einfügen
|
||||
_context.Metrics.Add(NewMetric);
|
||||
_context.Metrics.Add(newMetric);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
_logger.LogInformation("Monitoring-Daten für '{server}' empfangen", server.Name);
|
||||
@@ -244,45 +253,73 @@ public class MonitoringController : Controller
|
||||
return BadRequest(new { error = "Invalid Payload", details = errors });
|
||||
}
|
||||
|
||||
// Prüfen, ob der Server existiert
|
||||
var serverExists = await _context.Servers.AnyAsync(s => s.Id == dto.Server_id);
|
||||
if (!serverExists)
|
||||
// Debug-Logging für eingehende Requests
|
||||
_logger.LogDebug("Service-Discovery Request empfangen: Server_id={ServerId}, IpAddress={IpAddress}",
|
||||
dto.Server_id, dto.IpAddress ?? "null");
|
||||
|
||||
// Server anhand IP-Adresse oder ID finden
|
||||
Server? server = null;
|
||||
|
||||
// Zuerst versuchen, Server anhand der IP-Adresse zu finden (bevorzugte Methode)
|
||||
if (!string.IsNullOrEmpty(dto.IpAddress))
|
||||
{
|
||||
_logger.LogError($"Server with ID {dto.Server_id} does not exist.");
|
||||
return BadRequest(new { error = "Server not found", details = $"Server with ID {dto.Server_id} does not exist. Please register the server first." });
|
||||
server = await _context.Servers.FirstOrDefaultAsync(s => s.IPAddress == dto.IpAddress);
|
||||
}
|
||||
// Falls keine IP-Adresse übergeben wurde oder Server nicht gefunden, versuche es mit der ID
|
||||
else if (dto.Server_id > 0)
|
||||
{
|
||||
server = await _context.Servers.FirstOrDefaultAsync(s => s.Id == dto.Server_id);
|
||||
}
|
||||
|
||||
if (server == null)
|
||||
{
|
||||
_logger.LogError("Server with IP '{IpAddress}' or ID {ServerId} does not exist.", dto.IpAddress, dto.Server_id);
|
||||
return BadRequest(new { error = "Server not found", details = $"Server with IP '{dto.IpAddress}' or ID {dto.Server_id} does not exist. Please register the server first." });
|
||||
}
|
||||
|
||||
// Server ID für die weitere Verarbeitung setzen
|
||||
int serverId = server.Id;
|
||||
|
||||
List<Container> newContainers =
|
||||
JsonSerializer.Deserialize<List<Container>>(dto.Containers.GetRawText())
|
||||
?? new List<Container>();
|
||||
|
||||
foreach (Container c in newContainers)
|
||||
foreach (Container container in newContainers)
|
||||
{
|
||||
c.ServerId = dto.Server_id;
|
||||
container.ServerId = serverId;
|
||||
// Debug Logs
|
||||
// TODO entfernen wenn fertig getestet
|
||||
Console.WriteLine("---------");
|
||||
Console.WriteLine("ServerId: " + c.ServerId);
|
||||
Console.WriteLine("ContainerId: " + c.ContainerId);
|
||||
Console.WriteLine("Name: " + c.Name);
|
||||
Console.WriteLine("Image: " + c.Image);
|
||||
Console.WriteLine("ServerId: " + container.ServerId);
|
||||
Console.WriteLine("ContainerId: " + container.ContainerId);
|
||||
Console.WriteLine("Name: " + container.Name);
|
||||
Console.WriteLine("Image: " + container.Image);
|
||||
Console.WriteLine("---------");
|
||||
|
||||
}
|
||||
|
||||
// Liste aller Container, die bereits der übergebenen ServerId zugewiesen sind
|
||||
List<Container> existingContainers = _context.Containers
|
||||
.Where(c => c.ServerId == dto.Server_id)
|
||||
.Where(c => c.ServerId == serverId)
|
||||
.ToList();
|
||||
|
||||
|
||||
// Logik, um Container, die mit dem Payload kamen zu verarbeiten
|
||||
foreach (Container c in newContainers)
|
||||
foreach (Container container in newContainers)
|
||||
{
|
||||
// Überprüfen, ob ein übergebener Container bereits für den Host registriert ist
|
||||
if (existingContainers.Contains(c))
|
||||
// Wichtig: Vergleich über ContainerId, nicht über Objektreferenz!
|
||||
var existingContainer = existingContainers
|
||||
.FirstOrDefault(ec => ec.ContainerId == container.ContainerId);
|
||||
|
||||
if (existingContainer != null)
|
||||
{
|
||||
_logger.LogInformation("Container with id " + c.ContainerId + " already exists.");
|
||||
// Container existiert bereits, nur Daten aktualisieren falls sich etwas geändert hat
|
||||
existingContainer.Name = container.Name;
|
||||
existingContainer.Image = container.Image;
|
||||
existingContainer.IsRunning = true;
|
||||
|
||||
_logger.LogInformation("Container '{containerName}' (ID: {containerId}) already exists for Server {serverId}, updated.", container.Name, container.ContainerId, serverId);
|
||||
}
|
||||
// Container auf einen Host/Server registrieren
|
||||
else
|
||||
@@ -290,34 +327,41 @@ public class MonitoringController : Controller
|
||||
// Container in Datenbank einlesen
|
||||
try
|
||||
{
|
||||
_context.Containers.Add(c);
|
||||
_context.Containers.Add(container);
|
||||
await _context.SaveChangesAsync();
|
||||
_logger.LogInformation(c.Name + " added for Host " + c.ServerId);
|
||||
_logger.LogInformation("Container '{containerName}' (ID: {containerId}) added for Server {serverId}", container.Name, container.ContainerId, container.ServerId);
|
||||
}
|
||||
catch (SqliteException e)
|
||||
{
|
||||
_logger.LogError("Error writing new Containers to Database: " + e.Message);
|
||||
_logger.LogError("Error writing new Container '{containerName}' to Database: {error}", container.Name, e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Logik um abgeschaltene Container aus der Datenbank zu entfernen
|
||||
foreach (Container c in existingContainers)
|
||||
foreach (Container existingContainer in existingContainers)
|
||||
{
|
||||
// Abfrage, ob bereits vorhandener Container im Payload vorhanden war
|
||||
if (!newContainers.Contains(c))
|
||||
// Wichtig: Vergleich über ContainerId, nicht über Objektreferenz!
|
||||
var stillRunning = newContainers
|
||||
.Any(nc => nc.ContainerId == existingContainer.ContainerId);
|
||||
|
||||
if (!stillRunning)
|
||||
{
|
||||
// Container entfernen
|
||||
_context.Containers.Remove(c);
|
||||
_context.Containers.Remove(existingContainer);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
// Metrics für den Container entfernen
|
||||
//Todo
|
||||
|
||||
_logger.LogInformation("Container " + c.Name + " (" + c.Id + ") on Host-Id " + c.ServerId + " was successfully removed from the database.");
|
||||
_logger.LogInformation("Container '{containerName}' (DB-ID: {id}, ContainerID: {containerId}) on Server {serverId} was removed from the database.", existingContainer.Name, existingContainer.Id, existingContainer.ContainerId, existingContainer.ServerId);
|
||||
}
|
||||
}
|
||||
|
||||
// Alle Änderungen in einem Batch speichern
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Ok();
|
||||
|
||||
}
|
||||
@@ -377,6 +421,7 @@ public class MonitoringController : Controller
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("cpu-usage")]
|
||||
public async Task<IActionResult> GetCpuUsageData(int serverId, int hours = 1)
|
||||
{
|
||||
@@ -397,6 +442,7 @@ public class MonitoringController : Controller
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("ram-usage")]
|
||||
public async Task<IActionResult> GetRamUsageData(int serverId, int hours = 1)
|
||||
{
|
||||
@@ -417,6 +463,7 @@ public class MonitoringController : Controller
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("gpu-usage")]
|
||||
public async Task<IActionResult> GetGpuUsageData(int serverId, int hours = 1)
|
||||
{
|
||||
@@ -437,40 +484,67 @@ public class MonitoringController : Controller
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("current-metrics/{serverId}")]
|
||||
public async Task<IActionResult> GetCurrentMetrics(int serverId)
|
||||
{
|
||||
var latestMetric = await _context.Metrics
|
||||
.Where(m => m.ServerId == serverId)
|
||||
.OrderByDescending(m => m.Timestamp)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (latestMetric == null)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
cpu = 0.0,
|
||||
ram = 0.0,
|
||||
gpu = 0.0,
|
||||
hasData = false
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
cpu = latestMetric.CPU_Load,
|
||||
ram = latestMetric.RAM_Load,
|
||||
gpu = latestMetric.GPU_Load,
|
||||
hasData = true
|
||||
});
|
||||
}
|
||||
|
||||
// Metric Input Byte zu Gigabyte umwandeln
|
||||
public static double calculateGigabyte(double metric_input)
|
||||
public static double CalculateGigabyte(double metricInput)
|
||||
{
|
||||
// *10^-9 um auf Gigabyte zu kommen
|
||||
double calculatedValue = metric_input * Math.Pow(10, -9);
|
||||
double calculatedValue = metricInput * Math.Pow(10, -9);
|
||||
|
||||
// Auf 2 Nachkommastellen runden
|
||||
double calculatedValue_s = sanitizeInput(calculatedValue);
|
||||
double calculatedValueSanitized = SanitizeInput(calculatedValue);
|
||||
|
||||
return calculatedValue_s;
|
||||
return calculatedValueSanitized;
|
||||
}
|
||||
|
||||
// Metric Input Byte/s zu Megabit/s umrechnen
|
||||
//TODO
|
||||
public static double calculateMegabit(double metric_input)
|
||||
public static double CalculateMegabit(double metricInput)
|
||||
{
|
||||
// *10^-9 um auf Gigabyte zu kommen
|
||||
double calculatedValue = metric_input * Math.Pow(10, -9);
|
||||
double calculatedValue = metricInput * Math.Pow(10, -9);
|
||||
|
||||
// Auf 2 Nachkommastellen runden
|
||||
double calculatedValue_s = sanitizeInput(calculatedValue);
|
||||
double calculatedValueSanitized = SanitizeInput(calculatedValue);
|
||||
|
||||
return calculatedValue_s;
|
||||
return calculatedValueSanitized;
|
||||
}
|
||||
|
||||
// Degree Input auf zwei Nachkommastellen runden
|
||||
public static double sanitizeInput(double metric_input)
|
||||
public static double SanitizeInput(double metricInput)
|
||||
{
|
||||
Math.Round(metric_input, 2);
|
||||
|
||||
return metric_input;
|
||||
return Math.Round(metricInput, 2);
|
||||
}
|
||||
|
||||
private List<Container> ParseServiceDiscoveryInput(int server_id, List<Container> containers)
|
||||
private List<Container> ParseServiceDiscoveryInput(int serverId, List<Container> containers)
|
||||
{
|
||||
List<Container> containerList = new List<Container>();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Watcher.Data;
|
||||
using Watcher.Models;
|
||||
using Watcher.ViewModels;
|
||||
using Watcher.Services;
|
||||
|
||||
[Authorize]
|
||||
[Route("[controller]")]
|
||||
@@ -13,23 +14,27 @@ public class ServerController : Controller
|
||||
|
||||
private readonly ILogger<ServerController> _logger;
|
||||
|
||||
private readonly ISystemStore _systemStore;
|
||||
|
||||
public ServerController(AppDbContext context, ILogger<ServerController> logger)
|
||||
|
||||
public ServerController(AppDbContext context, ILogger<ServerController> logger, ISystemStore systemStore)
|
||||
{
|
||||
_context = context;
|
||||
_logger = logger;
|
||||
_systemStore = systemStore;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("Overview")]
|
||||
public async Task<IActionResult> Overview()
|
||||
{
|
||||
var vm = new ServerOverviewViewModel
|
||||
var viewModel = new ServerOverviewViewModel
|
||||
{
|
||||
Servers = await _context.Servers.OrderBy(s => s.Id).ToListAsync()
|
||||
Servers = await _context.Servers.OrderBy(s => s.Id).ToListAsync(),
|
||||
RefreshIntervalMilliseconds = _systemStore.FrontendRefreshIntervalMilliseconds
|
||||
};
|
||||
|
||||
return View(vm);
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,17 +47,17 @@ public class ServerController : Controller
|
||||
// POST: Server/AddServer
|
||||
[HttpPost("AddServer")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> AddServer(AddServerViewModel vm)
|
||||
public async Task<IActionResult> AddServer(AddServerViewModel viewModel)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return View(vm);
|
||||
return View(viewModel);
|
||||
|
||||
var server = new Server
|
||||
{
|
||||
Name = vm.Name,
|
||||
IPAddress = vm.IPAddress,
|
||||
Type = vm.Type,
|
||||
IsOnline = vm.IsOnline,
|
||||
Name = viewModel.Name,
|
||||
IPAddress = viewModel.IPAddress,
|
||||
Type = viewModel.Type,
|
||||
IsOnline = viewModel.IsOnline,
|
||||
};
|
||||
|
||||
_context.Servers.Add(server);
|
||||
@@ -91,25 +96,39 @@ public class ServerController : Controller
|
||||
var server = await _context.Servers.FindAsync(id);
|
||||
if (server == null) return NotFound();
|
||||
|
||||
var vm = new EditServerViewModel
|
||||
var viewModel = new EditServerViewModel
|
||||
{
|
||||
Name = server.Name,
|
||||
IPAddress = server.IPAddress,
|
||||
Type = server.Type
|
||||
Type = server.Type,
|
||||
CpuLoadWarning = server.CpuLoadWarning,
|
||||
CpuLoadCritical = server.CpuLoadCritical,
|
||||
CpuTempWarning = server.CpuTempWarning,
|
||||
CpuTempCritical = server.CpuTempCritical,
|
||||
RamLoadWarning = server.RamLoadWarning,
|
||||
RamLoadCritical = server.RamLoadCritical,
|
||||
GpuLoadWarning = server.GpuLoadWarning,
|
||||
GpuLoadCritical = server.GpuLoadCritical,
|
||||
GpuTempWarning = server.GpuTempWarning,
|
||||
GpuTempCritical = server.GpuTempCritical,
|
||||
DiskUsageWarning = server.DiskUsageWarning,
|
||||
DiskUsageCritical = server.DiskUsageCritical,
|
||||
DiskTempWarning = server.DiskTempWarning,
|
||||
DiskTempCritical = server.DiskTempCritical
|
||||
};
|
||||
|
||||
return View(vm);
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
|
||||
// POST: Server/Edit/5
|
||||
[HttpPost("EditServer/{id}")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> EditServer(int id, EditServerViewModel vm)
|
||||
public async Task<IActionResult> EditServer(int id, EditServerViewModel viewModel)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View(vm);
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
var server = await _context.Servers.FindAsync(id);
|
||||
@@ -118,9 +137,23 @@ public class ServerController : Controller
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
server.Name = vm.Name;
|
||||
server.IPAddress = vm.IPAddress;
|
||||
server.Type = vm.Type;
|
||||
server.Name = viewModel.Name;
|
||||
server.IPAddress = viewModel.IPAddress;
|
||||
server.Type = viewModel.Type;
|
||||
server.CpuLoadWarning = viewModel.CpuLoadWarning;
|
||||
server.CpuLoadCritical = viewModel.CpuLoadCritical;
|
||||
server.CpuTempWarning = viewModel.CpuTempWarning;
|
||||
server.CpuTempCritical = viewModel.CpuTempCritical;
|
||||
server.RamLoadWarning = viewModel.RamLoadWarning;
|
||||
server.RamLoadCritical = viewModel.RamLoadCritical;
|
||||
server.GpuLoadWarning = viewModel.GpuLoadWarning;
|
||||
server.GpuLoadCritical = viewModel.GpuLoadCritical;
|
||||
server.GpuTempWarning = viewModel.GpuTempWarning;
|
||||
server.GpuTempCritical = viewModel.GpuTempCritical;
|
||||
server.DiskUsageWarning = viewModel.DiskUsageWarning;
|
||||
server.DiskUsageCritical = viewModel.DiskUsageCritical;
|
||||
server.DiskTempWarning = viewModel.DiskTempWarning;
|
||||
server.DiskTempCritical = viewModel.DiskTempCritical;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -132,7 +165,7 @@ public class ServerController : Controller
|
||||
{
|
||||
_logger.LogError(ex, "Fehler beim Speichern des Servers");
|
||||
ModelState.AddModelError("", "Fehler beim Speichern");
|
||||
return View(vm);
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,27 +175,28 @@ public class ServerController : Controller
|
||||
public async Task<IActionResult> Details(int id)
|
||||
{
|
||||
|
||||
var s = await _context.Servers.FindAsync(id);
|
||||
if (s == null) return NotFound();
|
||||
var server = await _context.Servers.FindAsync(id);
|
||||
if (server == null) return NotFound();
|
||||
|
||||
var vm = new ServerDetailsViewModel
|
||||
var viewModel = new ServerDetailsViewModel
|
||||
{
|
||||
Id = s.Id,
|
||||
Name = s.Name,
|
||||
IPAddress = s.IPAddress,
|
||||
Type = s.Type,
|
||||
Description = s.Description,
|
||||
CpuType = s.CpuType,
|
||||
CpuCores = s.CpuCores,
|
||||
GpuType = s.GpuType,
|
||||
RamSize = s.RamSize,
|
||||
CreatedAt = s.CreatedAt,
|
||||
IsOnline = s.IsOnline,
|
||||
LastSeen = s.LastSeen,
|
||||
IsVerified = s.IsVerified
|
||||
Id = server.Id,
|
||||
Name = server.Name,
|
||||
IPAddress = server.IPAddress,
|
||||
Type = server.Type,
|
||||
Description = server.Description,
|
||||
CpuType = server.CpuType,
|
||||
CpuCores = server.CpuCores,
|
||||
GpuType = server.GpuType,
|
||||
RamSize = server.RamSize,
|
||||
CreatedAt = server.CreatedAt,
|
||||
IsOnline = server.IsOnline,
|
||||
LastSeen = server.LastSeen,
|
||||
IsVerified = server.IsVerified,
|
||||
RefreshIntervalMilliseconds = _systemStore.FrontendRefreshIntervalMilliseconds
|
||||
};
|
||||
|
||||
return View(vm);
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,6 +211,7 @@ public class ServerController : Controller
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
ViewBag.RefreshIntervalMilliseconds = _systemStore.FrontendRefreshIntervalMilliseconds;
|
||||
return PartialView("_ServerCard", servers);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,5 +41,19 @@ public class AppDbContext : DbContext
|
||||
optionsBuilder.UseSqlite(connStr);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
// Server IDs bei 0 starten lassen (statt Standard 1)
|
||||
modelBuilder.Entity<Server>()
|
||||
.Property(s => s.Id)
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
// SQLite-spezifische Konfiguration: AUTOINCREMENT startet bei 0
|
||||
modelBuilder.Entity<Server>()
|
||||
.ToTable(tb => tb.HasCheckConstraint("CK_Server_Id", "Id >= 0"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
392
Watcher/Migrations/20251116233330_RenameServerPropertiesToPascalCase.Designer.cs
generated
Normal file
392
Watcher/Migrations/20251116233330_RenameServerPropertiesToPascalCase.Designer.cs
generated
Normal file
@@ -0,0 +1,392 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Watcher.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20251116233330_RenameServerPropertiesToPascalCase")]
|
||||
partial class RenameServerPropertiesToPascalCase
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ContainerId")
|
||||
.HasColumnType("TEXT")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<string>("Image")
|
||||
.HasColumnType("TEXT")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "image");
|
||||
|
||||
b.Property<int?>("ImageId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsRunning")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "name");
|
||||
|
||||
b.Property<int>("ServerId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "Server_id");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ImageId");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.ContainerMetric", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CPU_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int?>("ContainerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("RAM_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ContainerMetrics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Tag")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Images");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("ContainerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Level")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContainerId");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("LogEvents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CPU_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Usage")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Vram_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Vram_Usage")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("NET_In")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("NET_Out")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Metrics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CpuCores")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CpuLoadCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CpuLoadWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CpuTempCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CpuTempWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("CpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("DiskSpace")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("DiskTempCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DiskTempWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DiskUsageCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DiskUsageWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuLoadCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuLoadWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuTempCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuTempWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("GpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("IPAddress")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("IsOnline")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsVerified")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("LastSeen")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("RamLoadCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RamLoadWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RamSize")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Servers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Tags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("LastLogin")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Image", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("ImageId");
|
||||
|
||||
b.HasOne("Watcher.Models.Server", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("TagId");
|
||||
|
||||
b.Navigation("Server");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Container", "Container")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContainerId");
|
||||
|
||||
b.HasOne("Watcher.Models.Server", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId");
|
||||
|
||||
b.Navigation("Container");
|
||||
|
||||
b.Navigation("Server");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Servers")
|
||||
.HasForeignKey("TagId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
|
||||
b.Navigation("Servers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RenameServerPropertiesToPascalCase : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "RAM_Load_Warning",
|
||||
table: "Servers",
|
||||
newName: "RamLoadWarning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "RAM_Load_Critical",
|
||||
table: "Servers",
|
||||
newName: "RamLoadCritical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "GPU_Temp_Warning",
|
||||
table: "Servers",
|
||||
newName: "GpuTempWarning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "GPU_Temp_Critical",
|
||||
table: "Servers",
|
||||
newName: "GpuTempCritical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "GPU_Load_Warning",
|
||||
table: "Servers",
|
||||
newName: "GpuLoadWarning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "GPU_Load_Critical",
|
||||
table: "Servers",
|
||||
newName: "GpuLoadCritical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Disk_Usage_Warning",
|
||||
table: "Servers",
|
||||
newName: "DiskUsageWarning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Disk_Usage_Critical",
|
||||
table: "Servers",
|
||||
newName: "DiskUsageCritical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "DISK_Temp_Warning",
|
||||
table: "Servers",
|
||||
newName: "DiskTempWarning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "DISK_Temp_Critical",
|
||||
table: "Servers",
|
||||
newName: "DiskTempCritical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "CPU_Temp_Warning",
|
||||
table: "Servers",
|
||||
newName: "CpuTempWarning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "CPU_Temp_Critical",
|
||||
table: "Servers",
|
||||
newName: "CpuTempCritical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "CPU_Load_Warning",
|
||||
table: "Servers",
|
||||
newName: "CpuLoadWarning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "CPU_Load_Critical",
|
||||
table: "Servers",
|
||||
newName: "CpuLoadCritical");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "RamLoadWarning",
|
||||
table: "Servers",
|
||||
newName: "RAM_Load_Warning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "RamLoadCritical",
|
||||
table: "Servers",
|
||||
newName: "RAM_Load_Critical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "GpuTempWarning",
|
||||
table: "Servers",
|
||||
newName: "GPU_Temp_Warning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "GpuTempCritical",
|
||||
table: "Servers",
|
||||
newName: "GPU_Temp_Critical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "GpuLoadWarning",
|
||||
table: "Servers",
|
||||
newName: "GPU_Load_Warning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "GpuLoadCritical",
|
||||
table: "Servers",
|
||||
newName: "GPU_Load_Critical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "DiskUsageWarning",
|
||||
table: "Servers",
|
||||
newName: "Disk_Usage_Warning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "DiskUsageCritical",
|
||||
table: "Servers",
|
||||
newName: "Disk_Usage_Critical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "DiskTempWarning",
|
||||
table: "Servers",
|
||||
newName: "DISK_Temp_Warning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "DiskTempCritical",
|
||||
table: "Servers",
|
||||
newName: "DISK_Temp_Critical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "CpuTempWarning",
|
||||
table: "Servers",
|
||||
newName: "CPU_Temp_Warning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "CpuTempCritical",
|
||||
table: "Servers",
|
||||
newName: "CPU_Temp_Critical");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "CpuLoadWarning",
|
||||
table: "Servers",
|
||||
newName: "CPU_Load_Warning");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "CpuLoadCritical",
|
||||
table: "Servers",
|
||||
newName: "CPU_Load_Critical");
|
||||
}
|
||||
}
|
||||
}
|
||||
395
Watcher/Migrations/20251117142850_StartServerIdsAtZero.Designer.cs
generated
Normal file
395
Watcher/Migrations/20251117142850_StartServerIdsAtZero.Designer.cs
generated
Normal file
@@ -0,0 +1,395 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Watcher.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20251117142850_StartServerIdsAtZero")]
|
||||
partial class StartServerIdsAtZero
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ContainerId")
|
||||
.HasColumnType("TEXT")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<string>("Image")
|
||||
.HasColumnType("TEXT")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "image");
|
||||
|
||||
b.Property<int?>("ImageId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsRunning")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "name");
|
||||
|
||||
b.Property<int>("ServerId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "Server_id");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ImageId");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.ContainerMetric", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CPU_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int?>("ContainerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("RAM_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ContainerMetrics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Tag")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Images");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("ContainerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Level")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContainerId");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("LogEvents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CPU_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Usage")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Vram_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Vram_Usage")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("NET_In")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("NET_Out")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Metrics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CpuCores")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CpuLoadCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CpuLoadWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CpuTempCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CpuTempWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("CpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("DiskSpace")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("DiskTempCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DiskTempWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DiskUsageCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DiskUsageWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuLoadCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuLoadWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuTempCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuTempWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("GpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("IPAddress")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("IsOnline")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsVerified")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("LastSeen")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("RamLoadCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RamLoadWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RamSize")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Servers", t =>
|
||||
{
|
||||
t.HasCheckConstraint("CK_Server_Id", "Id >= 0");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Tags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("LastLogin")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Image", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("ImageId");
|
||||
|
||||
b.HasOne("Watcher.Models.Server", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("TagId");
|
||||
|
||||
b.Navigation("Server");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Container", "Container")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContainerId");
|
||||
|
||||
b.HasOne("Watcher.Models.Server", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId");
|
||||
|
||||
b.Navigation("Container");
|
||||
|
||||
b.Navigation("Server");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Servers")
|
||||
.HasForeignKey("TagId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
|
||||
b.Navigation("Servers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Watcher/Migrations/20251117142850_StartServerIdsAtZero.cs
Normal file
35
Watcher/Migrations/20251117142850_StartServerIdsAtZero.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class StartServerIdsAtZero : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddCheckConstraint(
|
||||
name: "CK_Server_Id",
|
||||
table: "Servers",
|
||||
sql: "Id >= 0");
|
||||
|
||||
// Bestehende Server-IDs um 1 verringern (1 -> 0, 2 -> 1, etc.)
|
||||
migrationBuilder.Sql(@"
|
||||
UPDATE Servers SET Id = Id - 1;
|
||||
UPDATE Metrics SET ServerId = ServerId - 1 WHERE ServerId IS NOT NULL;
|
||||
UPDATE Containers SET ServerId = ServerId - 1 WHERE ServerId IS NOT NULL;
|
||||
UPDATE sqlite_sequence SET seq = seq - 1 WHERE name = 'Servers';
|
||||
");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropCheckConstraint(
|
||||
name: "CK_Server_Id",
|
||||
table: "Servers");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,55 +197,55 @@ namespace Watcher.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CPU_Load_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Load_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Temp_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Temp_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int>("CpuCores")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CpuLoadCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CpuLoadWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CpuTempCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CpuTempWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("CpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("DISK_Temp_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Temp_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("DiskSpace")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("Disk_Usage_Critical")
|
||||
b.Property<double>("DiskTempCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("Disk_Usage_Warning")
|
||||
b.Property<double>("DiskTempWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Load_Critical")
|
||||
b.Property<double>("DiskUsageCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Load_Warning")
|
||||
b.Property<double>("DiskUsageWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Temp_Critical")
|
||||
b.Property<double>("GpuLoadCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Temp_Warning")
|
||||
b.Property<double>("GpuLoadWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuTempCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GpuTempWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("GpuType")
|
||||
@@ -268,10 +268,10 @@ namespace Watcher.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("RAM_Load_Critical")
|
||||
b.Property<double>("RamLoadCritical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Load_Warning")
|
||||
b.Property<double>("RamLoadWarning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RamSize")
|
||||
@@ -288,7 +288,10 @@ namespace Watcher.Migrations
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Servers");
|
||||
b.ToTable("Servers", t =>
|
||||
{
|
||||
t.HasCheckConstraint("CK_Server_Id", "Id >= 0");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
|
||||
@@ -13,15 +13,15 @@ public class Container
|
||||
public Server Server { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public String? ContainerId { get; set; }
|
||||
public string? ContainerId { get; set; }
|
||||
|
||||
[JsonPropertyName("image")]
|
||||
public String? Image { get; set; }
|
||||
public string? Image { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public String? Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
// keine Variable, die vom Agent übergeben wird. Ein container ist immer Running, die Variable dient nur für die Übersicht
|
||||
// auf dem Dashboard.
|
||||
public Boolean IsRunning { get; set; } = true;
|
||||
public bool IsRunning { get; set; } = true;
|
||||
}
|
||||
|
||||
@@ -29,32 +29,32 @@ public class Server
|
||||
|
||||
|
||||
// Hardware Measurment Warning/Crit Values
|
||||
public double CPU_Load_Warning { get; set; } = 75.0;
|
||||
public double CPU_Load_Critical { get; set; } = 90.0;
|
||||
public double CPU_Temp_Warning { get; set; } = 80.0;
|
||||
public double CPU_Temp_Critical { get; set; } = 90.0;
|
||||
public double CpuLoadWarning { get; set; } = 75.0;
|
||||
public double CpuLoadCritical { get; set; } = 90.0;
|
||||
public double CpuTempWarning { get; set; } = 80.0;
|
||||
public double CpuTempCritical { get; set; } = 90.0;
|
||||
|
||||
public double RAM_Load_Warning { get; set; } = 85.0;
|
||||
public double RAM_Load_Critical { get; set; } = 95.0;
|
||||
public double RamLoadWarning { get; set; } = 85.0;
|
||||
public double RamLoadCritical { get; set; } = 95.0;
|
||||
|
||||
public double GPU_Load_Warning { get; set; } = 75.0;
|
||||
public double GPU_Load_Critical { get; set; } = 90.0;
|
||||
public double GPU_Temp_Warning { get; set; } = 70.0;
|
||||
public double GPU_Temp_Critical { get; set; } = 80.0;
|
||||
public double GpuLoadWarning { get; set; } = 75.0;
|
||||
public double GpuLoadCritical { get; set; } = 90.0;
|
||||
public double GpuTempWarning { get; set; } = 70.0;
|
||||
public double GpuTempCritical { get; set; } = 80.0;
|
||||
|
||||
public double Disk_Usage_Warning { get; set; } = 75.0;
|
||||
public double Disk_Usage_Critical { get; set; } = 90.0;
|
||||
public double DISK_Temp_Warning { get; set; } = 34.0;
|
||||
public double DISK_Temp_Critical { get; set; } = 36.0;
|
||||
public double DiskUsageWarning { get; set; } = 75.0;
|
||||
public double DiskUsageCritical { get; set; } = 90.0;
|
||||
public double DiskTempWarning { get; set; } = 34.0;
|
||||
public double DiskTempCritical { get; set; } = 36.0;
|
||||
|
||||
|
||||
// Database
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public Boolean IsOnline { get; set; } = false;
|
||||
public bool IsOnline { get; set; } = false;
|
||||
|
||||
public DateTime LastSeen { get; set; }
|
||||
|
||||
public Boolean IsVerified { get; set; } = false;
|
||||
public bool IsVerified { get; set; } = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -29,15 +29,33 @@ builder.Host.UseSerilog();
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
// Health Checks
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddDbContextCheck<AppDbContext>("database");
|
||||
|
||||
// HttpContentAccessor
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
|
||||
// Storage Singleton
|
||||
builder.Services.AddSingleton<IDashboardStore, DashboardStore>();
|
||||
builder.Services.AddSingleton<ISystemStore, SystemStore>();
|
||||
builder.Services.AddSingleton<IVersionService, VersionService>();
|
||||
builder.Services.AddSingleton<IUpdateCheckStore, UpdateCheckStore>();
|
||||
|
||||
// SystemStore mit Konfiguration initialisieren
|
||||
builder.Services.AddSingleton<ISystemStore>(sp =>
|
||||
{
|
||||
var configuration = sp.GetRequiredService<IConfiguration>();
|
||||
var refreshIntervalSeconds = int.TryParse(
|
||||
configuration["Frontend:RefreshIntervalSeconds"]
|
||||
?? Environment.GetEnvironmentVariable("FRONTEND_REFRESH_INTERVAL_SECONDS"),
|
||||
out var seconds) ? seconds : 30;
|
||||
|
||||
return new SystemStore
|
||||
{
|
||||
FrontendRefreshIntervalMilliseconds = refreshIntervalSeconds * 1000
|
||||
};
|
||||
});
|
||||
|
||||
// Background Services
|
||||
builder.Services.AddHostedService<NetworkCheck>();
|
||||
builder.Services.AddHostedService<DatabaseCheck>();
|
||||
@@ -145,6 +163,9 @@ app.UseSwaggerUI(options =>
|
||||
options.RoutePrefix = "api/v1/swagger";
|
||||
});
|
||||
|
||||
// 🔹 Health Check Endpoint
|
||||
app.MapHealthChecks("/health");
|
||||
|
||||
// 🔹 Authentifizierung & Autorisierung
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace Watcher.Services;
|
||||
|
||||
public class DashboardStore : IDashboardStore
|
||||
{
|
||||
public String? NetworkStatus { get; set; }
|
||||
public string? NetworkStatus { get; set; }
|
||||
|
||||
public String? DatabaseStatus { get; set; }
|
||||
public string? DatabaseStatus { get; set; }
|
||||
}
|
||||
@@ -21,14 +21,14 @@ public class DatabaseCheck : BackgroundService
|
||||
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||
{
|
||||
// Hintergrundprozess abwarten
|
||||
await checkDatabaseIntegrity();
|
||||
await CheckDatabaseIntegrity();
|
||||
// 5 Sekdunden Offset
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||
}
|
||||
}
|
||||
|
||||
// String sqliteConnectionString als Argument übergeben
|
||||
public Task checkDatabaseIntegrity()
|
||||
public Task CheckDatabaseIntegrity()
|
||||
{
|
||||
using var conn = new SqliteConnection("Data Source=./persistence/watcher.db");
|
||||
_logger.LogInformation("Sqlite Integrity-Check started...");
|
||||
|
||||
@@ -2,6 +2,6 @@ namespace Watcher.Services;
|
||||
|
||||
public interface IDashboardStore
|
||||
{
|
||||
String? NetworkStatus { get; set; }
|
||||
String? DatabaseStatus { get; set; }
|
||||
string? NetworkStatus { get; set; }
|
||||
string? DatabaseStatus { get; set; }
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ namespace Watcher.Services;
|
||||
|
||||
public interface ISystemStore
|
||||
{
|
||||
Boolean NewVersionAvailable { get; set; }
|
||||
bool NewVersionAvailable { get; set; }
|
||||
|
||||
Double DatabaseSize { get; set; }
|
||||
double DatabaseSize { get; set; }
|
||||
|
||||
int FrontendRefreshIntervalMilliseconds { get; set; }
|
||||
|
||||
}
|
||||
@@ -5,12 +5,12 @@ public class NetworkCheck : BackgroundService
|
||||
{
|
||||
private readonly ILogger<NetworkCheck> _logger;
|
||||
|
||||
private IDashboardStore _DashboardStore;
|
||||
private IDashboardStore _dashboardStore;
|
||||
|
||||
public NetworkCheck(ILogger<NetworkCheck> logger, IDashboardStore DashboardStore)
|
||||
public NetworkCheck(ILogger<NetworkCheck> logger, IDashboardStore dashboardStore)
|
||||
{
|
||||
_logger = logger;
|
||||
_DashboardStore = DashboardStore;
|
||||
_dashboardStore = dashboardStore;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ public class NetworkCheck : BackgroundService
|
||||
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||
{
|
||||
// Hintergrundprozess abwarten
|
||||
await checkConnectionAsync();
|
||||
await CheckConnectionAsync();
|
||||
|
||||
// 5 Sekdunden Offset
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||
}
|
||||
}
|
||||
|
||||
public Task checkConnectionAsync()
|
||||
public Task CheckConnectionAsync()
|
||||
{
|
||||
_logger.LogInformation("Networkcheck started.");
|
||||
|
||||
@@ -40,13 +40,13 @@ public class NetworkCheck : BackgroundService
|
||||
PingReply reply = p.Send(host, 3000);
|
||||
if (reply.Status == IPStatus.Success)
|
||||
{
|
||||
_DashboardStore.NetworkStatus = "online";
|
||||
_dashboardStore.NetworkStatus = "online";
|
||||
_logger.LogInformation("Ping successfull. Watcher is online.");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_DashboardStore.NetworkStatus = "offline";
|
||||
_dashboardStore.NetworkStatus = "offline";
|
||||
_logger.LogError("Ping failed. Watcher appears to have no network connection.");
|
||||
|
||||
// LogEvent erstellen
|
||||
|
||||
@@ -6,12 +6,12 @@ public class SystemManagement : BackgroundService
|
||||
{
|
||||
private readonly ILogger<NetworkCheck> _logger;
|
||||
|
||||
private ISystemStore _SystemStore;
|
||||
private ISystemStore _systemStore;
|
||||
|
||||
public SystemManagement(ILogger<NetworkCheck> logger, ISystemStore SystemStore)
|
||||
public SystemManagement(ILogger<NetworkCheck> logger, ISystemStore systemStore)
|
||||
{
|
||||
_logger = logger;
|
||||
_SystemStore = SystemStore;
|
||||
_systemStore = systemStore;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,19 +23,19 @@ public class SystemManagement : BackgroundService
|
||||
while (await timer.WaitForNextTickAsync(stoppingToken))
|
||||
{
|
||||
// Hintergrundprozess abwarten
|
||||
await checkForNewDockerImageVersion();
|
||||
await CheckForNewDockerImageVersion();
|
||||
|
||||
// 5 Sekdunden Offset
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||
}
|
||||
}
|
||||
|
||||
public Task checkForNewDockerImageVersion()
|
||||
public Task CheckForNewDockerImageVersion()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task createDailySqliteBackup()
|
||||
public Task CreateDailySqliteBackup()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ namespace Watcher.Services;
|
||||
|
||||
public class SystemStore: ISystemStore
|
||||
{
|
||||
public Boolean NewVersionAvailable { get; set; }
|
||||
public bool NewVersionAvailable { get; set; }
|
||||
|
||||
public Double DatabaseSize { get; set; }
|
||||
public double DatabaseSize { get; set; }
|
||||
|
||||
public int FrontendRefreshIntervalMilliseconds { get; set; }
|
||||
|
||||
}
|
||||
@@ -14,8 +14,10 @@ namespace Watcher.ViewModels
|
||||
public List<LogEvent> RecentEvents { get; set; } = new();
|
||||
public List<Container> Containers { get; set; } = new();
|
||||
|
||||
public String? NetworkStatus { get; set; } = "?";
|
||||
public String? DatabaseStatus { get; set; } = "?";
|
||||
public string? NetworkStatus { get; set; } = "?";
|
||||
public string? DatabaseStatus { get; set; } = "?";
|
||||
|
||||
public int RefreshIntervalMilliseconds { get; set; } = 30000;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,32 +7,32 @@ namespace Watcher.ViewModels
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Name ist erforderlich")]
|
||||
public string? Name { get; set; }
|
||||
public required string Name { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "IP-Adresse ist erforderlich")]
|
||||
[RegularExpression(@"^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$", ErrorMessage = "Ungültige IP-Adresse")]
|
||||
public required string IPAddress { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Typ ist erforderlich")]
|
||||
public string? Type { get; set; }
|
||||
public required string Type { get; set; }
|
||||
|
||||
// Hardware Measurment Warning/Crit Values
|
||||
public double CPU_Load_Warning { get; set; } = 75.0;
|
||||
public double CPU_Load_Critical { get; set; } = 90.0;
|
||||
public double CPU_Temp_Warning { get; set; } = 80.0;
|
||||
public double CPU_Temp_Critical { get; set; } = 90.0;
|
||||
public double CpuLoadWarning { get; set; } = 75.0;
|
||||
public double CpuLoadCritical { get; set; } = 90.0;
|
||||
public double CpuTempWarning { get; set; } = 80.0;
|
||||
public double CpuTempCritical { get; set; } = 90.0;
|
||||
|
||||
public double RAM_Load_Warning { get; set; } = 85.0;
|
||||
public double RAM_Load_Critical { get; set; } = 95.0;
|
||||
public double RamLoadWarning { get; set; } = 85.0;
|
||||
public double RamLoadCritical { get; set; } = 95.0;
|
||||
|
||||
public double GPU_Load_Warning { get; set; } = 75.0;
|
||||
public double GPU_Load_Critical { get; set; } = 90.0;
|
||||
public double GPU_Temp_Warning { get; set; } = 70.0;
|
||||
public double GPU_Temp_Critical { get; set; } = 80.0;
|
||||
public double GpuLoadWarning { get; set; } = 75.0;
|
||||
public double GpuLoadCritical { get; set; } = 90.0;
|
||||
public double GpuTempWarning { get; set; } = 70.0;
|
||||
public double GpuTempCritical { get; set; } = 80.0;
|
||||
|
||||
public double Disk_Usage_Warning { get; set; } = 75.0;
|
||||
public double Disk_Usage_Critical { get; set; } = 90.0;
|
||||
public double DISK_Temp_Warning { get; set; } = 34.0;
|
||||
public double DISK_Temp_Critical { get; set; } = 36.0;
|
||||
public double DiskUsageWarning { get; set; } = 75.0;
|
||||
public double DiskUsageCritical { get; set; } = 90.0;
|
||||
public double DiskTempWarning { get; set; } = 34.0;
|
||||
public double DiskTempCritical { get; set; } = 36.0;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Watcher.ViewModels;
|
||||
public class EditUserViewModel
|
||||
{
|
||||
[Required]
|
||||
public string? Username { get; set; }
|
||||
public required string Username { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataType(DataType.Password)]
|
||||
|
||||
@@ -31,9 +31,11 @@ public class ServerDetailsViewModel
|
||||
// Database
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public Boolean IsOnline { get; set; } = false;
|
||||
public bool IsOnline { get; set; } = false;
|
||||
|
||||
public DateTime LastSeen { get; set; }
|
||||
|
||||
public Boolean IsVerified { get; set; } = false;
|
||||
public bool IsVerified { get; set; } = false;
|
||||
|
||||
public int RefreshIntervalMilliseconds { get; set; } = 30000;
|
||||
}
|
||||
@@ -6,5 +6,6 @@ namespace Watcher.ViewModels
|
||||
public class ServerOverviewViewModel
|
||||
{
|
||||
public List<Server> Servers { get; set; } = new();
|
||||
public int RefreshIntervalMilliseconds { get; set; } = 30000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
foreach (var serverGroup in groupedContainers.OrderBy(g => g.Key))
|
||||
{
|
||||
<div class="mb-4">
|
||||
<h5 class="text-muted mb-3">
|
||||
<h5 class="text-text mb-3">
|
||||
<i class="bi bi-hdd-network me-2"></i>@serverGroup.Key
|
||||
<span class="badge bg-secondary ms-2">@serverGroup.Count()</span>
|
||||
</h5>
|
||||
@@ -90,7 +90,7 @@
|
||||
<i class="bi bi-chevron-down float-end"></i>
|
||||
</button>
|
||||
<div class="metrics-panel collapse" id="metrics-@container.Id">
|
||||
<div class="metrics-content mt-3 p-3 bg-light rounded">
|
||||
<div class="metrics-content mt-3 p-3 rounded">
|
||||
<div class="metric-item">
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<small><i class="bi bi-cpu me-1"></i>CPU</small>
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Initial laden und dann alle 30 Sekunden
|
||||
// Initial laden und dann mit konfiguriertem Intervall
|
||||
loadDashboardStats();
|
||||
setInterval(loadDashboardStats, 30000);
|
||||
setInterval(loadDashboardStats, @Model.RefreshIntervalMilliseconds);
|
||||
</script>
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="container mt-4">
|
||||
<!-- Server Overview Card -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center bg-white border-bottom">
|
||||
<div class="card-header d-flex justify-content-between align-items-center border-bottom">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-hdd-network me-2 text-primary"></i>@Model.Name
|
||||
</h5>
|
||||
@@ -231,8 +231,8 @@
|
||||
datasets: [{
|
||||
label: 'CPU Last (%)',
|
||||
data: [],
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.1)',
|
||||
borderColor: 'rgba(13, 202, 240, 1)',
|
||||
backgroundColor: 'rgba(13, 202, 240, 0.2)',
|
||||
borderWidth: 2,
|
||||
fill: true,
|
||||
tension: 0.4,
|
||||
@@ -284,8 +284,8 @@
|
||||
datasets: [{
|
||||
label: 'RAM Last (%)',
|
||||
data: [],
|
||||
borderColor: 'rgba(75, 192, 192, 1)',
|
||||
backgroundColor: 'rgba(75, 192, 192, 0.1)',
|
||||
borderColor: 'rgba(25, 135, 84, 1)',
|
||||
backgroundColor: 'rgba(25, 135, 84, 0.2)',
|
||||
borderWidth: 2,
|
||||
fill: true,
|
||||
tension: 0.4,
|
||||
@@ -337,8 +337,8 @@
|
||||
datasets: [{
|
||||
label: 'GPU Last (%)',
|
||||
data: [],
|
||||
borderColor: 'rgba(153, 102, 255, 1)',
|
||||
backgroundColor: 'rgba(153, 102, 255, 0.1)',
|
||||
borderColor: 'rgba(220, 53, 69, 1)',
|
||||
backgroundColor: 'rgba(220, 53, 69, 0.2)',
|
||||
borderWidth: 2,
|
||||
fill: true,
|
||||
tension: 0.4,
|
||||
@@ -480,10 +480,10 @@
|
||||
loadRamData();
|
||||
loadGpuData();
|
||||
|
||||
// Alle 30 Sekunden aktualisieren
|
||||
setInterval(loadCpuData, 30000);
|
||||
setInterval(loadRamData, 30000);
|
||||
setInterval(loadGpuData, 30000);
|
||||
// Mit konfiguriertem Intervall aktualisieren
|
||||
setInterval(loadCpuData, @Model.RefreshIntervalMilliseconds);
|
||||
setInterval(loadRamData, @Model.RefreshIntervalMilliseconds);
|
||||
setInterval(loadGpuData, @Model.RefreshIntervalMilliseconds);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@@ -54,32 +54,32 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="CPU_Load_Warning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
||||
<input asp-for="CPU_Load_Warning" class="form-control" placeholder="z.B. 80" />
|
||||
<span asp-validation-for="CPU_Load_Warning" class="text-danger small"></span>
|
||||
<label asp-for="CpuLoadWarning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
||||
<input asp-for="CpuLoadWarning" class="form-control" placeholder="z.B. 80" />
|
||||
<span asp-validation-for="CpuLoadWarning" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="CPU_Load_Critical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
||||
<input asp-for="CPU_Load_Critical" class="form-control" placeholder="z.B. 95" />
|
||||
<span asp-validation-for="CPU_Load_Critical" class="text-danger small"></span>
|
||||
<label asp-for="CpuLoadCritical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
||||
<input asp-for="CpuLoadCritical" class="form-control" placeholder="z.B. 95" />
|
||||
<span asp-validation-for="CpuLoadCritical" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="CPU_Temp_Warning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
||||
<input asp-for="CPU_Temp_Warning" class="form-control" placeholder="z.B. 75" />
|
||||
<span asp-validation-for="CPU_Temp_Warning" class="text-danger small"></span>
|
||||
<label asp-for="CpuTempWarning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
||||
<input asp-for="CpuTempWarning" class="form-control" placeholder="z.B. 75" />
|
||||
<span asp-validation-for="CpuTempWarning" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="CPU_Temp_Critical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
||||
<input asp-for="CPU_Temp_Critical" class="form-control" placeholder="z.B. 90" />
|
||||
<span asp-validation-for="CPU_Temp_Critical" class="text-danger small"></span>
|
||||
<label asp-for="CpuTempCritical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
||||
<input asp-for="CpuTempCritical" class="form-control" placeholder="z.B. 90" />
|
||||
<span asp-validation-for="CpuTempCritical" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -90,16 +90,16 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="RAM_Load_Warning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
||||
<input asp-for="RAM_Load_Warning" class="form-control" placeholder="z.B. 85" />
|
||||
<span asp-validation-for="RAM_Load_Warning" class="text-danger small"></span>
|
||||
<label asp-for="RamLoadWarning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
||||
<input asp-for="RamLoadWarning" class="form-control" placeholder="z.B. 85" />
|
||||
<span asp-validation-for="RamLoadWarning" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="RAM_Load_Critical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
||||
<input asp-for="RAM_Load_Critical" class="form-control" placeholder="z.B. 98" />
|
||||
<span asp-validation-for="RAM_Load_Critical" class="text-danger small"></span>
|
||||
<label asp-for="RamLoadCritical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
||||
<input asp-for="RamLoadCritical" class="form-control" placeholder="z.B. 98" />
|
||||
<span asp-validation-for="RamLoadCritical" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -110,32 +110,32 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="Disk_Usage_Warning" class="form-label"><i class="bi bi-disc-fill me-1"></i>Warnung bei Auslastung (%)</label>
|
||||
<input asp-for="Disk_Usage_Warning" class="form-control" placeholder="z.B. 90" />
|
||||
<span asp-validation-for="Disk_Usage_Warning" class="text-danger small"></span>
|
||||
<label asp-for="DiskUsageWarning" class="form-label"><i class="bi bi-disc-fill me-1"></i>Warnung bei Auslastung (%)</label>
|
||||
<input asp-for="DiskUsageWarning" class="form-control" placeholder="z.B. 90" />
|
||||
<span asp-validation-for="DiskUsageWarning" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="Disk_Usage_Critical" class="form-label"><i class="bi bi-disc-fill me-1"></i>Kritische Auslastung (%)</label>
|
||||
<input asp-for="Disk_Usage_Critical" class="form-control" placeholder="z.B. 98" />
|
||||
<span asp-validation-for="Disk_Usage_Critical" class="text-danger small"></span>
|
||||
<label asp-for="DiskUsageCritical" class="form-label"><i class="bi bi-disc-fill me-1"></i>Kritische Auslastung (%)</label>
|
||||
<input asp-for="DiskUsageCritical" class="form-control" placeholder="z.B. 98" />
|
||||
<span asp-validation-for="DiskUsageCritical" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="DISK_Temp_Warning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
||||
<input asp-for="DISK_Temp_Warning" class="form-control" placeholder="z.B. 45" />
|
||||
<span asp-validation-for="DISK_Temp_Warning" class="text-danger small"></span>
|
||||
<label asp-for="DiskTempWarning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
||||
<input asp-for="DiskTempWarning" class="form-control" placeholder="z.B. 45" />
|
||||
<span asp-validation-for="DiskTempWarning" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="DISK_Temp_Critical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
||||
<input asp-for="DISK_Temp_Critical" class="form-control" placeholder="z.B. 55" />
|
||||
<span asp-validation-for="DISK_Temp_Critical" class="text-danger small"></span>
|
||||
<label asp-for="DiskTempCritical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
||||
<input asp-for="DiskTempCritical" class="form-control" placeholder="z.B. 55" />
|
||||
<span asp-validation-for="DiskTempCritical" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -146,32 +146,32 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="GPU_Load_Warning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
||||
<input asp-for="GPU_Load_Warning" class="form-control" placeholder="z.B. 80" />
|
||||
<span asp-validation-for="GPU_Load_Warning" class="text-danger small"></span>
|
||||
<label asp-for="GpuLoadWarning" class="form-label"><i class="bi bi-graph-up me-1"></i>Warnung bei Auslastung (%)</label>
|
||||
<input asp-for="GpuLoadWarning" class="form-control" placeholder="z.B. 80" />
|
||||
<span asp-validation-for="GpuLoadWarning" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="GPU_Load_Critical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
||||
<input asp-for="GPU_Load_Critical" class="form-control" placeholder="z.B. 95" />
|
||||
<span asp-validation-for="GPU_Load_Critical" class="text-danger small"></span>
|
||||
<label asp-for="GpuLoadCritical" class="form-label"><i class="bi bi-graph-up me-1"></i>Kritische Auslastung (%)</label>
|
||||
<input asp-for="GpuLoadCritical" class="form-control" placeholder="z.B. 95" />
|
||||
<span asp-validation-for="GpuLoadCritical" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="GPU_Temp_Warning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
||||
<input asp-for="GPU_Temp_Warning" class="form-control" placeholder="z.B. 70" />
|
||||
<span asp-validation-for="GPU_Temp_Warning" class="text-danger small"></span>
|
||||
<label asp-for="GpuTempWarning" class="form-label"><i class="bi bi-thermometer-half me-1"></i>Warnung bei Temperatur (°C)</label>
|
||||
<input asp-for="GpuTempWarning" class="form-control" placeholder="z.B. 70" />
|
||||
<span asp-validation-for="GpuTempWarning" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label asp-for="GPU_Temp_Critical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
||||
<input asp-for="GPU_Temp_Critical" class="form-control" placeholder="z.B. 85" />
|
||||
<span asp-validation-for="GPU_Temp_Critical" class="text-danger small"></span>
|
||||
<label asp-for="GpuTempCritical" class="form-label"><i class="bi bi-thermometer-high me-1"></i>Kritische Temperatur (°C)</label>
|
||||
<input asp-for="GpuTempCritical" class="form-control" placeholder="z.B. 85" />
|
||||
<span asp-validation-for="GpuTempCritical" class="text-danger small"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,51 +1,189 @@
|
||||
@model IEnumerable<Watcher.Models.Server>
|
||||
|
||||
<div class="container py-4">
|
||||
<div class="row g-4">
|
||||
@foreach (var s in Model)
|
||||
<div class="row g-3">
|
||||
@foreach (var server in Model)
|
||||
{
|
||||
<div class="col-12">
|
||||
<div class="card h-100 border-secondary shadow-sm">
|
||||
<div class="card-body d-flex flex-column gap-3">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h5 class="card-title text-text mb-0">
|
||||
<i class="bi bi-pc-display me-2 text-text"></i>(#@s.Id) @s.Name
|
||||
</h5>
|
||||
|
||||
<div class="col-md-4 text-text small">
|
||||
<div><i class="bi bi-globe me-1"></i><strong>IP:</strong> @s.IPAddress</div>
|
||||
<div><i class="bi bi-pc-display me-1"></i><strong>Typ:</strong> @s.Type</div>
|
||||
<div class="col-12 col-lg-6 col-xl-4">
|
||||
<div class="card server-card shadow-sm">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<div class="d-flex align-items-center">
|
||||
<i class="bi bi-hdd-network me-2 text-primary"></i>
|
||||
<strong>@server.Name</strong>
|
||||
</div>
|
||||
|
||||
<span class="badge @(s.IsOnline ? "bg-success text-light" : "bg-danger text-light")">
|
||||
<i class="bi @(s.IsOnline ? "bi-check-circle" : "bi-x-circle") me-1"></i>
|
||||
@(s.IsOnline ? "Online" : "Offline")
|
||||
<span class="badge @(server.IsOnline ? "bg-success" : "bg-danger")">
|
||||
<i class="bi @(server.IsOnline ? "bi-check-circle" : "bi-x-circle")"></i>
|
||||
@(server.IsOnline ? "Online" : "Offline")
|
||||
</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<!-- Server Info -->
|
||||
<div class="server-info">
|
||||
<div class="info-row">
|
||||
<span class="info-label"><i class="bi bi-globe me-1"></i>IP:</span>
|
||||
<span class="info-value">@server.IPAddress</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label"><i class="bi bi-pc-display me-1"></i>Typ:</span>
|
||||
<span class="info-value">@server.Type</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label"><i class="bi bi-cpu me-1"></i>CPU:</span>
|
||||
<span class="info-value">@(server.CpuCores > 0 ? $"{server.CpuCores} Cores" : "N/A")</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label"><i class="bi bi-memory me-1"></i>RAM:</span>
|
||||
<span class="info-value">
|
||||
@if (server.RamSize > 0)
|
||||
{
|
||||
var ramGB = server.RamSize / (1024.0 * 1024.0 * 1024.0);
|
||||
@($"{ramGB:F1} GB")
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>N/A</text>
|
||||
}
|
||||
</span>
|
||||
<div class="d-flex flex-wrap gap-4">
|
||||
|
||||
<a asp-action="EditServer" asp-route-id="@s.Id" class="btn btn-outline-primary">
|
||||
<i class="bi bi-pencil-square me-1"></i> Bearbeiten
|
||||
</a>
|
||||
|
||||
<a asp-asp-controller="Server" asp-action="Details" asp-route-id="@s.Id"
|
||||
class="btn btn-outline-primary">
|
||||
<i class="bi bi-bar-chart-fill me-1"></i> Metrics
|
||||
</a>
|
||||
|
||||
<form asp-action="Delete" asp-controller="Server" asp-route-id="@s.Id" method="post"
|
||||
onsubmit="return confirm('Diesen Server wirklich löschen?');" class="m-0">
|
||||
<button type="submit" class="btn btn-outline-danger">
|
||||
<i class="bi bi-trash me-1"></i> Löschen
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Current Metrics (wenn online) -->
|
||||
@if (server.IsOnline)
|
||||
{
|
||||
<div class="mt-3 current-metrics">
|
||||
<h6 class="mb-2"><i class="bi bi-activity me-1"></i>Aktuelle Last</h6>
|
||||
<div class="metric-bars">
|
||||
<div class="metric-bar-item">
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<small>CPU</small>
|
||||
<small class="metric-value" data-server-id="@server.Id" data-metric="cpu">--</small>
|
||||
</div>
|
||||
<div class="progress" style="height: 6px;">
|
||||
<div class="progress-bar bg-info server-cpu-bar" role="progressbar" style="width: 0%"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="metric-bar-item mt-2">
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<small>RAM</small>
|
||||
<small class="metric-value" data-server-id="@server.Id" data-metric="ram">--</small>
|
||||
</div>
|
||||
<div class="progress" style="height: 6px;">
|
||||
<div class="progress-bar bg-success server-ram-bar" role="progressbar" style="width: 0%"></div>
|
||||
</div>
|
||||
</div>
|
||||
@if (!string.IsNullOrEmpty(server.GpuType))
|
||||
{
|
||||
<div class="metric-bar-item mt-2">
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<small>GPU</small>
|
||||
<small class="metric-value" data-server-id="@server.Id" data-metric="gpu">--</small>
|
||||
</div>
|
||||
<div class="progress" style="height: 6px;">
|
||||
<div class="progress-bar bg-danger server-gpu-bar" role="progressbar" style="width: 0%"></div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="action-buttons mt-3 d-flex gap-2">
|
||||
<a asp-action="Details" asp-route-id="@server.Id" class="btn btn-sm btn-outline-primary flex-fill">
|
||||
<i class="bi bi-bar-chart-fill"></i> Details
|
||||
</a>
|
||||
<button class="btn btn-sm btn-outline-warning flex-fill" onclick="rebootServer(@server.Id)">
|
||||
<i class="bi bi-arrow-clockwise"></i> Reboot
|
||||
</button>
|
||||
<a asp-action="EditServer" asp-route-id="@server.Id" class="btn btn-sm btn-outline-secondary flex-fill">
|
||||
<i class="bi bi-pencil"></i> Edit
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Delete Button (separate row) -->
|
||||
<div class="mt-2">
|
||||
<form asp-action="Delete" asp-route-id="@server.Id" method="post" class="m-0"
|
||||
onsubmit="return confirm('Server @server.Name wirklich löschen?');">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger w-100">
|
||||
<i class="bi bi-trash"></i> Server löschen
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function rebootServer(serverId) {
|
||||
if (confirm('Server wirklich neu starten?')) {
|
||||
console.log('Rebooting server:', serverId);
|
||||
// TODO: API Call zum Neustarten des Servers
|
||||
alert('Reboot-Funktion wird implementiert');
|
||||
}
|
||||
}
|
||||
|
||||
// Lade aktuelle Metriken für alle Server
|
||||
async function loadCurrentMetrics() {
|
||||
// Sammle alle eindeutigen Server-IDs
|
||||
const serverIds = new Set();
|
||||
document.querySelectorAll('.metric-value').forEach(el => {
|
||||
const serverId = el.getAttribute('data-server-id');
|
||||
if (serverId) serverIds.add(serverId);
|
||||
});
|
||||
|
||||
// Lade Metriken für jeden Server
|
||||
for (const serverId of serverIds) {
|
||||
try {
|
||||
const response = await fetch(`/monitoring/current-metrics/${serverId}`);
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
|
||||
if (data.hasData) {
|
||||
// Update CPU
|
||||
updateMetric(serverId, 'cpu', data.cpu, '.server-cpu-bar', 'bg-info');
|
||||
|
||||
// Update RAM
|
||||
updateMetric(serverId, 'ram', data.ram, '.server-ram-bar', 'bg-success');
|
||||
|
||||
// Update GPU (falls vorhanden)
|
||||
updateMetric(serverId, 'gpu', data.gpu, '.server-gpu-bar', 'bg-danger');
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Fehler beim Laden der Metriken für Server ${serverId}:`, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateMetric(serverId, metricType, value, barClass, defaultColorClass) {
|
||||
// Finde das Element für diesen Server und Metrik-Typ
|
||||
const metricElement = document.querySelector(`.metric-value[data-server-id="${serverId}"][data-metric="${metricType}"]`);
|
||||
if (!metricElement) return;
|
||||
|
||||
// Update Text
|
||||
metricElement.textContent = `${value.toFixed(1)}%`;
|
||||
|
||||
// Update Progress Bar
|
||||
const card = metricElement.closest('.card');
|
||||
const bar = card.querySelector(barClass);
|
||||
if (bar) {
|
||||
bar.style.width = `${value}%`;
|
||||
|
||||
// Optional: Farbe basierend auf Wert ändern
|
||||
bar.className = 'progress-bar';
|
||||
if (value >= 90) {
|
||||
bar.classList.add('bg-danger');
|
||||
} else if (value >= 75) {
|
||||
bar.classList.add('bg-warning');
|
||||
} else {
|
||||
bar.classList.add(defaultColorClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initial laden und mit konfiguriertem Intervall aktualisieren
|
||||
loadCurrentMetrics();
|
||||
const refreshInterval = @(ViewBag.RefreshIntervalMilliseconds ?? 30000);
|
||||
setInterval(loadCurrentMetrics, refreshInterval);
|
||||
</script>
|
||||
@@ -44,8 +44,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Initial laden und dann alle 30 Sekunden
|
||||
// Initial laden und dann mit konfiguriertem Intervall
|
||||
loadServerCards();
|
||||
setInterval(loadServerCards, 30000);
|
||||
setInterval(loadServerCards, @Model.RefreshIntervalMilliseconds);
|
||||
</script>
|
||||
}
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
<div>
|
||||
<strong>@User.Identity?.Name</strong><br />
|
||||
<small class="text-muted">Profil ansehen</small>
|
||||
<small style="color: var(--color-text);">Profil ansehen</small>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@@ -115,7 +115,7 @@
|
||||
}
|
||||
|
||||
<div class="mt-3 pt-3 border-top border-secondary text-center">
|
||||
<small style="color: #adb5bd;">
|
||||
<small style="color: var(--color-muted);">
|
||||
@{
|
||||
var statusColor = UpdateCheckStore.IsUpdateAvailable ? "#ffc107" : "#28a745";
|
||||
var statusTitle = UpdateCheckStore.IsUpdateAvailable
|
||||
@@ -123,7 +123,7 @@
|
||||
: "System ist aktuell";
|
||||
}
|
||||
<span style="display: inline-block; width: 8px; height: 8px; background-color: @statusColor; border-radius: 50%; margin-right: 8px;" title="@statusTitle"></span>
|
||||
<i class="bi bi-box me-1"></i>Version: <strong style="color: #fff;">@VersionService.GetVersion()</strong>
|
||||
<i class="bi bi-box me-1"></i>Version: <strong style="color: var(--color-primary);">@VersionService.GetVersion()</strong>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -12,107 +12,96 @@
|
||||
<link rel="stylesheet" href="~/css/settings.css" />
|
||||
</head>
|
||||
|
||||
<div class="Settingscontainer">
|
||||
<div class="container mt-4">
|
||||
<h1 class="mb-4">
|
||||
<i class="bi bi-gear-fill me-2"></i>Einstellungen
|
||||
</h1>
|
||||
|
||||
<div class="card shadow mt-5 p-4" style="width: 55%; margin: auto;">
|
||||
<h4><i class="bi bi-pencil-square me-2"></i>Systemeinformationen</h4>
|
||||
<!-- Systemeinformationen Card -->
|
||||
<div class="card settings-card shadow-sm mb-4">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-info-circle me-2"></i>Systemeinformationen
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<!-- System Info Table -->
|
||||
<div class="info-table">
|
||||
<div class="info-row">
|
||||
<div class="info-label">
|
||||
<i class="bi bi-tag me-2"></i>Version
|
||||
</div>
|
||||
<div class="info-value">@ServerVersion</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="info-row">
|
||||
<div class="info-label">
|
||||
<i class="bi bi-shield-lock me-2"></i>Authentifizierung
|
||||
</div>
|
||||
<div class="info-value">@(ViewBag.IdentityProvider ?? "nicht gefunden")</div>
|
||||
</div>
|
||||
|
||||
<h5>Watcher Version: @ServerVersion</h5>
|
||||
|
||||
<hr class="my-4" />
|
||||
|
||||
<h5>Authentifizierungsmethode: <strong>@(ViewBag.IdentityProvider ?? "nicht gefunden")</strong></h5>
|
||||
|
||||
|
||||
<hr class="my-4" />
|
||||
|
||||
<h5>Datenbank-Engine: <strong>@(DbEngine ?? "nicht gefunden")</strong></h5>
|
||||
<div class="info-row">
|
||||
<div class="info-label">
|
||||
<i class="bi bi-database me-2"></i>Datenbank-Engine
|
||||
</div>
|
||||
<div class="info-value">@(DbEngine ?? "nicht gefunden")</div>
|
||||
</div>
|
||||
|
||||
@if (ViewBag.DatabaseSize != null)
|
||||
{
|
||||
<h5>Datenbankgröße: <strong>@ViewBag.DatabaseSize</strong></h5>
|
||||
<div class="info-row">
|
||||
<div class="info-label">
|
||||
<i class="bi bi-hdd me-2"></i>Datenbankgröße
|
||||
</div>
|
||||
<div class="info-value">@ViewBag.DatabaseSize</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Falls Sqlite verwendet wird können Backups erstellt werden -->
|
||||
<!-- Datenbank-Backups Section -->
|
||||
@if (DbEngine == "SQLite" || DbEngine == "Microsoft.EntityFrameworkCore.Sqlite")
|
||||
{
|
||||
<div class="d-flex gap-2">
|
||||
<hr class="my-4" />
|
||||
<h6 class="mb-3">
|
||||
<i class="bi bi-archive me-2"></i>Datenbank-Backups
|
||||
</h6>
|
||||
<div class="backup-buttons">
|
||||
<form asp-action="CreateSqlDump" method="post" asp-controller="Database">
|
||||
<button type="submit" class="btn btn-db">
|
||||
<i class="bi bi-save me-1"></i> Backup erstellen
|
||||
<button type="submit" class="btn btn-outline-primary">
|
||||
<i class="bi bi-plus-circle me-2"></i>Backup erstellen
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form asp-action="ManageSqlDumps" method="post" asp-controller="Database">
|
||||
<button type="submit" class="btn btn-db">
|
||||
<i class="bi bi-save me-1"></i> Backups verwalten
|
||||
<button type="submit" class="btn btn-outline-primary">
|
||||
<i class="bi bi-folder2-open me-2"></i>Backups verwalten
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
}
|
||||
else if (DbEngine == "Microsoft.EntityFrameworkCore.MySQL")
|
||||
{
|
||||
<p> MySQL Dump aktuell nicht möglich </p>
|
||||
<hr class="my-4" />
|
||||
<div class="alert alert-info">
|
||||
<i class="bi bi-info-circle me-2"></i>MySQL Dump aktuell nicht möglich
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Status für Erstellung eines Backups -->
|
||||
<!-- Status Messages -->
|
||||
@if (TempData["DumpMessage"] != null)
|
||||
{
|
||||
<div class="alert alert-success">
|
||||
<i class="bi bi-check-circle me-1"></i>@TempData["DumpMessage"]
|
||||
<div class="alert alert-success mt-3">
|
||||
<i class="bi bi-check-circle me-2"></i>@TempData["DumpMessage"]
|
||||
</div>
|
||||
}
|
||||
@if (TempData["DumpError"] != null)
|
||||
{
|
||||
<div class="alert alert-danger">
|
||||
<i class="bi bi-exclamation-circle me-1"></i>@TempData["DumpError"]
|
||||
<div class="alert alert-danger mt-3">
|
||||
<i class="bi bi-exclamation-circle me-2"></i>@TempData["DumpError"]
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card shadow mt-5 p-4" style="width: 55%; margin: auto;">
|
||||
<h4><i class="bi bi-pencil-square me-2"></i>Benachrichtungen</h4>
|
||||
|
||||
<p>Registrierte E-Mail Adresse: <strong>@(ViewBag.mail ?? "nicht gefunden")</strong></p>
|
||||
|
||||
<!-- action="/Notification/UpdateSettings" existiert noch nicht-->
|
||||
<form method="post" action="#">
|
||||
<div class="card p-4 shadow-sm" style="max-width: 500px;">
|
||||
<h5 class="card-title mb-3">
|
||||
<i class="bi bi-bell me-2"></i>Benachrichtigungseinstellungen
|
||||
</h5>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="notifyOffline" name="NotifyOffline" checked>
|
||||
<label class="form-check-label" for="notifyOffline">Benachrichtigung bei Server-Offline</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="notifyUpdates" name="NotifyUpdates">
|
||||
<label class="form-check-label" for="notifyUpdates">Benachrichtigung bei neuen Updates</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="notifyUser" name="NotifyUser">
|
||||
<label class="form-check-label" for="notifyUser">Benachrichtigung bei neuen Benutzern</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="notifyMaintenance" name="NotifyMaintenance">
|
||||
<label class="form-check-label" for="notifyMaintenance">Wartungsinformationen erhalten</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-db mt-3">
|
||||
<i class="bi bi-save me-1"></i>Speichern
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr class="my-4" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
|
||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.3.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||
|
||||
@@ -12,5 +12,9 @@
|
||||
"ConnectionStrings": {
|
||||
"Sqlite": "Data Source=./persistence/watcher.db"
|
||||
}
|
||||
},
|
||||
|
||||
"Frontend": {
|
||||
"RefreshIntervalSeconds": 30
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
}
|
||||
|
||||
.form-error {
|
||||
color: #ff6b6b;
|
||||
color: var(--color-danger);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
@@ -14,16 +14,25 @@
|
||||
.info-label {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
color: #6c757d;
|
||||
color: var(--color-muted) !important;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 0.95rem;
|
||||
color: var(--color-text, #212529);
|
||||
font-weight: 400;
|
||||
padding-left: 1.25rem;
|
||||
color: var(--color-text, #f9feff) !important;
|
||||
}
|
||||
|
||||
/* All text within info-value should be visible */
|
||||
.info-value,
|
||||
.info-value *,
|
||||
.info-value span,
|
||||
.info-value .text-muted,
|
||||
.info-value .text-success {
|
||||
color: var(--color-text, #f9feff) !important;
|
||||
}
|
||||
|
||||
.info-value .text-muted {
|
||||
@@ -37,17 +46,23 @@
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text) !important;
|
||||
}
|
||||
|
||||
.card-body h6.text-muted i {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* Description and other text-muted paragraphs */
|
||||
.card-body p.text-muted {
|
||||
color: var(--color-text) !important;
|
||||
}
|
||||
|
||||
/* Graph Container */
|
||||
.graphcontainer {
|
||||
height: 25rem;
|
||||
width: 100%;
|
||||
background-color: var(--color-surface, #f8f9fa);
|
||||
background-color: var(--color-surface, #212121);
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/* Server Card Styling */
|
||||
.server-card {
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
border: 1px solid rgba(0, 0, 0, 0.125);
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.server-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
.server-card .card-header {
|
||||
background-color: var(--color-bg);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.server-card .card-body {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
/* Ensure all text in server-card uses light color */
|
||||
.server-card,
|
||||
.server-card * {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
/* Allow Bootstrap badge colors to work */
|
||||
.server-card .badge {
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Allow button colors to work */
|
||||
.server-card .btn {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* Server Info Rows */
|
||||
.server-info {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0.4rem 0;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.info-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
color: var(--color-muted);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* Current Metrics Section */
|
||||
.current-metrics h6 {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.metric-bar-item {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.metric-bar-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.progress {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
/* Action Buttons */
|
||||
.action-buttons .btn {
|
||||
font-size: 0.85rem;
|
||||
padding: 0.4rem 0.6rem;
|
||||
}
|
||||
|
||||
/* Responsive Adjustments */
|
||||
@media (max-width: 768px) {
|
||||
.action-buttons {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.action-buttons .btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Badge Styling */
|
||||
.badge {
|
||||
font-size: 0.75rem;
|
||||
padding: 0.35em 0.65em;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
.container-card {
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
border: 1px solid rgba(0, 0, 0, 0.125);
|
||||
background: var(--color-background-secondary, #fff);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
.container-card:hover {
|
||||
@@ -11,8 +11,8 @@
|
||||
}
|
||||
|
||||
.container-card .card-header {
|
||||
background-color: rgba(0, 0, 0, 0.03);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
|
||||
background-color: var(--color-bg);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
@@ -37,15 +37,24 @@
|
||||
}
|
||||
|
||||
.info-label {
|
||||
color: #6c757d;
|
||||
color: var(--color-muted);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
color: var(--color-text, #212529);
|
||||
color: var(--color-text, #f9feff);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.info-value a {
|
||||
color: var(--color-text);
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.info-value a:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
/* Action Buttons */
|
||||
.action-buttons .btn {
|
||||
font-size: 0.85rem;
|
||||
@@ -65,8 +74,8 @@
|
||||
}
|
||||
|
||||
.metrics-content {
|
||||
background-color: #f8f9fa !important;
|
||||
border: 1px solid #dee2e6;
|
||||
background-color: var(--color-bg) !important;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
@@ -110,6 +119,6 @@
|
||||
/* Server Group Header */
|
||||
h5.text-muted {
|
||||
font-weight: 600;
|
||||
border-bottom: 2px solid #dee2e6;
|
||||
border-bottom: 2px solid var(--color-accent);
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
@@ -1,24 +1,158 @@
|
||||
.Settingscontainer {
|
||||
/* Settings Card Styling - gleicher Stil wie Server Cards */
|
||||
.settings-card {
|
||||
background: var(--color-surface);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.settings-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
.settings-card .card-header {
|
||||
background-color: var(--color-bg);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.settings-card .card-header h5 {
|
||||
color: var(--color-text);
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.settings-card .card-body {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
/* Info Table Layout - ähnlich wie Server Info Rows */
|
||||
.info-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.75rem;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.info-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.info-row:hover {
|
||||
background-color: rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
|
||||
.info-label {
|
||||
color: var(--color-muted);
|
||||
font-weight: 500;
|
||||
font-size: 0.9rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.info-label i {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.info-value {
|
||||
color: var(--color-text);
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* Subsection Headers */
|
||||
.settings-card h6 {
|
||||
color: var(--color-text);
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
/* Backup Buttons */
|
||||
.backup-buttons {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
/* Wichtig: erlaubt Umbruch */
|
||||
gap: 1rem;
|
||||
/* optionaler Abstand */
|
||||
}
|
||||
|
||||
.Settingscontainer>* {
|
||||
flex: 1 1 calc(50% - 0.5rem);
|
||||
/* 2 Elemente pro Zeile, inkl. Gap */
|
||||
box-sizing: border-box;
|
||||
.backup-buttons form {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.btn-db {
|
||||
background-color: var(--color-primary);
|
||||
border: none;
|
||||
.backup-buttons .btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.btn-db:hover {
|
||||
background-color: var(--color-accent);
|
||||
border: none;
|
||||
/* Button Styling */
|
||||
.settings-card .btn {
|
||||
font-weight: 500;
|
||||
font-size: 0.85rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.settings-card .btn-outline-primary {
|
||||
border-color: var(--color-accent) !important;
|
||||
color: var(--color-accent) !important;
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
.settings-card .btn-outline-primary:hover {
|
||||
background-color: var(--color-accent) !important;
|
||||
border-color: var(--color-accent) !important;
|
||||
color: white !important;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.settings-card .btn-outline-primary:active,
|
||||
.settings-card .btn-outline-primary:focus,
|
||||
.settings-card .btn-outline-primary:focus-visible {
|
||||
background-color: var(--color-accent) !important;
|
||||
border-color: var(--color-accent) !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
/* HR Styling */
|
||||
.settings-card hr {
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
/* Alert Styling */
|
||||
.alert {
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 768px) {
|
||||
.info-row {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.backup-buttons {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.backup-buttons form {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
--color-text: #f9feff;
|
||||
--color-muted: #c0c0c0;
|
||||
--color-success: #14a44d;
|
||||
--color-success-hover: #0f8c3c;
|
||||
--color-danger: #ff6b6b;
|
||||
}
|
||||
|
||||
@@ -54,9 +55,30 @@ a {
|
||||
}
|
||||
|
||||
.btn-pocketid:hover {
|
||||
background-color: #0f8c3c;
|
||||
background-color: var(--color-success-hover);
|
||||
}
|
||||
|
||||
hr {
|
||||
border-top: 1px solid var(--color-accent);
|
||||
}
|
||||
|
||||
/* Bootstrap Overrides für Dark Theme */
|
||||
.text-muted {
|
||||
color: var(--color-muted) !important;
|
||||
}
|
||||
|
||||
.bg-light {
|
||||
background-color: var(--color-surface) !important;
|
||||
}
|
||||
|
||||
.text-text {
|
||||
color: var(--color-text) !important;
|
||||
}
|
||||
|
||||
.text-primary-emphasis {
|
||||
color: var(--color-primary) !important;
|
||||
}
|
||||
|
||||
.border-secondary {
|
||||
border-color: rgba(255, 255, 255, 0.2) !important;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
.table {
|
||||
color: red;
|
||||
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.picture {
|
||||
|
||||
@@ -2,26 +2,71 @@ services:
|
||||
watcher:
|
||||
image: git.triggermeelmo.com/watcher/watcher-server:${IMAGE_VERSION:-latest}
|
||||
container_name: watcher
|
||||
|
||||
# Resource Management
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 200M
|
||||
cpus: '0.5'
|
||||
reservations:
|
||||
memory: 100M
|
||||
cpus: '0.25'
|
||||
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
||||
|
||||
# Security
|
||||
user: "1000:1000"
|
||||
|
||||
# Health Check
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
# Environment
|
||||
environment:
|
||||
# Timezone
|
||||
- TZ=Europe/Berlin
|
||||
|
||||
# Application Version (wird aus Image-Tag übernommen)
|
||||
- WATCHER_VERSION=${IMAGE_VERSION:-latest}
|
||||
|
||||
# ASP.NET Core
|
||||
- ASPNETCORE_ENVIRONMENT=Production
|
||||
- ASPNETCORE_URLS=http://+:5000
|
||||
|
||||
# Update Check
|
||||
- UPDATE_CHECK_ENABLED=true
|
||||
- UPDATE_CHECK_INTERVAL_HOURS=24
|
||||
- UPDATE_CHECK_REPOSITORY_URL=https://git.triggermeelmo.com/api/v1/repos/Watcher/watcher/releases/latest
|
||||
|
||||
# Data Retention Policy
|
||||
- METRIC_RETENTION_DAYS=30
|
||||
- METRIC_CLEANUP_INTERVAL_HOURS=24
|
||||
- METRIC_CLEANUP_ENABLED=true
|
||||
|
||||
# Aktualisierungsrate Frontend
|
||||
- FRONTEND_REFRESH_INTERVAL_SECONDS=30
|
||||
|
||||
# Ports
|
||||
ports:
|
||||
- "5000:5000"
|
||||
|
||||
# Volumes
|
||||
volumes:
|
||||
- ./watcher-volumes/data:/app/persistence
|
||||
- ./watcher-volumes/dumps:/app/wwwroot/downloads/sqlite
|
||||
- ./watcher-volumes/logs:/app/logs
|
||||
- ./data/db:/app/persistence
|
||||
- ./data/dumps:/app/wwwroot/downloads/sqlite
|
||||
- ./data/logs:/app/logs
|
||||
|
||||
# Labels (Traefik Integration)
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.watcher.rule=Host(`watcher.example.com`)"
|
||||
- "traefik.http.routers.watcher.entrypoints=websecure"
|
||||
- "traefik.http.routers.watcher.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.services.watcher.loadbalancer.server.port=5000"
|
||||
- "com.watcher.description=Server Monitoring Application"
|
||||
- "com.watcher.version=${IMAGE_VERSION:-latest}"
|
||||
|
||||
Reference in New Issue
Block a user