diff options
author | Anton Tananaev <anton@traccar.org> | 2024-06-24 07:56:43 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-06-24 07:56:43 -0700 |
commit | 4e66d2b8dfbf362493905451cd8f6ca5655dddaa (patch) | |
tree | 06c3e5bfc85781ca377e6355fdeb09ea98f00889 /src | |
parent | 690f734e423a6ebe55b3bef5b7ac42cc734b664f (diff) | |
download | trackermap-server-4e66d2b8dfbf362493905451cd8f6ca5655dddaa.tar.gz trackermap-server-4e66d2b8dfbf362493905451cd8f6ca5655dddaa.tar.bz2 trackermap-server-4e66d2b8dfbf362493905451cd8f6ca5655dddaa.zip |
Handle zero stored messages
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/schedule/TaskHealthCheck.java | 10 |
1 files changed, 5 insertions, 5 deletions
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(); |