2022-03-25 09:19:34 -04:00
|
|
|
#!/usr/bin/env bash
|
2023-02-07 12:15:22 -05:00
|
|
|
|
|
|
|
# Copyright (c) 2021-2023 tteck
|
|
|
|
# Author: tteck (tteckster)
|
|
|
|
# License: MIT
|
|
|
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
|
|
|
|
2023-01-10 11:16:26 -05:00
|
|
|
function header_info {
|
|
|
|
cat <<"EOF"
|
|
|
|
__________ __ __
|
|
|
|
/ ____/ __ \/ / / /
|
|
|
|
/ / / /_/ / / / /
|
|
|
|
/ /___/ ____/ /_/ /
|
|
|
|
\____/_/ \____/
|
|
|
|
Scaling Governors
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
2022-03-25 09:43:55 -04:00
|
|
|
clear
|
2023-01-10 11:16:26 -05:00
|
|
|
header_info
|
2022-03-25 09:56:24 -04:00
|
|
|
set -e
|
2022-03-25 09:28:41 -04:00
|
|
|
while true; do
|
2022-03-25 11:28:17 -04:00
|
|
|
read -p "View CPU Scaling Governors. Proceed(y/n)?" yn
|
2022-03-25 09:28:41 -04:00
|
|
|
case $yn in
|
2022-10-29 23:45:14 -04:00
|
|
|
[Yy]*) break ;;
|
|
|
|
[Nn]*) exit ;;
|
|
|
|
*) echo "Please answer yes or no." ;;
|
2022-03-25 09:28:41 -04:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
clear
|
2023-01-10 11:16:26 -05:00
|
|
|
|
2022-10-29 23:45:14 -04:00
|
|
|
show_menu() {
|
|
|
|
CL=$(echo "\033[m")
|
|
|
|
GN=$(echo "\033[32m")
|
|
|
|
BL=$(echo "\033[36m")
|
|
|
|
YW=$(echo "\033[33m")
|
|
|
|
fgred=$(echo "\033[31m")
|
|
|
|
header_info
|
2022-03-25 14:35:40 -04:00
|
|
|
CK=$(uname -r)
|
2022-03-25 09:19:34 -04:00
|
|
|
IP=$(hostname -I)
|
2022-10-29 23:45:14 -04:00
|
|
|
# MAC=$(cat /sys/class/net/eno1/address)
|
2022-03-25 09:19:34 -04:00
|
|
|
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}"
|
|
|
|
|
2022-03-25 14:35:40 -04:00
|
|
|
echo -e "${YW}MAC Address ${BL}${MAC}${CL}"
|
|
|
|
|
|
|
|
echo -e "${YW}Current Kernel ${BL}${CK}${CL}"
|
|
|
|
|
2022-03-25 09:19:34 -04:00
|
|
|
echo -e "\n${YW}Available CPU Scaling Governors
|
|
|
|
${BL}${ACSG}${CL}"
|
2022-10-29 23:45:14 -04:00
|
|
|
|
2022-03-25 09:19:34 -04:00
|
|
|
echo -e "\n${YW}Current CPU Scaling Governor
|
|
|
|
${BL}${CCSG}${CL}"
|
2022-03-25 09:58:46 -04:00
|
|
|
printf "\n ${fgred}Only Select Available CPU Scaling Governors From Above${CL}\n \n"
|
2022-03-25 09:19:34 -04:00
|
|
|
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"
|
2022-03-25 09:28:41 -04:00
|
|
|
printf "\n Please choose an option from the menu and press [ENTER] or ${fgred}x${CL} to exit."
|
2022-03-25 09:19:34 -04:00
|
|
|
read opt
|
|
|
|
}
|
|
|
|
clear
|
|
|
|
show_menu
|
2022-10-30 00:19:48 -04:00
|
|
|
while [ "$opt" != "" ]; do
|
|
|
|
if [ "$opt" = "" ]; then
|
2022-10-29 23:45:14 -04:00
|
|
|
exit
|
2022-03-25 09:19:34 -04:00
|
|
|
else
|
2022-10-29 23:45:14 -04:00
|
|
|
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
|
2022-03-25 09:19:34 -04:00
|
|
|
clear
|
|
|
|
show_menu
|
2022-10-29 23:45:14 -04:00
|
|
|
;;
|
|
|
|
3)
|
|
|
|
echo "userspace" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
|
2022-03-25 09:19:34 -04:00
|
|
|
clear
|
|
|
|
show_menu
|
2022-10-29 23:45:14 -04:00
|
|
|
;;
|
|
|
|
4)
|
|
|
|
echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
|
2022-03-25 09:19:34 -04:00
|
|
|
clear
|
|
|
|
show_menu
|
2022-10-29 23:45:14 -04:00
|
|
|
;;
|
|
|
|
5)
|
|
|
|
echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
|
2022-03-25 09:19:34 -04:00
|
|
|
clear
|
|
|
|
show_menu
|
2022-10-29 23:45:14 -04:00
|
|
|
;;
|
|
|
|
6)
|
|
|
|
echo "schedutil" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
|
2022-03-25 09:19:34 -04:00
|
|
|
clear
|
|
|
|
show_menu
|
2022-10-29 23:45:14 -04:00
|
|
|
;;
|
|
|
|
x)
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
\n)
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
*)
|
2022-03-25 09:19:34 -04:00
|
|
|
clear
|
|
|
|
show_menu
|
2022-10-29 23:45:14 -04:00
|
|
|
;;
|
|
|
|
esac
|
2022-03-25 09:19:34 -04:00
|
|
|
fi
|
2022-10-29 23:45:14 -04:00
|
|
|
done
|