mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 17:14:28 +01:00
Improve the scripts
This commit is contained in:
parent
6a0e3eb002
commit
424629ef94
@ -22,7 +22,7 @@ try {
|
||||
write-warning "Drive $Drive has only $Free GB left to use! ($Used GB out of $Total GB in use, minimum is $MinLevel GB)"
|
||||
exit 1
|
||||
}
|
||||
write-host -foregroundColor green "OK - drive $Drive has $Free GB left ($Used GB of $Total GB used, $MinLevel GB is minimum)"
|
||||
write-host -foregroundColor green "OK - drive $Drive has $Free GB left ($Used GB of $Total GB used)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -6,35 +6,36 @@
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$Hostname = $(hostname)
|
||||
"Checking health of $Hostname ..."
|
||||
$Hostname = $(hostname)
|
||||
$Healthy = 1
|
||||
"Checking health of $Hostname ..."
|
||||
|
||||
& check-swap-space.ps1
|
||||
if ($lastExitCode -ne "0") { throw "check-swap-space.ps1 failed" }
|
||||
& check-swap-space.ps1
|
||||
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||
|
||||
if ($IsLinux) {
|
||||
& check-drive-space.ps1 /
|
||||
if ($lastExitCode -ne "0") { throw "check-drive-space.ps1 failed" }
|
||||
} else {
|
||||
& check-drive-space.ps1 C
|
||||
if ($lastExitCode -ne "0") { throw "check-drive-space.ps1 failed" }
|
||||
}
|
||||
if ($IsLinux) {
|
||||
& check-drive-space.ps1 /
|
||||
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||
} else {
|
||||
& check-drive-space.ps1 C
|
||||
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||
}
|
||||
|
||||
& check-cpu-temp.ps1
|
||||
if ($lastExitCode -ne "0") { throw "check-cpu-temp.ps1 failed" }
|
||||
& check-cpu-temp.ps1
|
||||
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||
|
||||
if (-not($IsLinux)) {
|
||||
& check-windows-system-files.ps1
|
||||
if ($lastExitCode -ne "0") { throw "check-windows-system-files.ps1 failed" }
|
||||
}
|
||||
if (-not($IsLinux)) {
|
||||
& check-windows-system-files.ps1
|
||||
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||
}
|
||||
|
||||
& check-dns-resolution.ps1
|
||||
if ($lastExitCode -ne "0") { throw "check-dns-resolution.ps1 failed" }
|
||||
& check-dns-resolution.ps1
|
||||
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||
|
||||
if ($Healthy) {
|
||||
write-host -foregroundColor green "OK - $Hostname is healthy"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
} else {
|
||||
write-warning "$Hostname is NOT healthy"
|
||||
exit 1
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ try {
|
||||
write-warning "Swap space has only $Free GB left to use! ($Used GB out of $Total GB in use, minimum is $MinLevel GB)"
|
||||
exit 1
|
||||
}
|
||||
write-host -foregroundColor green "OK - swap space has $Free GB left ($Used GB of $Total GB used, minimum is $MinLevel GB)"
|
||||
write-host -foregroundColor green "OK - swap space has $Free GB left ($Used GB of $Total GB used)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user