From d1e128b7d4035cc534e82231912e42e9378942cb Mon Sep 17 00:00:00 2001 From: SantosFC <33733406+SantosFC@users.noreply.github.com> Date: Sun, 7 Jun 2026 03:50:44 -0300 Subject: [PATCH] feat: incluir IPs e uptime do device no body do ping --- healthcheck.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/healthcheck.py b/healthcheck.py index d5f8f50..84546cf 100644 --- a/healthcheck.py +++ b/healthcheck.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import json import os +import subprocess import sys import urllib.request import urllib.error @@ -51,7 +52,21 @@ def main(): device = os.environ.get("DEVICE_NAME") or config.get("DEVICE_NAME", "unknown") timeout = int(os.environ.get("HEALTHCHECK_TIMEOUT", 10)) - body = json.dumps({"user": USER_NAME, "device": device}).encode() + try: + ips = subprocess.check_output(["hostname", "-I"], timeout=5).decode().split() + except Exception: + ips = [] + + try: + seconds = int(float(Path("/proc/uptime").read_text().split()[0])) + d, rem = divmod(seconds, 86400) + h, rem = divmod(rem, 3600) + m = rem // 60 + uptime = f"{d}d {h}h {m}m" + except Exception: + uptime = "unknown" + + body = json.dumps({"user": USER_NAME, "device": device, "ips": ips, "uptime": uptime}).encode() try: status = ping(url, body, timeout)