scaling-governor.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. header_info() {
  7. clear
  8. cat <<EOF
  9. __________ __ __
  10. / ____/ __ \/ / / /
  11. / / / /_/ / / / /
  12. / /___/ ____/ /_/ /
  13. \____/_/ \____/
  14. Scaling Governors
  15. EOF
  16. }
  17. while true; do
  18. header_info
  19. read -p "View CPU Scaling Governors. Proceed(y/n)?" yn
  20. case $yn in
  21. [Yy]*) break ;;
  22. [Nn]*) exit ;;
  23. *) echo "Please answer yes or no." ;;
  24. esac
  25. done
  26. show_menu() {
  27. header_info
  28. echo -e "\nProxmox IP \033[36m$(hostname -I)\033[m"
  29. echo -e "Current Kernel \033[36m$(uname -r)\033[m\n"
  30. available_governors=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
  31. echo -e "Available CPU Scaling Governors\n\033[36m${available_governors}\033[m\n"
  32. echo -e "Current CPU Scaling Governor\n\033[36m$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)\033[m\n"
  33. options=""
  34. i=1
  35. for governor in $available_governors
  36. do
  37. options+="** ${i}) \033[36m${governor}\033[m CPU Scaling Governor\n"
  38. ((i=i+1))
  39. done
  40. echo -e "${options}"
  41. echo -e "\033[31mNOTE: Settings return to default after reboot\033[m\n"
  42. read -p "Please choose an option from the menu and press [ENTER] or x to exit." opt
  43. }
  44. show_menu
  45. while [[ "$opt" != "" ]]; do
  46. num_governors=$(echo "$available_governors" | wc -w)
  47. if [[ $opt -gt 0 ]] && [[ $opt -le $num_governors ]]; then
  48. governor=$(echo "$available_governors" | cut -d' ' -f $opt)
  49. echo "${governor}" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  50. elif [[ $opt == "x" ]] || [[ $opt == "\n" ]]; then
  51. exit
  52. else
  53. show_menu
  54. fi
  55. show_menu
  56. done