Use cpufreq if available instead of hardcoding it to specific distros
This commit is contained in:
parent
0e83e2099d
commit
3c3e2cc571
15
fetch
15
fetch
|
@ -590,13 +590,7 @@ 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" ;;
|
||||
|
@ -609,8 +603,11 @@ getcpu () {
|
|||
|
||||
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))
|
||||
|
|
Reference in New Issue