mirror of https://github.com/tteck/Proxmox.git
Compare commits
4 Commits
7305fa4f0a
...
7a22dbfa98
Author | SHA1 | Date |
---|---|---|
|
7a22dbfa98 | |
|
65d6956819 | |
|
a153da3465 | |
|
6b10aa922a |
|
@ -2,6 +2,14 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
|
||||||
|
## 2023-03-08
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Proxmox CPU Scaling Governor**
|
||||||
|
- Menu options dynamically based on the available scaling governors.
|
||||||
|
|
||||||
## 2023-03-07
|
## 2023-03-07
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -5,20 +5,17 @@
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
|
|
||||||
function header_info {
|
header_info() {
|
||||||
cat <<"EOF"
|
clear
|
||||||
|
cat <<EOF
|
||||||
__________ __ __
|
__________ __ __
|
||||||
/ ____/ __ \/ / / /
|
/ ____/ __ \/ / / /
|
||||||
/ / / /_/ / / / /
|
/ / / /_/ / / / /
|
||||||
/ /___/ ____/ /_/ /
|
/ /___/ ____/ /_/ /
|
||||||
\____/_/ \____/
|
\____/_/ \____/
|
||||||
Scaling Governors
|
Scaling Governors
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
set -e
|
|
||||||
while true; do
|
while true; do
|
||||||
read -p "View CPU Scaling Governors. Proceed(y/n)?" yn
|
read -p "View CPU Scaling Governors. Proceed(y/n)?" yn
|
||||||
case $yn in
|
case $yn in
|
||||||
|
@ -27,89 +24,34 @@ while true; do
|
||||||
*) echo "Please answer yes or no." ;;
|
*) echo "Please answer yes or no." ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
clear
|
|
||||||
|
|
||||||
show_menu() {
|
show_menu() {
|
||||||
CL=$(echo "\033[m")
|
|
||||||
GN=$(echo "\033[32m")
|
|
||||||
BL=$(echo "\033[36m")
|
|
||||||
YW=$(echo "\033[33m")
|
|
||||||
fgred=$(echo "\033[31m")
|
|
||||||
header_info
|
header_info
|
||||||
CK=$(uname -r)
|
echo -e "\nProxmox IP \033[36m$(hostname -I)\033[m"
|
||||||
IP=$(hostname -I)
|
echo -e "Current Kernel \033[36m$(uname -r)\033[m\n"
|
||||||
# MAC=$(cat /sys/class/net/eno1/address)
|
available_governors=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
|
||||||
ACSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
|
echo -e "Available CPU Scaling Governors\n\033[36m${available_governors}\033[m\n"
|
||||||
CCSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
|
echo -e "Current CPU Scaling Governor\n\033[36m$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)\033[m\n"
|
||||||
echo -e "${YW}Proxmox IP ${BL}${IP}${CL}"
|
options=""
|
||||||
|
i=1
|
||||||
echo -e "${YW}MAC Address ${BL}${MAC}${CL}"
|
for governor in $available_governors
|
||||||
|
do
|
||||||
echo -e "${YW}Current Kernel ${BL}${CK}${CL}"
|
options+="** ${i}) \033[36m${governor}\033[m CPU Scaling Governor\n"
|
||||||
|
((i=i+1))
|
||||||
echo -e "\n${YW}Available CPU Scaling Governors
|
done
|
||||||
${BL}${ACSG}${CL}"
|
echo -e "${options}"
|
||||||
|
echo -e "\033[31mNOTE: Settings return to default after reboot\033[m\n"
|
||||||
echo -e "\n${YW}Current CPU Scaling Governor
|
read -p "Please choose an option from the menu and press [ENTER] or x to exit." opt
|
||||||
${BL}${CCSG}${CL}"
|
|
||||||
printf "\n ${fgred}Only Select Available CPU Scaling Governors From Above${CL}\n \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${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
}
|
||||||
clear
|
|
||||||
show_menu
|
show_menu
|
||||||
while [ "$opt" != "" ]; do
|
while [[ "$opt" != "" ]]; do
|
||||||
if [ "$opt" = "" ]; then
|
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
|
exit
|
||||||
else
|
else
|
||||||
case $opt in
|
show_menu
|
||||||
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
|
fi
|
||||||
|
show_menu
|
||||||
done
|
done
|
||||||
|
|
|
@ -15,31 +15,6 @@ while true; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd $TEMP_DIR >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
CHAR_DEVS+=("166:.*")
|
CHAR_DEVS+=("166:.*")
|
||||||
|
|
Loading…
Reference in New Issue