Updated ping-internet.ps1

This commit is contained in:
Markus Fleschutz 2024-10-23 18:44:11 +02:00
parent 01a00dd30f
commit 8deb881f99
2 changed files with 8 additions and 8 deletions

View File

@ -5,7 +5,7 @@
This PowerShell script measures the DNS resolution speed using 100 internet domains and prints it. This PowerShell script measures the DNS resolution speed using 100 internet domains and prints it.
.EXAMPLE .EXAMPLE
PS> ./check-dns.ps1 PS> ./check-dns.ps1
Internet DNS queries take 33.6ms Internet DNS lookups in 33.6ms
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -25,9 +25,9 @@ try {
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds * 1000.0 [float]$elapsed = $stopWatch.Elapsed.TotalSeconds * 1000.0
$speed = [math]::round($elapsed / $table.Length, 1) $speed = [math]::round($elapsed / $table.Length, 1)
if ($speed -gt 100.0) { if ($speed -gt 100.0) {
Write-Host "⚠️ Internet DNS queries are $($speed)ms slow" Write-Host "⚠️ Internet DNS lookups take $($speed)ms!"
} else { } else {
Write-Host "✅ Internet DNS queries take $($speed)ms" Write-Host "✅ Internet DNS lookups in $($speed)ms"
} }
exit 0 # success exit 0 # success
} catch { } catch {

View File

@ -7,7 +7,7 @@
Specifies the hosts to ping, seperated by commata (10 Internet servers by default) Specifies the hosts to ping, seperated by commata (10 Internet servers by default)
.EXAMPLE .EXAMPLE
PS> ./ping-internet.ps1 PS> ./ping-internet.ps1
Internet ping latency 12ms (9...18ms range) Internet ping takes 12ms (9...18ms range)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -34,12 +34,12 @@ try {
[int]$loss = $total - $success [int]$loss = $total - $success
if ($success -eq 0) { if ($success -eq 0) {
Write-Host "⚠️ Internet offline (100% ping loss)" Write-Host "⚠️ Internet offline (100% ping loss)"
} elseif ($loss -eq 0) { } elseif ($loss -gt 0) {
[float]$speed = [math]::round([float]$avg / [float]$success, 1)
Write-Host "✅ Internet ping latency $($speed)ms ($($min)...$($max)ms range)"
} else {
[float]$speed = [math]::round([float]$avg / [float]$success, 1) [float]$speed = [math]::round([float]$avg / [float]$success, 1)
Write-Host "✅ Online with $loss/$total ping loss and $($min)...$($max)ms latency - $($speed)ms average" Write-Host "✅ Online with $loss/$total ping loss and $($min)...$($max)ms latency - $($speed)ms average"
} else {
[float]$speed = [math]::round([float]$avg / [float]$success, 1)
Write-Host "✅ Internet ping takes $($speed)ms ($($min)...$($max)ms range)"
} }
exit 0 # success exit 0 # success
} catch { } catch {