scaling-governor.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/usr/bin/env bash
  2. function header_info {
  3. cat <<"EOF"
  4. __________ __ __
  5. / ____/ __ \/ / / /
  6. / / / /_/ / / / /
  7. / /___/ ____/ /_/ /
  8. \____/_/ \____/
  9. Scaling Governors
  10. EOF
  11. }
  12. clear
  13. header_info
  14. set -e
  15. while true; do
  16. read -p "View CPU Scaling Governors. Proceed(y/n)?" yn
  17. case $yn in
  18. [Yy]*) break ;;
  19. [Nn]*) exit ;;
  20. *) echo "Please answer yes or no." ;;
  21. esac
  22. done
  23. clear
  24. show_menu() {
  25. CL=$(echo "\033[m")
  26. GN=$(echo "\033[32m")
  27. BL=$(echo "\033[36m")
  28. YW=$(echo "\033[33m")
  29. fgred=$(echo "\033[31m")
  30. header_info
  31. CK=$(uname -r)
  32. IP=$(hostname -I)
  33. # MAC=$(cat /sys/class/net/eno1/address)
  34. ACSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
  35. CCSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
  36. echo -e "${YW}Proxmox IP ${BL}${IP}${CL}"
  37. echo -e "${YW}MAC Address ${BL}${MAC}${CL}"
  38. echo -e "${YW}Current Kernel ${BL}${CK}${CL}"
  39. echo -e "\n${YW}Available CPU Scaling Governors
  40. ${BL}${ACSG}${CL}"
  41. echo -e "\n${YW}Current CPU Scaling Governor
  42. ${BL}${CCSG}${CL}"
  43. printf "\n ${fgred}Only Select Available CPU Scaling Governors From Above${CL}\n \n"
  44. printf "${BL}**${YW} 1)${GN} Switch to ${BL}conservative${CL}${GN} CPU Scaling Governor ${CL}\n"
  45. printf "${BL}**${YW} 2)${GN} Switch to ${BL}ondemand${CL}${GN} CPU Scaling Governor ${CL}\n"
  46. printf "${BL}**${YW} 3)${GN} Switch to ${BL}userspace${CL}${GN} CPU Scaling Governor ${CL}\n"
  47. printf "${BL}**${YW} 4)${GN} Switch to ${BL}powersave${CL}${GN} CPU Scaling Governor ${CL}\n"
  48. printf "${BL}**${YW} 5)${GN} Switch to ${BL}performance${CL}${GN} CPU Scaling Governor ${CL}\n"
  49. printf "${BL}**${YW} 6)${GN} Switch to ${BL}schedutil${CL}${GN} CPU Scaling Governor ${CL}\n"
  50. printf "\n ${fgred}NOTE: Settings return to default after reboot${CL}\n"
  51. printf "\n Please choose an option from the menu and press [ENTER] or ${fgred}x${CL} to exit."
  52. read opt
  53. }
  54. clear
  55. show_menu
  56. while [ "$opt" != "" ]; do
  57. if [ "$opt" = "" ]; then
  58. exit
  59. else
  60. case $opt in
  61. 1)
  62. echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  63. clear
  64. show_menu
  65. ;;
  66. 2)
  67. echo "ondemand" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  68. clear
  69. show_menu
  70. ;;
  71. 3)
  72. echo "userspace" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  73. clear
  74. show_menu
  75. ;;
  76. 4)
  77. echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  78. clear
  79. show_menu
  80. ;;
  81. 5)
  82. echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  83. clear
  84. show_menu
  85. ;;
  86. 6)
  87. echo "schedutil" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  88. clear
  89. show_menu
  90. ;;
  91. x)
  92. exit
  93. ;;
  94. \n)
  95. exit
  96. ;;
  97. *)
  98. clear
  99. show_menu
  100. ;;
  101. esac
  102. fi
  103. done