diff --git a/Common/Server/Utils/Monitor/Criteria/CompareCriteria.ts b/Common/Server/Utils/Monitor/Criteria/CompareCriteria.ts index 2cc1321eff..3ad83ede34 100644 --- a/Common/Server/Utils/Monitor/Criteria/CompareCriteria.ts +++ b/Common/Server/Utils/Monitor/Criteria/CompareCriteria.ts @@ -31,6 +31,8 @@ export default class CompareCriteria { value: boolean | Array; evaluationType?: EvaluateOverTimeType | undefined; }): boolean { + logger.debug(`isTrue: ${JSON.stringify(data)}`); + if (Array.isArray(data.value)) { if (data.evaluationType === EvaluateOverTimeType.AnyValue) { return data.value.some((value: boolean) => { @@ -49,6 +51,8 @@ export default class CompareCriteria { value: boolean | Array; evaluationType?: EvaluateOverTimeType | undefined; }): boolean { + logger.debug(`isFalse: ${JSON.stringify(data)}`); + if (Array.isArray(data.value)) { if (data.evaluationType === EvaluateOverTimeType.AnyValue) { return data.value.some((value: boolean) => { @@ -304,6 +308,8 @@ export default class CompareCriteria { value: Array | boolean; criteriaFilter: CriteriaFilter; }): string | null { + logger.debug(`compareCriteriaBoolean: ${JSON.stringify(data)}`); + if (data.value === null || data.value === undefined) { return null; } diff --git a/Common/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts b/Common/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts index 09ced784ba..932cc60798 100644 --- a/Common/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts +++ b/Common/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts @@ -12,6 +12,7 @@ import { import ServerMonitorResponse, { ServerProcess, } from "Common/Types/Monitor/ServerMonitor/ServerMonitorResponse"; +import logger from "../../Logger"; export default class ServerMonitorCriteria { public static async isMonitorInstanceCriteriaFilterMet(input: { @@ -64,18 +65,31 @@ export default class ServerMonitorCriteria { input.criteriaFilter.evaluateOverTimeOptions.timeValueInMinutes || 3; } + logger.debug("Server Monitor Criteria Filter"); + logger.debug(`Monitor ID: ${input.dataToProcess.monitorId}`); + logger.debug(`Check On: ${input.criteriaFilter.checkOn}`); + logger.debug(`Difference in Minutes: ${differenceInMinutes}`); + logger.debug( + `Offline if not checked in minutes: ${offlineIfNotCheckedInMinutes}`, + ); + if ( input.criteriaFilter.checkOn === CheckOn.IsOnline && differenceInMinutes >= offlineIfNotCheckedInMinutes ) { - const currentIsOnline: boolean | Array = (overTimeValue as Array) || false; // false because no request receieved in the last 2 minutes - return CompareCriteria.compareCriteriaBoolean({ + logger.debug(`Current Is Online: ${currentIsOnline}`); + + const criteria: string | null = CompareCriteria.compareCriteriaBoolean({ value: currentIsOnline, criteriaFilter: input.criteriaFilter, }); + + logger.debug(`Criteria: ${criteria}`); + + return criteria; } if ( @@ -85,10 +99,16 @@ export default class ServerMonitorCriteria { const currentIsOnline: boolean | Array = (overTimeValue as Array) || true; // true because request receieved in the last 2 minutes - return CompareCriteria.compareCriteriaBoolean({ + logger.debug(`Current Is Online: ${currentIsOnline}`); + + const criteria: string | null = CompareCriteria.compareCriteriaBoolean({ value: currentIsOnline, criteriaFilter: input.criteriaFilter, }); + + logger.debug(`Criteria: ${criteria}`); + + return criteria; } if ( diff --git a/Common/Server/Utils/Monitor/MonitorResource.ts b/Common/Server/Utils/Monitor/MonitorResource.ts index 916cf4ccb9..36c83e6d4c 100644 --- a/Common/Server/Utils/Monitor/MonitorResource.ts +++ b/Common/Server/Utils/Monitor/MonitorResource.ts @@ -418,7 +418,7 @@ export default class MonitorResourceUtil { logger.debug( `${dataToProcess.monitorId.toString()} - Processing monitor step...`, ); - + response = await MonitorResourceUtil.processMonitorStep({ dataToProcess: dataToProcess, monitorStep: monitorStep, diff --git a/Worker/Jobs/ServerMonitor/CheckOnlineStatus.ts b/Worker/Jobs/ServerMonitor/CheckOnlineStatus.ts index fb00b2d0f3..a9c3de777a 100644 --- a/Worker/Jobs/ServerMonitor/CheckOnlineStatus.ts +++ b/Worker/Jobs/ServerMonitor/CheckOnlineStatus.ts @@ -54,7 +54,9 @@ RunCron( monitorId: monitor.id!, onlyCheckRequestReceivedAt: true, requestReceivedAt: - monitor.serverMonitorRequestReceivedAt || monitor.serverMonitorResponse?.requestReceivedAt || monitor.createdAt!, + monitor.serverMonitorRequestReceivedAt || + monitor.serverMonitorResponse?.requestReceivedAt || + monitor.createdAt!, hostname: monitor.serverMonitorResponse?.hostname || "", };