Updated check-swap-space.ps1

This commit is contained in:
Markus Fleschutz 2025-02-26 20:49:04 +01:00
parent a0f0ed7814
commit 9c2bcc5861

View File

@ -46,16 +46,16 @@ try {
[int64]$free = ($total - $used) [int64]$free = ($total - $used)
} }
if ($total -eq 0) { if ($total -eq 0) {
Write-Output "⚠️ No swap space configured" Write-Output "⚠️ No swap space configured."
} elseif ($free -eq 0) { } elseif ($free -eq 0) {
Write-Output "⚠️ Swap space with $(MB2String $total) is FULL !!!" Write-Output "⚠️ Swap space of $(MB2String $total) is FULL!"
} elseif ($free -lt $minLevel) { } elseif ($free -lt $minLevel) {
Write-Output "⚠️ Swap space has only $(MB2String $free) of $(MB2String $total) left!" Write-Output "⚠️ Swap space has only $(MB2String $free) of $(MB2String $total) left!"
} elseif ($used -lt 3) { } elseif ($used -lt 3) {
Write-Output "✅ Swap space has $(MB2String $total) reserved" Write-Output "✅ Swap space has $(MB2String $total) reserved."
} else { } else {
[int64]$percent = ($used * 100) / $total [int64]$percent = ($used * 100) / $total
Write-Output "✅ Swap space uses $(MB2String $used) ($percent%) of $(MB2String $total)" Write-Output "✅ Swap space at $(MB2String $used) ($percent%) of $(MB2String $total)."
} }
exit 0 # success exit 0 # success
} catch { } catch {