From 2a1e5f377c01fdf8e6be412572b0f0968316e3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= <12514511+RincewindsHat@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:51:47 +0200 Subject: [PATCH 1/2] CheckTimeSync: Let "IgnoreService" truly ignore the local service --- plugins/Invoke-IcingaCheckTimeSync.psm1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/Invoke-IcingaCheckTimeSync.psm1 b/plugins/Invoke-IcingaCheckTimeSync.psm1 index b62bc3da..d6c24ae2 100644 --- a/plugins/Invoke-IcingaCheckTimeSync.psm1 +++ b/plugins/Invoke-IcingaCheckTimeSync.psm1 @@ -89,9 +89,7 @@ function Invoke-IcingaCheckTimeSync() -MetricIndex $Server ` -MetricName 'service'; - if ($IgnoreService -eq $FALSE) { - $TimeCheck.CritIfNotMatch($ProviderEnums.ServiceStatus.Running) | Out-Null; - } + $TimeCheck.CritIfNotMatch($ProviderEnums.ServiceStatus.Running) | Out-Null; $SyncStatus = New-IcingaCheck ` -Name 'Sync Status' ` @@ -101,13 +99,15 @@ function Invoke-IcingaCheckTimeSync() $SyncStatus.CritIfMatch($ProviderEnums.TimeSyncStatus.ClockNotSynchronized) | Out-Null; + if ($IgnoreService) { + $checks = @($OffsetCheck, $SyncStatus) + } else { + $checks = @($OffsetCheck, $TimeCheck, $SyncStatus) + } + $CheckPackage = New-IcingaCheckPackage ` -Name 'Time Package' ` - -Checks @( - $OffsetCheck, - $TimeCheck, - $SyncStatus - ) ` + -Checks $checks ` -OperatorAnd ` -Verbose $Verbosity; From 070843ffff0676f56e22ed811f5b6f8e34851d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= <12514511+RincewindsHat@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:11:50 +0200 Subject: [PATCH 2/2] Declare variable in outer scope to make it available later --- plugins/Invoke-IcingaCheckTimeSync.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/Invoke-IcingaCheckTimeSync.psm1 b/plugins/Invoke-IcingaCheckTimeSync.psm1 index d6c24ae2..4f927a86 100644 --- a/plugins/Invoke-IcingaCheckTimeSync.psm1 +++ b/plugins/Invoke-IcingaCheckTimeSync.psm1 @@ -99,6 +99,7 @@ function Invoke-IcingaCheckTimeSync() $SyncStatus.CritIfMatch($ProviderEnums.TimeSyncStatus.ClockNotSynchronized) | Out-Null; + $checks = @() if ($IgnoreService) { $checks = @($OffsetCheck, $SyncStatus) } else {