mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-02 19:09:13 +01:00
Update check-drives.ps1 and check-swap-space.ps1
This commit is contained in:
parent
355989f481
commit
6e02dba5da
@ -45,7 +45,7 @@ try {
|
||||
if ($total -eq 0) {
|
||||
Write-Host "✅ Drive $name is empty"
|
||||
} elseif ($free -eq 0) {
|
||||
Write-Host "⚠️ Drive $name with $(Bytes2String $total) is 100% full"
|
||||
Write-Host "⚠️ Drive $name with $(Bytes2String $total) is full"
|
||||
} elseif ($free -lt $minLevel) {
|
||||
Write-Host "⚠️ Drive $name with $(Bytes2String $total) is nearly full, $(Bytes2String $free) free"
|
||||
} else {
|
||||
|
@ -3,18 +3,18 @@
|
||||
Checks the swap space status
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries the status of the swap space and prints it.
|
||||
.PARAMETER MinLevel
|
||||
Specifies the minimum level (10 GB by default)
|
||||
.PARAMETER minLevel
|
||||
Specifies the minimum level in GB (10 GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-swap-space.ps1
|
||||
✅ 1GB Swap space at 42%, 748MB free
|
||||
✅ Swap space at 42% of 1GB, 748MB free
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([int]$MinLevel = 10) # minimum level in GB
|
||||
param([int]$minLevel = 10)
|
||||
|
||||
function MB2String { param([int64]$Bytes)
|
||||
if ($Bytes -lt 1000) { return "$($Bytes)MB" }
|
||||
@ -47,17 +47,13 @@ try {
|
||||
Write-Output "⚠️ No swap space configured"
|
||||
} elseif ($Free -eq 0) {
|
||||
Write-Output "⚠️ $(MB2String $Total) Swap space is full"
|
||||
} elseif ($Free -lt $MinLevel) {
|
||||
} elseif ($Free -lt $minLevel) {
|
||||
Write-Output "⚠️ $(MB2String $Total) Swap space is nearly full, only $(MB2String $Free) free"
|
||||
} elseif ($Used -eq 0) {
|
||||
Write-Output "✅ $(MB2String $Total) Swap space reserved"
|
||||
} else {
|
||||
[int]$Percent = ($Used * 100) / $Total
|
||||
if ($Percent -ge 90) {
|
||||
Write-Output "✅ $(MB2String $Total) Swap space is $Percent% full, only $(MB2String $Free) free"
|
||||
} else {
|
||||
Write-Output "✅ $(MB2String $Total) Swap space at $Percent%, $(MB2String $Free) free"
|
||||
}
|
||||
Write-Output "✅ Swap space at $Percent% of $(MB2String $Total), $(MB2String $Free) free"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user