mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 16:03:22 +01:00
Updated check-swap-space.ps1
This commit is contained in:
parent
2a1123485f
commit
f0272d1d37
@ -7,7 +7,7 @@
|
|||||||
Specifies the minimum level in MB (10 MB by default)
|
Specifies the minimum level in MB (10 MB by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-swap-space.ps1
|
PS> ./check-swap-space.ps1
|
||||||
✅ Swap space uses 21% of 1GB - 1005MB free
|
✅ Swap space uses 1GB (21%) of 5GB
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -48,14 +48,14 @@ 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 is full ($(MB2String $total))"
|
Write-Output "⚠️ Swap space with $(MB2String $total) is FULL !!!"
|
||||||
} elseif ($free -lt $minLevel) {
|
} elseif ($free -lt $minLevel) {
|
||||||
Write-Output "⚠️ Swap space has only $(MB2String $free) of $(MB2String $total) left"
|
Write-Output "⚠️ Swap space has only $(MB2String $free) of $(MB2String $total) left!"
|
||||||
} elseif ($used -lt 3) {
|
} elseif ($used -lt 3) {
|
||||||
Write-Output "✅ Swap space unused - $(MB2String $free) available"
|
Write-Output "✅ Swap space has $(MB2String $total) reserved"
|
||||||
} else {
|
} else {
|
||||||
[int64]$percent = ($free * 100) / $total
|
[int64]$percent = ($used * 100) / $total
|
||||||
Write-Output "✅ Swap space has $(MB2String $free) of $(MB2String $total) left ($percent%)"
|
Write-Output "✅ Swap space uses $(MB2String $used) ($percent%) of $(MB2String $total)"
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user