mirror of
https://github.com/AlexMacocian/ServerManagementUtils.git
synced 2026-07-15 15:19:58 +00:00
Fixes to temperature
This commit is contained in:
@@ -33,13 +33,19 @@ for i in {1..6}; do
|
||||
timestamp=$(GetTimestamp)
|
||||
|
||||
if [[ "$OS_TYPE" == "macos" ]]; then
|
||||
# Try osx-cpu-temp first
|
||||
# Try osx-cpu-temp first (check both PATH and common install location)
|
||||
if command -v osx-cpu-temp &> /dev/null; then
|
||||
temp_output=$(osx-cpu-temp 2>/dev/null)
|
||||
if [[ $? -eq 0 && -n "$temp_output" ]]; then
|
||||
# Output format: "50.0°C"
|
||||
echo "$timestamp CPU $temp_output" >> "$LOGFILE"
|
||||
fi
|
||||
elif [[ -x /usr/local/bin/osx-cpu-temp ]]; then
|
||||
temp_output=$(/usr/local/bin/osx-cpu-temp 2>/dev/null)
|
||||
if [[ $? -eq 0 && -n "$temp_output" ]]; then
|
||||
# Output format: "50.0°C"
|
||||
echo "$timestamp CPU $temp_output" >> "$LOGFILE"
|
||||
fi
|
||||
# Fallback to powermetrics (requires sudo)
|
||||
elif [[ -x /usr/bin/powermetrics ]]; then
|
||||
# Run powermetrics for 1 second and extract temperature
|
||||
|
||||
@@ -119,7 +119,8 @@ IsThermalMonitoringSupported() {
|
||||
case "$os" in
|
||||
macos)
|
||||
# Check if osx-cpu-temp or powermetrics is available
|
||||
command -v osx-cpu-temp &> /dev/null || [[ -x /usr/bin/powermetrics ]]
|
||||
# Check both PATH and common install locations
|
||||
command -v osx-cpu-temp &> /dev/null || [[ -x /usr/local/bin/osx-cpu-temp ]] || [[ -x /usr/bin/powermetrics ]]
|
||||
;;
|
||||
linux)
|
||||
# Check if thermal zones exist
|
||||
|
||||
Reference in New Issue
Block a user