From 06e1d683b3822e76391422d8c9f9e229f7f124e4 Mon Sep 17 00:00:00 2001 From: Antoine Van Elstraete Date: Mon, 26 Jan 2026 19:38:37 +0100 Subject: [PATCH] Fix ping latency to use actual RTT instead of subprocess time Parse the real RTT from ping output instead of measuring subprocess execution time, which included process startup overhead. Co-Authored-By: Claude Opus 4.5 --- checkers/ping.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/checkers/ping.py b/checkers/ping.py index 20c2326..ebd3939 100644 --- a/checkers/ping.py +++ b/checkers/ping.py @@ -4,8 +4,8 @@ Checker Ping. Vérifie la disponibilité d'un hôte via ICMP ping. """ +import re import subprocess -import time import platform from .base import BaseChecker, CheckResult @@ -41,7 +41,6 @@ class PingChecker(BaseChecker): else: cmd = ["ping", "-c", str(count), "-W", str(timeout), host] - start = time.time() try: result = subprocess.run( cmd, @@ -49,9 +48,12 @@ class PingChecker(BaseChecker): text=True, timeout=timeout + 5 ) - response_time = (time.time() - start) * 1000 # ms if result.returncode == 0: + # Parse RTT from ping output (e.g., "time=0.32 ms" or "time=0.32ms") + match = re.search(r"time[=<]([\d.]+)\s*ms", result.stdout) + response_time = float(match.group(1)) if match else None + return CheckResult( success=True, message="Host is reachable",