LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-05-2011, 08:37 AM   #1
alirz
LQ Newbie
 
Registered: Jun 2011
Posts: 19

Rep: Reputation: Disabled
how to get free memory stat for the past few days


im trying to collect some data.
Is there a way to get the free memory stats over the past few days from some file...
i looked into the sar log files but they dont have date stamps in them!
 
Old 07-05-2011, 08:56 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Sar, if set up correctly, places 31 files in /var/log/sa. Each file represents a previous date/day.

Code:
sar -f /var/log/sa/sa04
The above example will show yesterdays info.

Hope this helps.
 
Old 07-05-2011, 08:57 AM   #3
alirz
LQ Newbie
 
Registered: Jun 2011
Posts: 19

Original Poster
Rep: Reputation: Disabled
Or if somehow its possible to collect some memory data for the past few days from the sar files that linux stores at /var/log/sa/

for a given day's sar file(its a very long file) e.g sar21, somewhere in the file the memory is listed as:

00:00:01 kbmemfree kbmemused %memused kbbuffers kbcached kbswpfree kbswpused %swpused kbswpcad
00:10:01 1385912 48065600 97.20 475672 23967824 16478504 301348 1.80 288644
00:20:01 2993564 46457948 93.95 464720 22337572 16478504 301348 1.80 288708

and towards the end of the day it also lists the average:

23:50:01 1003292 48448220 97.97 666296 25555924 16478500 301352 1.80 290164
Average: 1096417 48355095 97.78 555984 25517802 16478500 301352 1.80 290096

I'm trying to find a way to be able to get just the Average for the kbcached column along with the date that sar file was created as there is no date information inside the file, just time.
all my awk, grep attempts are not giving me what i need. Could someone please help?

Im trying to get my output to look something like:

Jul 1 23454545
Jul 2 78645654
Jul 3 76735443
jul 4 63537644
 
Old 07-05-2011, 08:59 AM   #4
alirz
LQ Newbie
 
Registered: Jun 2011
Posts: 19

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
Hi,

Sar, if set up correctly, places 31 files in /var/log/sa. Each file represents a previous date/day.

Code:
sar -f /var/log/sa/sa04
The above example will show yesterdays info.

Hope this helps.
thanks druuna but that gives me cpu info and thats not what im trying to get . Thanks though.
 
Old 07-05-2011, 09:20 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

The example I gave was just that; An example. It wasn't clear at the time of replying that you knew /var/log/sa holds all the daily files

About your problem:

The date _is_ in the file (first line). A quick one-liner I came up with:
Code:
S_TIME_FORMAT=ISO sar -r -f /var/log/sa/sa22 | awk 'NR == 1 { printf $4 } ; /Average:/ { print " : " $6 }'

# output
2011-06-22 : 1364496
Not exactly what you want/need, but I hope it helps.
 
Old 07-05-2011, 09:36 AM   #6
alirz
LQ Newbie
 
Registered: Jun 2011
Posts: 19

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
Hi,

The example I gave was just that; An example. It wasn't clear at the time of replying that you knew /var/log/sa holds all the daily files

About your problem:

The date _is_ in the file (first line). A quick one-liner I came up with:
Code:
S_TIME_FORMAT=ISO sar -r -f /var/log/sa/sa22 | awk 'NR == 1 { printf $4 } ; /Average:/ { print " : " $6 }'

# output
2011-06-22 : 1364496
Not exactly what you want/need, but I hope it helps.
well the result it gives me for that day is good. Shouldnt it be possible to run this command on all sa files in the directory?
Also any difference between the sa and the sar files?
 
Old 07-05-2011, 09:47 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,
Quote:
Originally Posted by alirz View Post
well the result it gives me for that day is good. Shouldnt it be possible to run this command on all sa files in the directory?
Yes, that is possible:
Code:
for FILE in /var/log/sa/sa[0-9]*; do S_TIME_FORMAT=ISO sar -r -f $FILE | awk 'NR == 1 { printf $4 } ; /Average:/ { print " : " $6 }'; done
Quote:
Also any difference between the sa and the sar files?
Sa files are data files, sar files are reports.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sar output for the past 4 days ZAMO Linux - Enterprise 2 12-24-2008 05:00 PM
NFS errors for the past few days dougtheslug Linux - Server 14 03-12-2008 01:06 PM
fc4 no. 8 on most downloads in past 30 days???? bendeco13 Linux - Software 5 08-22-2007 04:45 PM
Cedega - Free for 14 days!! shazam75 Linux - Games 1 11-05-2005 12:48 AM
Been trying to install Red Hat 7.0 for the past 3 days w/o success, HELP!!! jayman626 Linux - Software 6 07-16-2001 02:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration