SilverRack VPS Tips

From SilverRack - Affordable VPS Hosting - Wiki

Jump to: navigation, search

Check Your Memory

On some older VPSs, when you use "free" or "top", you don't see your individual memory information - you see the memory information for the entire machine that your VPS is one. In order to check your own memory usage, you can log into the SilverRack Control Panel and choose "VPS Information", or you can read what are called the "beancounters". These are in /proc/user_beancounters. The beancounters are special OpenVZ parameters. To make life easy, here is a script that will interpret the beancounters and tell you your memory usage:

#!/bin/bash

BEAN=`cat /proc/user_beancounters`
GUAR=`echo "$BEAN" | grep vmguar | awk '{ print $4;}'`
PRIV=`echo "$BEAN" | grep privvm | awk '{ print $2;}'`
KMEM=`echo "$BEAN" | grep kmem | awk '{ print $3;}'`

let TOTL=$GUAR/256
let KMMB=$KMEM/1048576
let PVMB=$PRIV/256
let USED=$KMMB+$PVMB
let FREE=$TOTL-$USED
if [ "$FREE" -gt "0" ]; then
  let UPER=$USED*100/$TOTL
  let FPER=100-$UPER
else
  let UPER="100"
  let FPER="0"
fi
echo "VPS Memory:"
echo "  Total: $TOTL mb  Used: $USED mb (${UPER}%)  Free: $FREE mb (${FPER}%)"

Simply copy the script and place it somewhere on your VPS. Make sure it's runnable (chmod +x) and then run it. It prints out something like this:

VPS Memory:
  Total: 320 mb  Used: 288 mb (90%)  Free: 32 mb (10%)

For more information on what exactly each beancounter parameter is, please see the OpenVZ Wiki