This article describes how Memory usage is calculated on Solaris box
How does CDM calculate QOS_PHYSICAL_MEMORY_PERC in Solaris?
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
Buffers and Cached memory (zfs for global and local zone) are counted as free unless the customer sets mem_buffer_used=yes
If set for mem_buffer_used=no
Formula: Used Physical - ( ZFS File Data + Exec and libs + Page cache)
Free (cachelist) is not included in formula due fixed issue CDM probe (on Solaris) reporting negative memory values))
So the QOS_MEMORY_PHYSICAL metric, by default, excludes the buffer and cache.
Cdm probe shows wrong Physical Memory on AIX and Linux Servers
Article Id: 47141
Feb 6 13:19:10:413  cdm: (GetMemoryInfo) - swap element 0: 17039360 pages (133120 MB), 15421011 free (120476 MB)
Feb 6 13:19:10:413  cdm: (GetMemoryInfo) - before excluding zfs cache and buffers: Total Physical: 131072 Used Physical: 115731
Feb 6 13:19:10:429  cdm: (get_zone_is_global) value - 0
Feb 6 13:19:10:430  cdm: (data_buffer) Collection ZFS cache on Local zone
Feb 6 13:19:10:430  cdm: is zone brand kz ? 0
Feb 6 13:19:10:430  cdm: (GetMemoryInfo) - after excluding zfs cache and buffers: Total Physical: 131072 Used Physical: 115731
Feb 6 13:19:10:430  cdm: (GetMemoryInfo) - Total: 264192 Physical: 131072 Swap: 133120
Feb 6 13:19:10:430  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.