2021-03-20 15:51:03 +01:00
|
|
|
#!/bin/powershell
|
|
|
|
<#
|
2021-03-22 20:10:18 +01:00
|
|
|
.SYNTAX ./check-health.ps1
|
|
|
|
.DESCRIPTION checks the system health
|
|
|
|
.LINK https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES Author: Markus Fleschutz / License: CC0
|
2021-03-20 15:51:03 +01:00
|
|
|
#>
|
|
|
|
|
2021-03-20 16:32:26 +01:00
|
|
|
$Hostname = $(hostname)
|
|
|
|
$Healthy = 1
|
|
|
|
"Checking health of $Hostname ..."
|
2021-03-20 15:51:03 +01:00
|
|
|
|
2021-04-04 11:33:57 +02:00
|
|
|
& ./check-swap-space.ps1
|
2021-03-20 16:32:26 +01:00
|
|
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
2021-03-20 15:51:03 +01:00
|
|
|
|
2021-03-20 16:32:26 +01:00
|
|
|
if ($IsLinux) {
|
2021-04-04 11:33:57 +02:00
|
|
|
& ./check-drive-space.ps1 /
|
2021-03-20 16:32:26 +01:00
|
|
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
|
|
|
} else {
|
2021-04-04 11:33:57 +02:00
|
|
|
& ./check-drive-space.ps1 C
|
2021-03-20 16:32:26 +01:00
|
|
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
|
|
|
}
|
2021-03-20 16:13:54 +01:00
|
|
|
|
2021-04-04 11:33:57 +02:00
|
|
|
& ./check-cpu-temp.ps1
|
2021-03-20 16:32:26 +01:00
|
|
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
2021-03-20 15:51:03 +01:00
|
|
|
|
2021-04-04 11:33:57 +02:00
|
|
|
& ./check-dns-resolution.ps1
|
2021-03-20 16:32:26 +01:00
|
|
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
2021-03-20 15:51:03 +01:00
|
|
|
|
2021-04-04 11:33:57 +02:00
|
|
|
& ./check-ping.ps1
|
2021-03-30 09:06:30 +02:00
|
|
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
|
|
|
|
2021-03-20 16:32:26 +01:00
|
|
|
if ($Healthy) {
|
2021-03-20 15:51:03 +01:00
|
|
|
write-host -foregroundColor green "OK - $Hostname is healthy"
|
|
|
|
exit 0
|
2021-03-20 16:32:26 +01:00
|
|
|
} else {
|
|
|
|
write-warning "$Hostname is NOT healthy"
|
2021-03-20 15:51:03 +01:00
|
|
|
exit 1
|
|
|
|
}
|