Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added condition for ryzen to CPU temperature. #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scripts/cpu_temp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ print_cpu_temp() {
else
val="$(sensors)"
fi
echo "$val" | sed -e 's/^Tccd/Core /' | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}'
val=$(echo "$val" | sed -e 's/^Tccd/Core /')
if [[ $val =~ Core ]]; then
echo "$val" | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}'
elif [[ $val =~ Tctl ]]; then
echo "$val" | sed -n 's/Tctl:\s*+//p' | tr -d " "
elif [[ $val =~ Tdie ]]; then
echo "$val" | sed -n 's/Tdie:\s*+//p' | tr -d " "
else
echo "NA"
fi
Comment on lines +21 to +30
Copy link
Collaborator

@casperdcl casperdcl Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this?

Suggested change
val=$(echo "$val" | sed -e 's/^Tccd/Core /')
if [[ $val =~ Core ]]; then
echo "$val" | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}'
elif [[ $val =~ Tctl ]]; then
echo "$val" | sed -n 's/Tctl:\s*+//p' | tr -d " "
elif [[ $val =~ Tdie ]]; then
echo "$val" | sed -n 's/Tdie:\s*+//p' | tr -d " "
else
echo "NA"
fi
echo "$val" | sed -r -e 's/^(Tccd|Tctl:|Tdie:)/Core /' | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core\s+[0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not working for my CPU (AMD Ryzen 9 3950X). The original proposal somehow works for me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Can you post the output of sensors?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm a little bit busy lately. Here's my sensors output:

➜ sensors
iwlwifi_1-virtual-0
Adapter: Virtual device
temp1:            N/A

k10temp-pci-00c3
Adapter: PCI adapter
Tdie:         +57.8°C  (high = +70.0°C)
Tctl:         +57.8°C

fi
}

Expand Down