ProxmoxVE-HelperScripts/misc/scaling-governor.sh

58 lines
1.7 KiB
Bash
Raw Normal View History

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
header_info() {
clear
cat <<EOF
2023-01-10 11:16:26 -05:00
__________ __ __
/ ____/ __ \/ / / /
/ / / /_/ / / / /
/ /___/ ____/ /_/ /
\____/_/ \____/
Scaling Governors
EOF
}
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
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer yes or no." ;;
2022-03-25 09:28:41 -04:00
esac
done
show_menu() {
header_info
echo -e "\nProxmox IP \033[36m$(hostname -I)\033[m"
echo -e "Current Kernel \033[36m$(uname -r)\033[m\n"
available_governors=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
echo -e "Available CPU Scaling Governors\n\033[36m${available_governors}\033[m\n"
echo -e "Current CPU Scaling Governor\n\033[36m$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)\033[m\n"
options=""
i=1
for governor in $available_governors
do
options+="** ${i}) \033[36m${governor}\033[m CPU Scaling Governor\n"
((i=i+1))
done
echo -e "${options}"
echo -e "\033[31mNOTE: Settings return to default after reboot\033[m\n"
read -p "Please choose an option from the menu and press [ENTER] or x to exit." opt
2022-03-25 09:19:34 -04:00
}
show_menu
while [[ "$opt" != "" ]]; do
num_governors=$(echo "$available_governors" | wc -w)
if [[ $opt -gt 0 ]] && [[ $opt -le $num_governors ]]; then
governor=$(echo "$available_governors" | cut -d' ' -f $opt)
echo "${governor}" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
elif [[ $opt == "x" ]] || [[ $opt == "\n" ]]; then
exit
2022-03-25 09:19:34 -04:00
else
show_menu
2022-03-25 09:19:34 -04:00
fi
show_menu
done