Skip to content

Instantly share code, notes, and snippets.

@aitseitz
Last active September 29, 2023 16:16
Show Gist options
  • Save aitseitz/279c16d614f997497ed6f396a068f7c4 to your computer and use it in GitHub Desktop.
Save aitseitz/279c16d614f997497ed6f396a068f7c4 to your computer and use it in GitHub Desktop.
Checks for RAM and SWAP Usage
#!/bin/bash
echo "free -m:"
free -m
echo " "
echo "------"
echo "sysctl vm.swappiness :"
sysctl vm.swappiness
echo " "
echo "------"
echo "cat /proc/meminfo:"
cat /proc/meminfo
echo " "
echo "------"
echo "check swap usage sorted by process names:"
#cat /proc/18361/status | grep -i "VmSwap"
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | cat
# Additional Checks with root permissions:
#echo " "
#echo "------"
#echo "sudo cat /proc/slabinfo"
#sudo cat /proc/slabinfo
#echo " "
#echo "------"
#echo "sudo slabtop"
#sudo slabtop
@aitseitz
Copy link
Author

aitseitz commented Feb 8, 2023

Change Swapiness:

Option 1: --> Temporary:

sudo sysctl vm.swappiness=10

Option 2: --> Permanently

echo "vm.swappiness=10" | sudo tee /etc/sysctl.d/500-custom-swapiness.conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment