Files
Sanders 465b27d673 ServerMonitor: Dockerized health-check service with Telegram alerts
- Pure stdlib Python (3.12), runs on python:3.12-alpine as non-root
- Checks: ping, HTTP (expected codes), TCP ports, Netdata alarms + metrics
- Netdata v2 compatible: system.cpu (no idle dim), system.ram, disk_space.* discovery
- AlertEngine dedup: first alert, reminders, recovery (only after real alert)
- Baseline first-run (no alert storm on deploy), atomic state file, --once mode
- 20 unit tests passing; verified live against 192.168.0.5
2026-08-05 22:28:20 +03:00

19 lines
466 B
Docker

FROM python:3.12-alpine
RUN adduser -D -u 10001 app
WORKDIR /app
COPY checks.py notify.py monitor.py config.json ./
RUN mkdir -p /data && chown -R app:app /data /app
USER app
ENV PYTHONUNBUFFERED=1
HEALTHCHECK --interval=60s --timeout=10s --retries=3 --start-period=30s \
CMD python -c "import os,time; p='/data/state.json'; raise SystemExit(0 if os.path.exists(p) and time.time()-os.path.getmtime(p)<300 else 1)"
CMD ["python", "-u", "/app/monitor.py"]