Solaris / OpenSolarisThis 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.
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.
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?
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.
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.
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?
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.
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.
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.
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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.