How does CDM calculate Memory Usage in Solaris?

Document ID : KB000129017
Last Modified Date : 08/03/2019
Show Technical Document Details
Introduction:
This article describes how Memory usage is calculated on Solaris box
Question:
How does CDM calculate QOS_PHYSICAL_MEMORY_PERC in Solaris?
Answer:
To calculate Physical Memory Usage (“QOS_PHYSICAL_MEMORY_PERC”) on Solaris the probe does not use any tool or utility ( "prstat -Z") but it uses APIs to get the physical memory information.


Get the total physical memory 


Phys Mem Pages = sysconf(_SC_PHYS_PAGES) 

Total Physical Memory = multiplied by the Page Size * number of Mem Pages 



Get physical available memory information 

Phys Avail Mem Pages = sysconf(_SC_AVPHYS_PAGES); 

Availabe Physical Memory = multiplied by the Page Size * number of Phys Avail Mem Pages 


Get physical memory usage information 

Physical Memory Used = Total Physical Memory - Availabe Physical Memory 


QOS_MEMORY_PHYSICAL (Physical Memory Used) = Physical Memory Used – Data Buffer and Cache 



Get physical memory usage percentage information

QOS_MEMORY_PHYSICAL_PERC (Physical Memory Used %) = (Physical Memory Used/Total Physical Memory) * 100 



Note: 
Buffers and Cached memory (zfs for global and local zone) are counted as free unless the customer sets mem_buffer_used=yes 
So the QOS_MEMORY_PHYSICAL metric, by default, excludes the buffer and cache. (see KB000047141

Feb 6 13:19:10:413 [0001] cdm: (GetMemoryInfo) - swap element 0: 17039360 pages (133120 MB), 15421011 free (120476 MB) 
Feb 6 13:19:10:413 [0001] cdm: (GetMemoryInfo) - before excluding zfs cache and buffers: Total Physical: 131072 Used Physical: 115731 
Feb 6 13:19:10:429 [0001] cdm: (get_zone_is_global) value - 0 
Feb 6 13:19:10:430 [0001] cdm: (data_buffer) Collection ZFS cache on Local zone 
Feb 6 13:19:10:430 [0001] cdm: is zone brand kz ? 0 
Feb 6 13:19:10:430 [0001] cdm: (GetMemoryInfo) - after excluding zfs cache and buffers: Total Physical: 131072 Used Physical: 115731 
Feb 6 13:19:10:430 [0001] cdm: (GetMemoryInfo) - Total: 264192 Physical: 131072 Swap: 133120 
Feb 6 13:19:10:430 [0001] cdm: (GetMemoryInfo) - Used : 128375 Physical: 115731 Swap: 12644 


Other Memory usage information: 

- Swap usage is found using the system call swapctl(). 

- Paging data is found by running either “/usr/bin/vmstat –s” or “/usr/5bin/vmstat –s” (depending on which is installed on the system) and parsing the data it provides. 
 
Additional Information:
Cdm probe shows wrong Physical Memory on AIX and Linux Servers
https://comm.support.ca.com/kb/cdm-probe-shows-wrong-physical-memory-on-aix-and-linux-servers/KB000047141