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?
Best Answer
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 thesr
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 runprstat -n 1 -a
which will give you the memory usage per user,prstat -n 1 -Z
for zone usage andprstat -s rss
for per process usage sorted by RAM.In
prstat
output, theSWAP
column shows the virtual memory used and theRSS
column, the RAM used.About kernel usage, you can run
kstat -n system_pages
and have a look to thepp_kernel
value.To precisely answer to your question:
No
vmstat
is not OK for that on Solaris. You might runecho ::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.