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 cpu_temperature #129

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 8 additions & 5 deletions scripts/cpu-temperature
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env bash

grep -E 'Tctl|Tdie|Package id' /sys/class/hwmon/hwmon*/temp*_label | head -n1 | cut -d':' -f1 | sed 's/label/input/' | xargs cat
temp_milliC=$(grep -E 'Tctl|Tdie|Package id' /sys/class/hwmon/hwmon*/temp*_label | head -n1 | cut -d':' -f1 | sed 's/label/input/' | xargs cat)

# Following script outputs current cpu die temperature in milidegree-celcius, convert it to celcius and fahrenheit and display as:
#
# Celcius: 42.0 C
# Fahrenheit: 107.6 F
# Convert to Celsius and Fahrenheit
temp_C=$(echo "scale=1; $temp_milliC / 1000" | bc)
temp_F=$(echo "scale=1; ($temp_milliC * 9 / 500) + 32" | bc)

# Display results
echo "Celsius: $temp_C C"
echo "Fahrenheit: $temp_F F"