Use cpufreq if available instead of hardcoding it to specific distros
This commit is contained in:
parent
0e83e2099d
commit
3c3e2cc571
1 changed files with 16 additions and 19 deletions
35
fetch
35
fetch
|
@ -590,27 +590,24 @@ getcpu () {
|
|||
cpu=${cpu/@*/}
|
||||
|
||||
# Get cpu speed
|
||||
case "$distro" in
|
||||
*"buntu"* | "CentOS"*)
|
||||
speed=$(awk -F ': ' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
|
||||
speed=${speed/\./}
|
||||
;;
|
||||
if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then
|
||||
case "$speed_type" in
|
||||
current) speed_type="scaling_cur_freq" ;;
|
||||
min) speed_type="scaling_min_freq" ;;
|
||||
max) speed_type="scaling_max_freq" ;;
|
||||
bios) speed_type="bios_limit" ;;
|
||||
scaling_current) speed_type="scaling_cur_freq" ;;
|
||||
scaling_min) speed_type="scaling_min_freq" ;;
|
||||
scaling_max) speed_type="scaling_max_freq" ;;
|
||||
esac
|
||||
|
||||
*)
|
||||
case "$speed_type" in
|
||||
current) speed_type="scaling_cur_freq" ;;
|
||||
min) speed_type="scaling_min_freq" ;;
|
||||
max) speed_type="scaling_max_freq" ;;
|
||||
bios) speed_type="bios_limit" ;;
|
||||
scaling_current) speed_type="scaling_cur_freq" ;;
|
||||
scaling_min) speed_type="scaling_min_freq" ;;
|
||||
scaling_max) speed_type="scaling_max_freq" ;;
|
||||
esac
|
||||
read -r speed < \
|
||||
/sys/devices/system/cpu/cpu0/cpufreq/${speed_type}
|
||||
|
||||
read -r speed < \
|
||||
/sys/devices/system/cpu/cpu0/cpufreq/${speed_type}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
speed=$(awk -F ': ' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
|
||||
speed=${speed/\./}
|
||||
fi
|
||||
|
||||
# Convert mhz to ghz without bc
|
||||
speed=$((speed / 100000))
|
||||
|
|
Loading…
Reference in a new issue