Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I checked few programs such as htop or top command but couldn't find any features for logging per minute.

Is there a way to do that for tracking memory issues ?

edit: I was using linode and decided to use Longview.

https://dl.dropboxusercontent.com/u/28301519/2013-04-18_231652.png

share|improve this question

4 Answers 4

Install and configure the sysstat package, which does just what you're asking for.

sudo apt-get install sysstat
share|improve this answer

If I were doing this I'd probably script something up with RRDtool.

RRDtool is something that is built for interval-based data-collection and then building graphs off the back of the data. If you've ever seen a netgraph on an ISPs control panel, it was probably done with RRDtool.

How you implement it is up to you. There are "pure" bash solutions with cron but there are also nice Python and Perl options floating around out there too:

If you want a lot more than this, check out Munin. This uses RRDtool prolifically to log a whole load of system data and generates static HTML pages at a set interval.

share|improve this answer

vmstat -S M 60 would do (in megabytes).

You only have to remember that actually free RAM is "free + cache + buf".

For logging purpose it might have sense to print it out time stamped which can be accomplished in various ways, for e. g.:

vmstat -nS M 60 | while read _vmstat; do echo $(date --rfc-3339=seconds) $_vmstat; done

share|improve this answer

There is one more way to do this. By using cron jobs we can get this.

* * * * * username /path/to/./script.sh

the script is simply

#!/bin/bash
echo "$(date +%Y%m%d-%H%M%S) $(free -mt | awk 'END{print $4}')" >> ~/memlog.txt

before placing the script do

chmod +x script.sh

so create above script and do it as I said then place the script at /usr/bin location . then open your /etc/crontab with

sudo nano /etc/crontab

and place the first line there . That script executes for every minute and gives memory details for every minute .

So finally that log.txt file will hold the Memory log details for every minute.

and I have got one more useful information for you that

watch cat log.txt will show the log.txt file in terminal and it will update the content live.so in the current terminal it self with one time typing you can have live watch of the log.txt file.

share|improve this answer
1  
Writing the date/time on the same might be a good idea so there's a reference point. Something like this: echo "$(date +%Y%m%d-%H%M%S) $(free -mt | awk 'END{print $4}')" >> ~/memlog.txt –  Oli Mar 14 '13 at 14:25
    
I made the edit @Oli . Thank you very much for the suggestion. –  AgentCool Mar 14 '13 at 14:30

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.