mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 16:03:22 +01:00
Update check-swap-space.ps1
This commit is contained in:
parent
37a6e8b087
commit
f73f8b3ccb
@ -7,7 +7,7 @@
|
|||||||
Specifies the minimum level (10 GB by default)
|
Specifies the minimum level (10 GB by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-swap-space.ps1
|
PS> ./check-swap-space.ps1
|
||||||
✅ Swap space with 1GB at 42%, 748MB free
|
✅ 1GB Swap space at 42%, 748MB free
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -46,17 +46,17 @@ try {
|
|||||||
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 "⚠️ $(MB2String $Total) Swap space is full"
|
||||||
} elseif ($Free -lt $MinLevel) {
|
} elseif ($Free -lt $MinLevel) {
|
||||||
Write-Output "⚠️ Swap space with $(MB2String $Total) is nearly full, only $(MB2String $Free) free"
|
Write-Output "⚠️ $(MB2String $Total) Swap space is nearly full, only $(MB2String $Free) free"
|
||||||
} elseif ($Used -eq 0) {
|
} elseif ($Used -eq 0) {
|
||||||
Write-Output "✅ Swap space with $(MB2String $Total) reserved"
|
Write-Output "✅ $(MB2String $Total) Swap space reserved"
|
||||||
} else {
|
} else {
|
||||||
[int]$Percent = ($Used * 100) / $Total
|
[int]$Percent = ($Used * 100) / $Total
|
||||||
if ($Percent -ge 90) {
|
if ($Percent -ge 90) {
|
||||||
Write-Output "✅ Swap space with $(MB2String $Total) is $Percent% full, $(MB2String $Free) free"
|
Write-Output "✅ $(MB2String $Total) Swap space is $Percent% full, only $(MB2String $Free) free"
|
||||||
} else {
|
} else {
|
||||||
Write-Output "✅ Swap space with $(MB2String $Total) at $Percent%, $(MB2String $Free) free"
|
Write-Output "✅ $(MB2String $Total) Swap space at $Percent%, $(MB2String $Free) free"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
|
Loading…
Reference in New Issue
Block a user