Improve the scripts

This commit is contained in:
Markus Fleschutz
2021-03-20 16:32:26 +01:00
parent 6a0e3eb002
commit 424629ef94
3 changed files with 25 additions and 24 deletions

View File

@ -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
}