Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-25-2006, 06:27 AM
|
#1
|
LQ Newbie
Registered: Oct 2006
Posts: 9
Rep:
|
vmstat vs. sar
hi!
I try to write a program that monitors the performance of some UNIX servers. One of the paramaters that I intend to monitor is memory usage...When I started to dig in to this problem, I was confused. There are a couple of ways to display memory related data, but none of them display directly the free/used physical/swap memory. Anyway, I'm trying to figure out which data should I use for monitoring memory: those provided by "sar -r" (I started accounting on servers) or those of "vmstat" ? Do this data differ in any way?
Thanks in advance!
|
|
|
10-25-2006, 07:01 AM
|
#2
|
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873
|
Sar can be used interactively to see the same data that can be seen using vmstat and iostat. The real value of sar is that it can keep logs of these data over a long period of time and then produce nice looking reports. This allows you to see how various system resources are being used over time. You can see if you have too little RAM on Tuesday afternoons, if the disk I/O is peaking when the Accounting Department closes their books at the end of the month, and other system performance metrics.
It is possible that sar already does what you intend to do with your program. That would mean that your program could simply run sar reports to achieve your goal.
|
|
|
10-25-2006, 07:38 AM
|
#3
|
Member
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548
Rep:
|
Good info from Stress Junkie ....
I just wanted to add, if you need the historical data (ie: to view the stats after they have happened) sar is the best tool I've found for that.
However if you want to see things real time 'top' works great and will show you what is currently happening on your system.
If you prefer the vmstat type of output, just redirect that output to a file for later review, in that way it can work like sar.
I used a very simple script to capture vmstat ouput and would cat the date and a line to it every few interations to break up the output and to show the time for a point of reference.
I think vmstat is like iostat in that the 1st observation is from since the system was up. So if you ran vmstat 1 1 The data would not be what your really after. You need that 2nd observation at the minimum. I would recomend
vmstat 30 10
that would give you 10 observations at 30 seconds apart. Use a 2nd script to append the date and a line to the same file for easier reading.
Hope this helps.
|
|
|
10-25-2006, 08:01 AM
|
#4
|
LQ Newbie
Registered: Oct 2006
Posts: 9
Original Poster
Rep:
|
thanks! that answers my question, but only partially...
problem is that the output from these data look different.
output from sar -r -f file
freemem freeswap
15:50:00 12465 7536819
output from vmstat 1 2
vmstat 1 2
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr m0 m1 m3 m4 in sy cs us sy id
0 0 0 3940976 121192 7 15 2 1 1 0 1 0 0 0 0 383 2576 3694 2 1 98
0 0 0 3769192 99744 24 30 0 0 0 0 0 0 0 0 0 384 2990 3659 1 0 99
I managed to figure out the difference of swap data: for sar uses 512-bytes bloks, while vmstat uses kbytes. that makes the numbers somewhat alike.
but when it comes to freememory, things are a little bit more difficult. in order to have relevant data, one must ignore the first row of the vmstat output(which they say that is an average...). the second row of data (free field) does not fit the output of sar (freemem field). so , again, which data should I use? which are more relevant?
thanks again!
|
|
|
10-25-2006, 11:29 AM
|
#5
|
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873
|
I understand your confusion. The problem is that system reporting utilities report different things. Most of the time you can get several different types of reports with a small change in a parameter. One example is free memory and pages swapped. The free utility man page says this:
Quote:
The -o switch disables the display of a "buffer adjusted" line. If the
-o option is not specified, free subtracts buffer memory from the used
memory and adds it to the free memory reported.
|
Other utilities have similar options. Then there is the issue of whether you are seeing empty pages on the free list, pages on the free list that can be reused by the process that just gave them up, pages on the free list that also have a copy of themselves in the swap partition, pages in the swap partition that do not have a copy of themselves anywhere in RAM.
Once you know about all of these variations in reports then you can use them to your advantage. In the end it is a good thing. It is confusing when you first start looking at these reporting utilities in depth.
The same thing applies to disk I/O reports. The numbers in a given report may be how many 512 byte or 1024 byte reads and writes are happening, or they may be the number of reads and writes on the disk that are the size of the file system's block size, which could be 4096 or higher, or they may include the number of write requests that were merged where several write requests become one I/O, or etc. etc.
The reporting utilities are difficult to compare until you learn exactly what each utility is telling you.
Last edited by stress_junkie; 10-25-2006 at 01:56 PM.
|
|
|
10-25-2006, 06:46 PM
|
#6
|
Member
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548
Rep:
|
Quote:
Originally Posted by danieldinu
thanks! that answers my question, but only partially...
problem is that the output from these data look different.
output from sar -r -f file
freemem freeswap
15:50:00 12465 7536819
output from vmstat 1 2
vmstat 1 2
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr m0 m1 m3 m4 in sy cs us sy id
0 0 0 3940976 121192 7 15 2 1 1 0 1 0 0 0 0 383 2576 3694 2 1 98
0 0 0 3769192 99744 24 30 0 0 0 0 0 0 0 0 0 384 2990 3659 1 0 99
I managed to figure out the difference of swap data: for sar uses 512-bytes bloks, while vmstat uses kbytes. that makes the numbers somewhat alike.
but when it comes to freememory, things are a little bit more difficult. in order to have relevant data, one must ignore the first row of the vmstat output(which they say that is an average...). the second row of data (free field) does not fit the output of sar (freemem field). so , again, which data should I use? which are more relevant?
thanks again!
|
Very good question. No easy answer.
I do not know the answer, but I'll tell you this. SAR does a very good job of collecting your systems data. I would let it do it's thing and not try to reinvent the wheel. However all data is relevent. I would only use vmstat output and top output when I'm spot checking performance or when I'm experiencing a performance issue. It works for me. 
|
|
|
10-26-2006, 01:29 AM
|
#7
|
LQ Newbie
Registered: Oct 2006
Posts: 9
Original Poster
Rep:
|
thank you, guys!
|
|
|
10-27-2006, 01:50 AM
|
#8
|
LQ Newbie
Registered: Oct 2006
Posts: 9
Original Poster
Rep:
|
Just one last question....When I thought I understood how to get the amount of free physical memory, I read some man pages that confused me again...
here are some outputs from those man pages:
#man sar
-r Report unused memory pages and disk blocks:
freemem
average pages available to user processes.
freeswap
disk blocks available for page swapping.
#man pagesize
The pagesize utility prints the default size of a page of
memory in bytes, as returned by getpagesize(3C)
output from "sar -r -f file"
00:00:00 freemem freeswap
00:10:00 6576 7512510
00:20:00 6452 7512319
00:30:00 6482 7512693
# pagesize
8192
does this mean that free physical memory is:
6576 x 8192 = 53870592 bytes= 52608 kbytes = 51 Mbytes
is my assumption correct?
thank you very much, again!
|
|
|
10-27-2006, 08:05 AM
|
#9
|
Member
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548
Rep:
|
Your numbers look to be right, but I would double check using top. It is very easy to get your decimal point in the wrong place, but knowing how much memory is installed and using top you should be able to verify your numbers.
Here is the memory section of top, copied from one of my servers. This is what I'm referring to.
Mem: 7711616k av, 6537444k used, 1174172k free, 0k shrd, 271520k buff
5014532k actv, 886792k in_d, 126076k in_c
Swap: 4192924k av, 5612k used, 4187312k free 5045660k cached
You appear more worried about memory than anything else for performance. How much memory is installed in this system?
|
|
|
10-27-2006, 09:29 AM
|
#10
|
LQ Newbie
Registered: Oct 2006
Posts: 9
Original Poster
Rep:
|
first of all, these data are taken from a Solaris 9 system, so "free" or "top" commands are not available.
secondly, I have 2GB RAM installed on this machine...from what I've read until know, I cannot yet state that having only 51MB of free memory is necessarly a bad thing...
finally, memory is not the only paramater I intend to monitor, but it's the one which gives me pain in the ...u know...
all I need to know for now is if my figures are correct FOR SOLARIS 9!
thanks!
|
|
|
10-27-2006, 04:07 PM
|
#11
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795
|
You assumption is correct, most of your RAM is used, which is generally a good thing.
|
|
|
All times are GMT -5. The time now is 01:58 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|