• Olá Visitante, se gosta do forum e pretende contribuir com um donativo para auxiliar nos encargos financeiros inerentes ao alojamento desta plataforma, pode encontrar mais informações sobre os várias formas disponíveis para o fazer no seguinte tópico: leia mais... O seu contributo é importante! Obrigado.

Como medir a memória RAM real em um VPS OpenVZ

obelix699

GF Prata
Membro Inactivo
Entrou
Mai 1, 2007
Mensagens
391
Gostos Recebidos
0
Hoje acedi á pagina web da minha vps e tinha a ram no "red line", achei estranho e lembrei-me de procurar por isto no google, usei deu um jeitão e como tal vou partilha-lo com o pessoal:

Free is a little bash script for use on a Virtuozzo or OpenVz VPS to display the current memory usage at the command line.

#!/bin/bash
#
# Revised 02-Feb-2007: include kernel memory (kmemsize) in 'used' calculation
# and show percentages in output.
#
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}%)"




Instructions:

Copy the above code and as root paste and save it as /bin/Free
(that's "Free" with a capital "F").
Make it executable: chmod 700 /bin/Free

Try it out:

[root@vps]# Free
VPS Memory:
Total: 256 mb Used: 92 mb (35%) Free: 164 mb (65%)

Negative value for amount free:

If you see a negative value, e.g., Free: -20 mb this means you are current exceeding your allocated guaranteed memory (i.e., you're using burst memory).

Note:

On Virtuozzo v.3 or OpenVZ you can only use Free as root. If you want to use it as a non-root user you'll need to:

Install the beanc helper app.
Change line 6 of the Free script to:
BEAN=`beanc`
Make Free executable by everyone: chmod 755 /bin/Free


Fonte: LabradorData
 
Última edição:

mlcalves

GF Ouro
Membro Inactivo
Entrou
Mai 20, 2010
Mensagens
2,278
Gostos Recebidos
0
Gostei :) Mas por norma vejo no ipc server ou no painel de controlo da minha vps mas normalmente está a 30%
 
Topo