mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-08 20:54:38 +02:00
Add check-ping.ps1
This commit is contained in:
@ -22,7 +22,7 @@ try {
|
||||
write-warning "Drive $Drive has only $Free GB left to use! ($Used GB out of $Total GB in use, minimum is $MinLevel GB)"
|
||||
exit 1
|
||||
}
|
||||
write-host -foregroundColor green "OK - drive $Drive has $Free GB left ($Used GB of $Total GB used)"
|
||||
write-host -foregroundColor green "OK - $Free GB left on drive $Drive ($Used GB of $Total GB used)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -32,6 +32,9 @@ if (-not($IsLinux)) {
|
||||
& check-dns-resolution.ps1
|
||||
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||
|
||||
& check-ping.ps1
|
||||
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||
|
||||
if ($Healthy) {
|
||||
write-host -foregroundColor green "OK - $Hostname is healthy"
|
||||
exit 0
|
||||
|
28
Scripts/check-ping.ps1
Executable file
28
Scripts/check-ping.ps1
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/powershell
|
||||
<#
|
||||
.SYNTAX ./check-ping.ps1
|
||||
.DESCRIPTION checks the ping latency to the internet
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
write-verbose "Sending pings to the internet ..."
|
||||
$Pings = test-connection -count 1 -computerName heise.de,cnn.com,github.com,www.microsoft.com,dropbox.com,amazon.com,google.com,bing.com,youtube.com
|
||||
|
||||
[int]$Min = 9999999
|
||||
[int]$Max = 0
|
||||
[int]$Avg = 0
|
||||
foreach($Ping in $Pings) {
|
||||
if ($Ping.latency -lt $Min) { $Min = $Ping.latency }
|
||||
if ($Ping.latency -gt $Max) { $Max = $Ping.latency }
|
||||
$Avg += $Ping.latency
|
||||
}
|
||||
$Avg = $Avg / $Pings.count
|
||||
|
||||
write-host -foregroundColor green "OK - $Avg ms average ping latency ($Min ms min, $Max ms max)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
@ -31,7 +31,7 @@ try {
|
||||
write-warning "Swap space has only $Free GB left to use! ($Used GB out of $Total GB in use, minimum is $MinLevel GB)"
|
||||
exit 1
|
||||
}
|
||||
write-host -foregroundColor green "OK - swap space has $Free GB left ($Used GB of $Total GB used)"
|
||||
write-host -foregroundColor green "OK - $Free GB left on swap space ($Used GB of $Total GB used)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Reference in New Issue
Block a user