PowerShell/Scripts/check-health.ps1

56 lines
1.3 KiB
PowerShell
Raw Normal View History

2021-09-27 10:38:12 +02:00
<#
2021-07-13 21:10:02 +02:00
.SYNOPSIS
Checks the health of the local computer
2021-10-04 21:29:23 +02:00
.DESCRIPTION
2021-10-16 16:50:10 +02:00
This script checks the health of the local computer.
2021-07-13 21:10:02 +02:00
.EXAMPLE
2021-09-24 17:19:49 +02:00
PS> ./check-health
2021-10-04 17:42:06 +02:00
1213 GB left for swap space (67 of 1280 GB used)
172 GB left on drive C (61 of 233 GB used)
30.3 °C CPU temperature - good
19.7 domains/s (177 domains resolved in 9 sec)
29 ms ping average (13 ms min, 110 ms max, 10 hosts)
Windmill is healthy
2021-07-13 21:10:02 +02:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
2021-08-03 15:53:57 +02:00
Author: Markus Fleschutz
License: CC0
2021-03-20 15:51:03 +01:00
#>
2021-03-20 16:32:26 +01:00
$Healthy = 1
2021-03-20 15:51:03 +01:00
2021-04-07 14:45:10 +02:00
& "$PSScriptRoot/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-07 14:45:10 +02:00
& "$PSScriptRoot/check-drive-space.ps1" /
2021-03-20 16:32:26 +01:00
if ($lastExitCode -ne "0") { $Healthy = 0 }
} else {
2021-04-07 14:45:10 +02:00
& "$PSScriptRoot/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-07 14:45:10 +02:00
& "$PSScriptRoot/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-07 14:45:10 +02:00
& "$PSScriptRoot/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-07 14:45:10 +02:00
& "$PSScriptRoot/check-ping.ps1"
2021-03-30 09:06:30 +02:00
if ($lastExitCode -ne "0") { $Healthy = 0 }
2021-10-03 21:43:29 +02:00
if ($IsLinux) {
& "$PSScriptRoot/check-smart-devices.ps1"
if ($lastExitCode -ne "0") { $Healthy = 0 }
}
2021-10-04 17:42:06 +02:00
$Hostname = $(hostname)
2021-03-20 16:32:26 +01:00
if ($Healthy) {
2021-10-19 09:43:25 +02:00
"✔️ $Hostname seems healthy"
2021-09-27 10:09:45 +02:00
exit 0 # success
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
}