From fa1496dccdbb029c7d9e69765a9577cfbd7bbe22 Mon Sep 17 00:00:00 2001 From: mollusk Date: Wed, 19 Dec 2018 00:53:28 -0700 Subject: [PATCH] genswap.sh: add option to view current swappiness level Former-commit-id: ff1ae6603e86d69d72073934dd646e0aead602e2 Former-commit-id: 176536b5c4673c2c219494a6f43e44a9204053e7 --- genswap.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/genswap.sh b/genswap.sh index e7161e1..4ce74d6 100755 --- a/genswap.sh +++ b/genswap.sh @@ -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 ;;