From 4e66d2b8dfbf362493905451cd8f6ca5655dddaa Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 24 Jun 2024 07:56:43 -0700 Subject: Handle zero stored messages --- src/main/java/org/traccar/schedule/TaskHealthCheck.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/schedule/TaskHealthCheck.java b/src/main/java/org/traccar/schedule/TaskHealthCheck.java index b3387eca7..56ac4b91d 100644 --- a/src/main/java/org/traccar/schedule/TaskHealthCheck.java +++ b/src/main/java/org/traccar/schedule/TaskHealthCheck.java @@ -97,17 +97,17 @@ public class TaskHealthCheck implements ScheduleTask { LOGGER.warn("Web health check failed with status {}", status); } - if (dropThreshold > 0) { - int messageCurrentTotal = statisticsManager.messageStoredCount(); - int messageCurrentPeriod = messageCurrentTotal - messageLastTotal; + int messageCurrentTotal = statisticsManager.messageStoredCount(); + int messageCurrentPeriod = messageCurrentTotal - messageLastTotal; + if (dropThreshold > 0 && messageLastPeriod > 0) { double drop = messageCurrentPeriod / (double) messageLastPeriod; if (drop < dropThreshold) { success = false; LOGGER.warn("Message health check failed with drop {}", drop); } - messageLastTotal = messageCurrentTotal; - messageLastPeriod = messageCurrentPeriod; } + messageLastTotal = messageCurrentTotal; + messageLastPeriod = messageCurrentPeriod; if (success) { notifyWatchdog(); -- cgit v1.2.3