From 282373b654d5c27787dd1b79d9a6e3c8f824c954 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Thu, 19 Dec 2024 18:10:15 +0000 Subject: [PATCH] Update server monitor criteria and request handling for accurate time tracking --- Common/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts | 2 +- ProbeIngest/API/ServerMonitor.ts | 3 +++ Worker/Jobs/ServerMonitor/CheckOnlineStatus.ts | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Common/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts b/Common/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts index 242992ab573..c8d92742e54 100644 --- a/Common/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts +++ b/Common/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts @@ -61,7 +61,7 @@ export default class ServerMonitorCriteria { input.criteriaFilter.evaluateOverTimeOptions ) { offlineIfNotCheckedInMinutes = - input.criteriaFilter.evaluateOverTimeOptions.timeValueInMinutes || 2; + input.criteriaFilter.evaluateOverTimeOptions.timeValueInMinutes || 3; } if ( diff --git a/ProbeIngest/API/ServerMonitor.ts b/ProbeIngest/API/ServerMonitor.ts index 0dd347e345d..38cf68e6938 100644 --- a/ProbeIngest/API/ServerMonitor.ts +++ b/ProbeIngest/API/ServerMonitor.ts @@ -15,6 +15,7 @@ import Express, { import MonitorResourceUtil from "Common/Server/Utils/Monitor/MonitorResource"; import Response from "Common/Server/Utils/Response"; import Monitor from "Common/Models/DatabaseModels/Monitor"; +import OneUptimeDate from "Common/Types/Date"; const router: ExpressRouter = Express.getRouter(); @@ -107,6 +108,8 @@ router.post( serverMonitorResponse.monitorId = monitor.id; + serverMonitorResponse.requestReceivedAt = OneUptimeDate.getCurrentDate(); + // process probe response here. const probeApiIngestResponse: ProbeApiIngestResponse = await MonitorResourceUtil.monitorResource(serverMonitorResponse); diff --git a/Worker/Jobs/ServerMonitor/CheckOnlineStatus.ts b/Worker/Jobs/ServerMonitor/CheckOnlineStatus.ts index 8a7f8bb8164..a7bd584d20a 100644 --- a/Worker/Jobs/ServerMonitor/CheckOnlineStatus.ts +++ b/Worker/Jobs/ServerMonitor/CheckOnlineStatus.ts @@ -16,7 +16,7 @@ RunCron( { schedule: EVERY_MINUTE, runOnStartup: false }, async () => { try { - const threeMinsAgo: Date = OneUptimeDate.getSomeMinutesAgo(3); + const threeMinsAgo: Date = OneUptimeDate.getSomeMinutesAgo(2); const serverMonitors: Array = await MonitorService.findBy({ query: {