Ping Check: Divide by 0
italianoaj opened this issue · comments
Anthony Italiano commented
Perhaps adding a check in the ping test, in the event that there are 0 successes, doesn't throw an exception.
IE:
if($successCount -eq 0){
$avg = 0
}else{
$avg /= $successCount
}
Food for thought.
Markus Fleschutz commented
You're perfectly right! I missed that point. Now, I have changed this as follows:
if ($successCount -eq 0) {
Write-Host "⚠️ Offline ($lossCount/$lossCount loss)"
} else {
$avg /= $successCount
Write-Host "✅ Ping latency is $($avg)ms average ($($min)ms...$($max)ms, $lossCount loss)"
}