From 92b4036c374b388b2608dcde76618842c965841f Mon Sep 17 00:00:00 2001 From: Username Date: Thu, 25 Dec 2025 18:48:27 +0100 Subject: [PATCH] proxywatchd: delay peak measurement until after startup --- proxywatchd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/proxywatchd.py b/proxywatchd.py index 2cc2a8c..4b8aa1e 100644 --- a/proxywatchd.py +++ b/proxywatchd.py @@ -302,9 +302,10 @@ class Stats(): self.last_history_tested = 0 self.last_history_passed = 0 - # Peak values + # Peak values (delayed measurement to avoid startup anomalies) self.peak_rate = 0.0 self.peak_success_rate = 0.0 + self.peak_grace_period = 30 # seconds before recording peaks self.min_latency = float('inf') self.max_latency = 0.0 @@ -423,7 +424,9 @@ class Stats(): self.rate_history.append(round(rate, 2)) if len(self.rate_history) > self.HISTORY_SIZE: self.rate_history.pop(0) - if rate > self.peak_rate and rate <= 100: + # Only record peaks after grace period (avoid startup anomalies) + uptime = now - self.start_time + if uptime >= self.peak_grace_period and rate > self.peak_rate and rate <= 100: self.peak_rate = rate # Success rate - with sanity checks @@ -436,7 +439,7 @@ class Stats(): self.success_rate_history.append(round(sr, 1)) if len(self.success_rate_history) > self.HISTORY_SIZE: self.success_rate_history.pop(0) - if sr > self.peak_success_rate: + if uptime >= self.peak_grace_period and sr > self.peak_success_rate: self.peak_success_rate = sr # Average latency for this interval