Initial commit: server-monitor v1 (Python)

Kompletter Neustart als Python-Projekt.
Portiert von zfs-monitor Bash v3, saubere Architektur:
- config.py: TOML-Config mit dataclasses
- state.py: zentrales State-Management (JSON statt Einzeldateien)
- notify.py: Telegram + Persistent Alerting als wiederverwendbare Klasse
- checks/zfs.py: ZFS Pool-Health, I/O-Fehler, Kapazität
- checks/smart.py: SATA + NVMe SMART-Monitoring
- checks/nut.py: NUT/USV-Monitoring (APC Back-UPS RS 1500G)
This commit is contained in:
2026-04-12 04:15:02 +02:00
commit c756195530
14 changed files with 1096 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/bin/bash
# server-monitor install.sh
set -euo pipefail
INSTALL_DIR="/usr/local/lib/server-monitor"
CONFIG_DST="/etc/server-monitor.toml"
echo "==> Abhängigkeiten installieren..."
apt-get install -y --no-install-recommends smartmontools curl nut-client python3
echo "==> Skripte installieren nach ${INSTALL_DIR}..."
mkdir -p "$INSTALL_DIR/checks"
cp monitor.py config.py state.py notify.py "$INSTALL_DIR/"
cp checks/*.py "$INSTALL_DIR/checks/"
chmod +x "${INSTALL_DIR}/monitor.py"
echo "==> Verzeichnisse anlegen..."
mkdir -p /var/log/server-monitor /var/lib/server-monitor
echo "==> Config installieren..."
if [[ -f "$CONFIG_DST" ]]; then
echo " Config existiert bereits wird nicht überschrieben."
else
cp server-monitor.toml "$CONFIG_DST"
echo " ⚠️ Bitte Token + Chat-ID eintragen in: ${CONFIG_DST}"
fi
echo "==> systemd Units installieren..."
cp systemd/server-monitor.service /etc/systemd/system/
cp systemd/server-monitor.timer /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now server-monitor.timer
echo ""
echo "✅ Fertig! Status prüfen:"
echo " systemctl status server-monitor.timer"
echo " journalctl -u server-monitor.service -f"