--json-Modus + Doku HTTP-Endpunkt (192.168.0.250:8090) und Homepage-customapi-Widget
This commit is contained in:
@ -26,3 +26,11 @@ Exit-Code 0 = alles ok, 1 = Auffälligkeiten (werden mit `!!` markiert).
|
|||||||
- apt: aktualisierbare Pakete
|
- apt: aktualisierbare Pakete
|
||||||
- pveproxy-Logs: externe IPs, Auth-Fehlversuche
|
- pveproxy-Logs: externe IPs, Auth-Fehlversuche
|
||||||
- proxi-healthcheck.timer aktiv
|
- proxi-healthcheck.timer aktiv
|
||||||
|
|
||||||
|
## JSON-Endpunkt auf proxi (fuer Homepage-Widget)
|
||||||
|
|
||||||
|
- Skript installiert als `/usr/local/bin/proxi-status.sh`; `--json` schreibt `/usr/local/share/proxi-status/status.json`
|
||||||
|
- Mini-HTTP-Endpunkt: `/usr/local/bin/proxi-status-http.py` als `proxi-status-http.service` auf **192.168.0.250:8090** — liefert `status.json` mit HTTP 200 (ok) bzw. 503 (Problem)
|
||||||
|
- Aktualisierung alle 5 Min. via `proxi-status-json.timer`
|
||||||
|
- Homepage-Widget (VM 105, `services.yaml`, Eintrag „Proxmox“):
|
||||||
|
`type: customapi`, `url: http://192.168.0.250:8090/status.json`, mappings auf `summary`/`warnings`
|
||||||
|
|||||||
@ -6,8 +6,11 @@
|
|||||||
# Exit-Code 0 = alles ok, 1 = Auffaelligkeiten gefunden.
|
# Exit-Code 0 = alles ok, 1 = Auffaelligkeiten gefunden.
|
||||||
|
|
||||||
WARN=0
|
WARN=0
|
||||||
|
WARNLIST=()
|
||||||
|
JSON=0
|
||||||
|
[ "$1" = "--json" ] && JSON=1
|
||||||
say() { printf '%s\n' "$*"; }
|
say() { printf '%s\n' "$*"; }
|
||||||
flag() { say "!! $*"; WARN=1; }
|
flag() { say "!! $*"; WARN=1; WARNLIST+=("$*"); }
|
||||||
|
|
||||||
say "=== proxi-status $(date '+%d.%m.%Y %H:%M:%S') ==="
|
say "=== proxi-status $(date '+%d.%m.%Y %H:%M:%S') ==="
|
||||||
|
|
||||||
@ -72,4 +75,21 @@ systemctl is-active proxi-healthcheck.timer >/dev/null 2>&1 || flag "proxi-healt
|
|||||||
|
|
||||||
say
|
say
|
||||||
if [ "$WARN" = "0" ]; then say "== ERGEBNIS: alles ok =="; else say "== ERGEBNIS: Auffaelligkeiten siehe '!!' =="; fi
|
if [ "$WARN" = "0" ]; then say "== ERGEBNIS: alles ok =="; else say "== ERGEBNIS: Auffaelligkeiten siehe '!!' =="; fi
|
||||||
|
|
||||||
|
if [ "$JSON" = "1" ]; then
|
||||||
|
OUT=/usr/local/share/proxi-status/status.json
|
||||||
|
mkdir -p "$(dirname "$OUT")"
|
||||||
|
{
|
||||||
|
printf '{"ok": %s, "ts": "%s", "summary": ' "$([ $WARN = 0 ] && echo true || echo false)" "$(date -Iseconds)"
|
||||||
|
if [ $WARN = 0 ]; then printf '"alles ok"'; else printf '"%d Auffaelligkeit(en)"' "${#WARNLIST[@]}"; fi
|
||||||
|
printf ', "warnings": ['
|
||||||
|
first=1
|
||||||
|
for w in "${WARNLIST[@]}"; do
|
||||||
|
[ $first = 1 ] || printf ', '
|
||||||
|
first=0
|
||||||
|
printf '"%s"' "$(printf '%s' "$w" | sed 's/"/\\"/g')"
|
||||||
|
done
|
||||||
|
printf ']}\n'
|
||||||
|
} > "$OUT.tmp" && mv "$OUT.tmp" "$OUT"
|
||||||
|
fi
|
||||||
exit $WARN
|
exit $WARN
|
||||||
|
|||||||
Reference in New Issue
Block a user