diff --git a/Data/scripts.csv b/Data/scripts.csv index c8968064..49c744e3 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -1,5 +1,6 @@ Script,Description add-firewall-rules.ps1, adds firewall rules to the given executables (requires admin rights) +check-cpu-temp.ps1, checks the CPU temperature check-dns-resolution.ps1, checks the DNS resolution with frequently used domain names check-drive-space.ps1, checks the given drive for free space left check-health.ps1, checks the system health diff --git a/README.md b/README.md index d1f06ddb..931ee143 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Collection of PowerShell Scripts ⚙️ Scripts for Computer Management --------------------------------- * [add-firewall-rules.ps1](Scripts/add-firewall-rules.ps1) - adds firewall rules for the given executables (requires admin rights) +* [check-cpu-temp.ps1](Scripts/check-cpu-temp.ps1) - checks the CPU temperature * [check-dns-resolution.ps1](Scripts/check-dns-resolution.ps1) - checks the DNS resolution with frequently used domain names * [check-drive-space.ps1](Scripts/check-drive-space.ps1) - checks the given drive for free space left * [check-health.ps1](Scripts/check-health.ps1) - checks the system health diff --git a/Scripts/check-cpu-temp.ps1 b/Scripts/check-cpu-temp.ps1 new file mode 100755 index 00000000..da887838 --- /dev/null +++ b/Scripts/check-cpu-temp.ps1 @@ -0,0 +1,23 @@ +#!/bin/powershell +<# +.SYNTAX ./check-cpu-temp.ps1 +.DESCRIPTION checks the CPU temperature +.LINK https://github.com/fleschutz/PowerShell +.NOTES Author: Markus Fleschutz / License: CC0 +#> + +try { + if (test-path "/sys/class/thermal/thermal_zone0/temp") { + $Temp = get-content "/sys/class/thermal/thermal_zone0/temp" + $Temp = $Temp / 1000.0 + } else { + write-warning "No CPU temperature retrieved" + exit 0 + } + + write-host -foregroundColor green "OK - CPU has $Temp °C" + exit 0 +} catch { + write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} diff --git a/Scripts/check-drive-space.ps1 b/Scripts/check-drive-space.ps1 index 034ecd00..d80c43ef 100755 --- a/Scripts/check-drive-space.ps1 +++ b/Scripts/check-drive-space.ps1 @@ -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 - $Free GB free at drive $Drive ($Used GB used out of $Total GB, $MinLevel GB is minimum)" + write-host -foregroundColor green "OK - drive $Drive has $Free GB left ($Used GB used out of $Total GB, $MinLevel GB is minimum)" exit 0 } catch { write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/check-health.ps1 b/Scripts/check-health.ps1 index 4867b74b..a366516b 100755 --- a/Scripts/check-health.ps1 +++ b/Scripts/check-health.ps1 @@ -15,10 +15,14 @@ try { 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 ($lastExitCode -ne "0") { throw "check-drive-space.ps1 failed" } + + & check-cpu-temp.ps1 + if ($lastExitCode -ne "0") { throw "check-cpu-temp.ps1 failed" } if (-not($IsLinux)) { & check-windows-system-files.ps1 diff --git a/Scripts/check-swap-space.ps1 b/Scripts/check-swap-space.ps1 index fe5b446c..deb6d83e 100755 --- a/Scripts/check-swap-space.ps1 +++ b/Scripts/check-swap-space.ps1 @@ -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 - $Free GB free swap space ($Used GB used out of $Total GB, minimum is $MinLevel GB)" + write-host -foregroundColor green "OK - swap space has $Free GB left ($Used GB used out of $Total GB, minimum is $MinLevel GB)" exit 0 } catch { write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"