I have some doubts with memory usage.
Currently I have nagios check who measures used memory from free -m command on Linux. I added another script for memory usage from http://exchange.nagios.org/directory/Plugins/Operating-Systems/Solaris/check_mem-2Epl/details and it measures for Solaris from vmstat and for Linux from /proc/meminfo, with this new check a have a lot more usage 20 % - 30 % more on some hosts.

./check_mem.pl -f -w 90 -c 60
CRITICAL - 34.6% (439872 kB) free!|TOTAL=1272376KB;;;; USED=832504KB;127237;508950;; FREE=439872KB;;;; CACHES=418977KB;;;;

this is output from new script on Solaris host on this host I also have

    vmstat 1 2
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr s0 -- -- --   in   sy   cs us sy id
 0 0 0 1184172 474856 54 222 0  0  0  0 112 8  0  0  0  231 1735  669  1  8 91
 0 0 0 1175352 440948 16 58  0  0  0  0  0  0  0  0  0  229   83  190  0  3 97

values from vmstat and from new script are OK. I mean the script collects from vmstat values ok. I need to know what is the best way to measure memory usage on Solaris and Linux, how can I see how much OS uses and how much is used by app is it vmstat(Sunos) and /proc/meminfo (Linux) OK for that?


vmstat is not that useful to measure memory usage. It doesn't give any metric quantifying how much virtual and physical memory is used and what is using it. It is however a very good tool to measure RAM shortage. You just need to monitor the sr column (scan rate). As long as it stays equal to zero, you shouldn't worry about RAM. If it is not equal to zero, you should investigate what is demanding RAM.

To have a detailed idea about what is using your system memory, in addition to the already suggested echo ::memstat | mdb -k command, you can run prstat -n 1 -a which will give you the memory usage per user, prstat -n 1 -Z for zone usage and prstat -s rss for per process usage sorted by RAM.

In prstat output, the SWAP column shows the virtual memory used and the RSS column, the RAM used.

About kernel usage, you can run kstat -n system_pages and have a look to the pp_kernel value.

To precisely answer to your question:

how can I see how much OS uses and how much is used by app is it vmstat(Sunos) and /proc/meminfo (Linux) OK for that?

No vmstat is not OK for that on Solaris. You might run echo ::memstat | mdb -k and parse its output.

The sum of the lines "Anon" and "Exec and libs" is the RAM used by applications, The line "Kernel" reports the RAM used by the kernel, the lines "ZFS ...", "Page cache" and "Free (cachelist)" show RAM used to cache data and the line "Free (freelist)" reports unused, i.e. wasted RAM.

Note: all of the above is about Solaris.

  • thaks for that, also as i understood real usage i get from vmstat when i dont care who actualy uses, what is what i actualy want ? – klerk Jan 21 '14 at 8:36
  • @vladeli Sorry, I don't understand what you wrote. – jlliagre Jan 21 '14 at 14:37
  • ok so question just for solaris i find out for Linux, who to belive more prstat or vmstat, with prstat i can parse root, system and default values with prstat -J 1 1, so what is generaly used memory difference between vmstat and prstat, as i saw prstat can divide used memory by users? – klerk Jan 23 '14 at 11:32
  • You can believe both prstat and vmstat output. They just happen to report different things. Which are the ones you are looking for is still unclear. – jlliagre Jan 23 '14 at 11:38
  • well i looking for used memory without OS usage, as i sad i get different values with prstat and vmstat. With vmstat i get more used memory then prstat, so my question is how to calculate TOTAL USED memory – klerk Jan 23 '14 at 11:41

Yes, vmstat and /proc/meminfo are the best options On Solaris you can also use following command:

echo ::memstat | mdb –k

It is really slow (it can take up to 30minutes on some bigger systems:)), but will give you a nice overview of the memory usage, hot much is used by kernel, processes, ZFS etc.

  • 1
    ::memstat taking a excessive time was a bug that should be fixed on current system. The patch was released several years ago and is included with Solaris 10 update 8 (Nov 2010) and newer. – jlliagre Jan 20 '14 at 21:47
  • CRITICAL - 34.6% (439872 kB) free!|TOTAL=1272376KB;;;; USED=832504KB;127237;508950;; FREE=439872KB;;;; CACHES=418977KB;;;; – klerk Jan 20 '14 at 21:59
  • this output i get whit vmstat and prtconf $used_memory_kb = $total_memory_kb - $free_memory_kb, $total_memory i parse with prtconf and free_momory i parse with vmstat 1 2 – klerk Jan 20 '14 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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