mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-24 00:43:35 +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)"
|
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
|
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
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -6,35 +6,36 @@
|
|||||||
.NOTES Author: Markus Fleschutz / License: CC0
|
.NOTES Author: Markus Fleschutz / License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
$Hostname = $(hostname)
|
||||||
$Hostname = $(hostname)
|
$Healthy = 1
|
||||||
"Checking health of $Hostname ..."
|
"Checking health of $Hostname ..."
|
||||||
|
|
||||||
& check-swap-space.ps1
|
& check-swap-space.ps1
|
||||||
if ($lastExitCode -ne "0") { throw "check-swap-space.ps1 failed" }
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||||
|
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
& check-drive-space.ps1 /
|
& check-drive-space.ps1 /
|
||||||
if ($lastExitCode -ne "0") { throw "check-drive-space.ps1 failed" }
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||||
} else {
|
} else {
|
||||||
& check-drive-space.ps1 C
|
& check-drive-space.ps1 C
|
||||||
if ($lastExitCode -ne "0") { throw "check-drive-space.ps1 failed" }
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
& check-cpu-temp.ps1
|
& check-cpu-temp.ps1
|
||||||
if ($lastExitCode -ne "0") { throw "check-cpu-temp.ps1 failed" }
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||||
|
|
||||||
if (-not($IsLinux)) {
|
if (-not($IsLinux)) {
|
||||||
& check-windows-system-files.ps1
|
& check-windows-system-files.ps1
|
||||||
if ($lastExitCode -ne "0") { throw "check-windows-system-files.ps1 failed" }
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
& check-dns-resolution.ps1
|
& check-dns-resolution.ps1
|
||||||
if ($lastExitCode -ne "0") { throw "check-dns-resolution.ps1 failed" }
|
if ($lastExitCode -ne "0") { $Healthy = 0 }
|
||||||
|
|
||||||
|
if ($Healthy) {
|
||||||
write-host -foregroundColor green "OK - $Hostname is healthy"
|
write-host -foregroundColor green "OK - $Hostname is healthy"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} else {
|
||||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-warning "$Hostname is NOT healthy"
|
||||||
exit 1
|
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)"
|
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
|
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
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user