Update check-swap-space.ps1

This commit is contained in:
Markus Fleschutz 2021-12-01 10:49:10 +01:00
parent 005613fe54
commit 17b2050c07

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Checks the free swap space Checks the swap space
.DESCRIPTION .DESCRIPTION
This script checks the free swap space. This script checks the free swap space.
.PARAMETER MinLevel .PARAMETER MinLevel
@ -32,14 +32,14 @@ try {
} }
if ($Total -eq "0") { if ($Total -eq "0") {
write-warning "No swap space configured!" $Reply = "No swap space configured!"
exit 1 } elseif ($Free -lt $MinLevel) {
$Reply = "Swap space has only $Free GB left to use! ($Used of $Total GB used, minimum is $MinLevel GB)"
} else {
$Reply = "Swap space has $Free GB left ($Total GB total)"
} }
if ($Free -lt $MinLevel) { "✔️ $Reply"
write-warning "Swap space has only $Free GB left to use! ($Used of $Total GB used, minimum is $MinLevel GB)" & "$PSScriptRoot/speak-english.ps1" "$Reply"
exit 1
}
"✔️ Swap space has $Free GB left ($Total GB total)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"