Calculate memory usage of each VPS node

You can find memory usage of each VPS usingĀ  the following steps,

1. Create a file called vpsmemory.sh and paste the following code in it.

#!/bin/bash
count=`cat /proc/user_beancounters`
guar=`echo "$count" | grep vmguar | awk '{ print $4;}'`
pri=`echo "$count" | grep privvm | awk '{ print $2;}'`
let totl=guar/256
let used=pri/256
let free=$totl-$used
echo "VPS Memory Usage:"
echo " total: $totl mb used: $used mb free: $free mb"
2. Execute the following script to view the total memory, used memory and memory that is remaining.


# chmod 755 vpsmemory.sh
# ./vpsmemory.sh

Or

# sh vpsmemory.sh

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.