Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a VPS system with 768MB RAM. Is there any way to find out

  • what the average amount of RAM I normally use is
  • which processes normally use high RAM and CPU

so that I can see if i need to upgrade it or not?

share|improve this question

1 Answer 1

Just RAM? Not swap? I have done a dirty scripting job into that:
First we need to parse ps aux output for getting mem, command and cpu, thats done in that perl script:

@dados = `ps aux`;
for $i ( 0 .. $#dados  ) {
    @l = split('\s+', $dados[$i]);
    $j = join(',',@l[1..9]);
    print "$j,@l[ 10 .. $#l]\n";
}

Output will be a comma separated value how will be interpreted by a Rscript:

efile <- commandArgs(TRUE)
dados <- read.csv(efile[1])
mem<-sum(dados[3])
dados <- dados[order(dados[3],dados[4],decreasing=T),]
sprintf("%f %s",mem,dados[1, 'COMMAND'])

This script do the tricky of getting MEM and what command is using more MEM|CPU.

In my crontab entry I have the following line.

* * * * * perl $HOME/processstats.pl > $HOME/process.csv && Rscript --vanilla $HOME/mstats.R $HOME/process.csv >> $HOME/sysmemcpu.log 

With R you can make the graphic if needed:

Memory usage

Sorry if I used a non-standard tool for making the statistics.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.