diff --git a/README.md b/README.md index b1e8882..7c5819f 100644 --- a/README.md +++ b/README.md @@ -82,4 +82,43 @@ Build-Schritt ist dafür nicht nötig. Details zur API: [api/README.md](api/README.md). Details zu den Endpunkten: [API.md](API.md). +--- + +## 🖥️ Einen Server zur Überwachung hinzufügen + +Der **System-Monitor** in der Büro-Visualisierung zeigt zunächst keine Kacheln an, solange +kein System gemeldet wurde — dafür gibt es zwei unabhängige Wege: + +**Weg 1: Klassische Ping-Überwachung (`hosts.conf`)** + +1. `hosts-sample.conf` nach `hosts.conf` kopieren und um den neuen Server erweitern + (eine Zeile pro Server, Format `Hostname IP`): + ``` + Webserver 192.168.178.10 + ``` +2. Optional, für E-Mail-Alarme bei Ausfall: `credentials-sample.conf` nach `credentials.conf` + kopieren und die SMTP-Zugangsdaten eintragen (wird von `mail_fds.py` benutzt). +3. `check_fds.sh` regelmäßig ausführen, z.B. per Cron alle paar Minuten. Das Skript pingt + jeden Eintrag aus `hosts.conf` dreimal an und schreibt das Ergebnis in `status.txt` (Pfad + über `STATUS_FILE` im Skript einstellbar). +4. Die API liest `status.txt` laufend mit und zeigt die Einträge als Systeme + (`source: "legacy"`) im System-Monitor an — ohne dass etwas neu gestartet werden muss. + +**Weg 2: Status direkt per REST-API melden** + +Eigene Server/Skripte können ihren Status auch ohne `hosts.conf` melden: + +1. Einen Agenten registrieren (liefert einmalig einen API-Key zurück, siehe + `register-agent.sh` bzw. [API.md](API.md#agenten)). +2. Mit diesem Key den Status senden: + ```bash + curl -X POST "$MONITOR_API_BASE/systems/mein-server/status" \ + -H "X-Api-Key: " \ + -H "Content-Type: application/json" \ + -d '{"status": "ok", "name": "Mein Server", "type": "host"}' + ``` + +So gemeldete Systeme (`source: "api"`) haben Vorrang vor dem Legacy-Import aus `status.txt` +und werden von ihm nicht überschrieben. Details zu Feldern/Auth: [API.md](API.md#systeme). + diff --git a/check_fds.sh b/check_fds.sh index 81d8db4..440ed3d 100755 --- a/check_fds.sh +++ b/check_fds.sh @@ -65,6 +65,9 @@ fi touch "$STATUS_FILE" while read -r line; do + case "$line" in + \#*|"") continue ;; + esac hostname=$(echo "$line" | awk '{print $1}') ip=$(echo "$line" | awk '{print $2}') if [ -n "$hostname" ] && [ -n "$ip" ]; then diff --git a/hosts-sample.conf b/hosts-sample.conf index b1c9183..52e0e8a 100644 --- a/hosts-sample.conf +++ b/hosts-sample.conf @@ -1,3 +1,5 @@ +# Nach hosts.conf kopieren und um eigene Server erweitern. +# Format: Hostname IP (ein Server pro Zeile, siehe README.md "Einen Server hinzufügen") Server1 192.168.178.2 Server2 192.168.178.3 Server3 192.168.178.4