genswap.sh: add option to view current swappiness level

Former-commit-id: ff1ae6603e86d69d72073934dd646e0aead602e2
Former-commit-id: 176536b5c4673c2c219494a6f43e44a9204053e7
This commit is contained in:
mollusk 2018-12-19 00:53:28 -07:00
parent 7a0c927d2d
commit fa1496dccd

View File

@ -162,10 +162,17 @@ function setSwappinessLvl(){
fi
}
liveSwappiness(){
CURRENTSWAPPINESS=$(cat /proc/sys/vm/swappiness)
echo -e "\n${LCYAN}Current swappiness value: (reboot to apply any changes you set):${NC}\n"
echo -e "${LGREEN}${CURRENTSWAPPINESS}${NC}\n"
}
function help(){
echo -e "\nUsage: $0 [-a] [--auto] [-s] [--swappiness]\n\n"
echo -e "-a | --auto Automatically create and size swapfile based on physical memory\n"
echo -e "-s | --swappiness Set the swappiness value to minimize swap usage\n\n"
echo -e "-a | --auto Automatically create and size swapfile based on physical memory\n"
echo -e "-ss | --set-swappiness Set the swappiness value to minimize swap usage\n\n"
echo -e "-ls | --live-swappiness View current swappiness level"
}
function version(){
@ -198,10 +205,14 @@ case "${1}" in
version
;;
-s|--swappiness)
-ss|--set-swappiness)
setSwappinessLvl
;;
-ls|--live-swappiness)
liveSwappiness
;;
*)
help
;;