Create scaling-governor.sh

This commit is contained in:
tteckster 2022-03-25 09:19:34 -04:00 committed by GitHub
parent 9d53133382
commit 0118f1fb0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 71 additions and 0 deletions

71
misc/scaling-governor.sh Normal file
View File

@ -0,0 +1,71 @@
#!/usr/bin/env bash
set -e
show_menu(){
CL=`echo "\033[m"`
GN=`echo "\033[32m"`
BL=`echo "\033[36m"`
YW=`echo "\033[33m"`
fgred=`echo "\033[31m"`
IP=$(hostname -I)
ACSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
CCSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
echo -e "${YW}Proxmox IP ${BL}${IP}${CL}"
echo -e "\n${YW}Available CPU Scaling Governors
${BL}${ACSG}${CL}"
echo -e "\n${YW}Current CPU Scaling Governor
${BL}${CCSG}${CL}"
printf "\n${BL}********** ${YW}CPU Scaling Governor Selector${CL} ${BL}********${CL}\n"
printf "${BL}**${YW} 1)${GN} Switch to ${BL}conservative${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 2)${GN} Switch to ${BL}ondemand${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 3)${GN} Switch to ${BL}userspace${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 4)${GN} Switch to ${BL}powersave${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 5)${GN} Switch to ${BL}performance${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "${BL}**${YW} 6)${GN} Switch to ${BL}schedutil${CL}${GN} CPU Scaling Governor ${CL}\n"
printf "\n ${fgred}NOTE: Settings return to default after reboot${CL}\n"
printf "\n Please choose an option from the menu and press [ENTER] or ${fgred}x to exit. ${CL}"
read opt
}
clear
show_menu
while [ $opt != '' ]
do
if [ $opt = '' ]; then
exit;
else
case $opt in
1) echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
2) echo "ondemand" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
3) echo "userspace" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
4) echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
5) echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
6) echo "schedutil" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
clear
show_menu
;;
x)exit;
;;
\n)exit;
;;
*)clear;
show_menu;
;;
esac
fi
done