scaling-governor.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/usr/bin/env bash
  2. clear
  3. set -e
  4. while true; do
  5. read -p "View CPU Scaling Governors. Proceed(y/n)?" yn
  6. case $yn in
  7. [Yy]* ) break;;
  8. [Nn]* ) exit;;
  9. * ) echo "Please answer yes or no.";;
  10. esac
  11. done
  12. clear
  13. function header_info {
  14. echo -e "
  15. _____ _____ _ _
  16. / ____| __ \| | | |
  17. | | | |__) | | | |
  18. | | | ___/| | | |
  19. | |____| | | |__| |
  20. \_____|_| \____/
  21. Scaling Governors
  22. "
  23. }
  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 != '' ]
  57. do
  58. if [ $opt = '' ]; then
  59. exit;
  60. else
  61. case $opt in
  62. 1) echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  63. clear
  64. show_menu
  65. ;;
  66. 2) echo "ondemand" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  67. clear
  68. show_menu
  69. ;;
  70. 3) echo "userspace" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  71. clear
  72. show_menu
  73. ;;
  74. 4) echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  75. clear
  76. show_menu
  77. ;;
  78. 5) echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  79. clear
  80. show_menu
  81. ;;
  82. 6) echo "schedutil" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  83. clear
  84. show_menu
  85. ;;
  86. x)exit;
  87. ;;
  88. \n)exit;
  89. ;;
  90. *)clear;
  91. show_menu;
  92. ;;
  93. esac
  94. fi
  95. done