Skip to content

Commit 1f2dc3a

Browse files
committed
Update check-swap-space.ps1
1 parent 4c3afd9 commit 1f2dc3a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Scripts/check-swap-space.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Specifies the minimum level (10 GB by default)
88
.EXAMPLE
99
PS> ./check-swap-space.ps1
10-
✅ Swap space 10% full, 901MB of 1TB free
10+
✅ Swap space with 1GB at 42%, 748MB free
1111
.LINK
1212
https://github.com/fleschutz/PowerShell
1313
.NOTES
@@ -46,14 +46,18 @@ try {
4646
if ($Total -eq 0) {
4747
Write-Output "⚠️ No swap space configured"
4848
} elseif ($Free -eq 0) {
49-
Write-Output "⚠️ Swap space of $(MB2String $Total) is full"
49+
Write-Output "⚠️ Swap space with $(MB2String $Total) is full"
5050
} elseif ($Free -lt $MinLevel) {
51-
Write-Output "⚠️ Swap space of $(MB2String $Total) is nearly full ($(MB2String $Free) free)"
51+
Write-Output "⚠️ Swap space with $(MB2String $Total) is nearly full, only $(MB2String $Free) free"
5252
} elseif ($Used -eq 0) {
5353
Write-Output "✅ Swap space with $(MB2String $Total) reserved"
5454
} else {
5555
[int]$Percent = ($Used * 100) / $Total
56-
Write-Output "✅ Swap space $Percent% full, $(MB2String $Free) of $(MB2String $Total) free"
56+
if ($Percent -ge 90) {
57+
Write-Output "✅ Swap space with $(MB2String $Total) is $Percent% full, $(MB2String $Free) free"
58+
} else {
59+
Write-Output "✅ Swap space with $(MB2String $Total) at $Percent%, $(MB2String $Free) free"
60+
}
5761
}
5862
exit 0 # success
5963
} catch {

0 commit comments

Comments
 (0)