mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-24 05:51:50 +02:00
Update check-swap-space.ps1
This commit is contained in:
parent
6f00b0a6bf
commit
c96f45fb42
@ -4,7 +4,7 @@
|
|||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script queries the current status of the swap space and prints it.
|
This PowerShell script queries the current status of the swap space and prints it.
|
||||||
.PARAMETER minLevel
|
.PARAMETER minLevel
|
||||||
Specifies the minimum level in GB (10 GB 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 21% of 1GB - 1005MB free
|
||||||
@ -51,11 +51,11 @@ try {
|
|||||||
Write-Output "⚠️ Swap space of $(MB2String $total) is full"
|
Write-Output "⚠️ Swap space of $(MB2String $total) is full"
|
||||||
} elseif ($free -lt $minLevel) {
|
} elseif ($free -lt $minLevel) {
|
||||||
Write-Output "⚠️ Swap space has only $(MB2String $free) of $(MB2String $total) free"
|
Write-Output "⚠️ Swap space has only $(MB2String $free) of $(MB2String $total) free"
|
||||||
} elseif ($used -lt 5) {
|
} elseif ($used -lt 3) {
|
||||||
Write-Output "✅ Swap space unused - $(MB2String $free) free"
|
Write-Output "✅ Swap space unused - full $(MB2String $free) free"
|
||||||
} else {
|
} else {
|
||||||
[int64]$percent = ($used * 100) / $total
|
[int64]$percent = ($used * 100) / $total
|
||||||
Write-Output "✅ Swap space uses $percent% of $(MB2String $total) - $(MB2String $free) free"
|
Write-Output "✅ Swap space at $percent% of $(MB2String $total) - $(MB2String $free) free"
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user