File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 7
7
Specifies the minimum level (10 GB by default)
8
8
. EXAMPLE
9
9
PS> ./check-swap-space.ps1
10
- ✅ Swap space 10% full, 901MB of 1TB free
10
+ ✅ Swap space with 1GB at 42%, 748MB free
11
11
. LINK
12
12
https://github.com/fleschutz/PowerShell
13
13
. NOTES
@@ -46,14 +46,18 @@ try {
46
46
if ($Total -eq 0 ) {
47
47
Write-Output " ⚠️ No swap space configured"
48
48
} elseif ($Free -eq 0 ) {
49
- Write-Output " ⚠️ Swap space of $ ( MB2String $Total ) is full"
49
+ Write-Output " ⚠️ Swap space with $ ( MB2String $Total ) is full"
50
50
} 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"
52
52
} elseif ($Used -eq 0 ) {
53
53
Write-Output " ✅ Swap space with $ ( MB2String $Total ) reserved"
54
54
} else {
55
55
[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
+ }
57
61
}
58
62
exit 0 # success
59
63
} catch {
You can’t perform that action at this time.
0 commit comments