mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-20 08:58:18 +02:00
Update check-swap-space.ps1
This commit is contained in:
parent
4c3afd9119
commit
1f2dc3a340
@ -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 10% full, 901MB of 1TB free
|
✅ Swap space with 1GB at 42%, 748MB free
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -46,14 +46,18 @@ 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 of $(MB2String $Total) is full"
|
Write-Output "⚠️ Swap space with $(MB2String $Total) is full"
|
||||||
} elseif ($Free -lt $MinLevel) {
|
} 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) {
|
} elseif ($Used -eq 0) {
|
||||||
Write-Output "✅ Swap space with $(MB2String $Total) reserved"
|
Write-Output "✅ Swap space with $(MB2String $Total) reserved"
|
||||||
} else {
|
} else {
|
||||||
[int]$Percent = ($Used * 100) / $Total
|
[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
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user