From a90edb5d6bef256e7d88959222ab02b071165762 Mon Sep 17 00:00:00 2001 From: lordmilko Date: Mon, 20 Nov 2017 20:57:07 +1100 Subject: [PATCH] Fixed a bug wherein Restart-Probe wouldn't completely ignore probes that were already disconnected --- .../ObjectTests/PowerShell/Progress.Tests.ps1 | 2 +- .../PowerShell/Cmdlets/ObjectManipulation/RestartProbe.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/PrtgAPI.Tests.UnitTests/ObjectTests/PowerShell/Progress.Tests.ps1 b/PrtgAPI.Tests.UnitTests/ObjectTests/PowerShell/Progress.Tests.ps1 index ac39a4eb..4aa868c4 100644 --- a/PrtgAPI.Tests.UnitTests/ObjectTests/PowerShell/Progress.Tests.ps1 +++ b/PrtgAPI.Tests.UnitTests/ObjectTests/PowerShell/Progress.Tests.ps1 @@ -7879,7 +7879,7 @@ Describe "Test-Progress" -Tag @("PowerShell", "UnitTest") { )) } - It "100b2: Variable -> Get-SensorFactorySource | Channel" { + It "100b2: Variable -> Get-SensorFactorySource -> Channel" { $sensors = Get-Sensor -Count 2 diff --git a/PrtgAPI/PowerShell/Cmdlets/ObjectManipulation/RestartProbe.cs b/PrtgAPI/PowerShell/Cmdlets/ObjectManipulation/RestartProbe.cs index 61eaaeb5..a83ddd2f 100644 --- a/PrtgAPI/PowerShell/Cmdlets/ObjectManipulation/RestartProbe.cs +++ b/PrtgAPI/PowerShell/Cmdlets/ObjectManipulation/RestartProbe.cs @@ -159,9 +159,11 @@ private void UpdateProbeStatus(List probes, List logs) if (logs.Any(log => log.Status == LogStatus.Disconnected && log.Id == probe.Id) || probe.Condition == ProbeStatus.Disconnected) probe.Disconnected = true; } - if (probe.Disconnected && !probe.Reconnected) + if (probe.Disconnected && !probe.Reconnected) //If it's already disconnected and hasn't reconnected, check its status { - if (logs.Any(log => log.Status == LogStatus.Connected && log.Id == probe.Id)) + //If the probe has disconnected and we see it's reconnected, flag it as such. If it was already disconnected though, + //it'll never reconnect, so let it through + if (logs.Any(log => log.Status == LogStatus.Connected && log.Id == probe.Id) || probe.Condition == ProbeStatus.Disconnected) probe.Reconnected = true; } }