From 1f2dc3a340014236c8432b8c6f85a4d920c5ddee Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sun, 6 Aug 2023 18:19:20 +0200 Subject: [PATCH] Update check-swap-space.ps1 --- Scripts/check-swap-space.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Scripts/check-swap-space.ps1 b/Scripts/check-swap-space.ps1 index e54dabf9..c38b895b 100755 --- a/Scripts/check-swap-space.ps1 +++ b/Scripts/check-swap-space.ps1 @@ -7,7 +7,7 @@ Specifies the minimum level (10 GB by default) .EXAMPLE PS> ./check-swap-space.ps1 - ✅ Swap space 10% full, 901MB of 1TB free + ✅ Swap space with 1GB at 42%, 748MB free .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -46,14 +46,18 @@ try { if ($Total -eq 0) { Write-Output "⚠️ No swap space configured" } elseif ($Free -eq 0) { - Write-Output "⚠️ Swap space of $(MB2String $Total) is full" + Write-Output "⚠️ Swap space with $(MB2String $Total) is full" } elseif ($Free -lt $MinLevel) { - Write-Output "⚠️ Swap space of $(MB2String $Total) is nearly full ($(MB2String $Free) free)" + Write-Output "⚠️ Swap space with $(MB2String $Total) is nearly full, only $(MB2String $Free) free" } elseif ($Used -eq 0) { Write-Output "✅ Swap space with $(MB2String $Total) reserved" } else { [int]$Percent = ($Used * 100) / $Total - Write-Output "✅ Swap space $Percent% full, $(MB2String $Free) of $(MB2String $Total) free" + if ($Percent -ge 90) { + Write-Output "✅ Swap space with $(MB2String $Total) is $Percent% full, $(MB2String $Free) free" + } else { + Write-Output "✅ Swap space with $(MB2String $Total) at $Percent%, $(MB2String $Free) free" + } } exit 0 # success } catch {