Physical memory calculation

Below is Physical Memory result :

-bash-3.00$ prtconf | grep "Memory size"
Memory size: 36854 Megabytes
-bash-3.00$ vmstat 1 2 | tail -1
 0 0 0 28220616 1318888 15 143 0 0 0  0  0 253 2 15  0 5215 14989 5917 7  0 93

and the script i have to calculate this in Percentage is :

#!/bin/sh
totalmb=`/usr/sbin/prtconf | grep "Memory size" | awk '{print $3}'`
freemb=`vmstat 1 2 | tail -1 | awk '{print $5/1024}'`
usedmb=`/usr/bin/echo $totalmb-$freemb|/usr/bin/bc`
percentage=`echo $usedmb*100/$totalmb | bc`
echo "Percentage="$percentage"%"
-bash-3.00$ sh PhysicalMemory.sh
Percentage=96%

Can you please help me to know whether the script i am using is really showing UsedPhysicalMemory in Percentage?

Or may i have one single cmd line to see the Used/Free Physical Memory in Solaris?

-bash-3.00$ uname -a
SunOS localhost 5.10 Generic_142910-17 i86pc i386 i86pc

As customer is showing result in :

 [oracle@xxxx]/u02/app/oracle>prstat -a
     PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
  18767 oracle     10G  770M cpu11    0    0   0:03:05 4.2% oracle/1
    1242 oracle     10G 9174M sleep   57    0  89:11:01 0.2% oracle/1
  12736 oracle     10G 8571M sleep   59    0  26:05:19 0.1% oracle/1
  12748 oracle     10G 8558M sleep   59    0  26:00:07 0.1% oracle/1
  12734 oracle     10G 8574M sleep   59    0  25:58:11 0.1% oracle/1
  12744 oracle     10G 8566M sleep   59    0  26:05:31 0.1% oracle/1
  12742 oracle     10G 8561M sleep   59    0  25:49:25 0.1% oracle/1
    2952 oracle     10G   48M sleep   59    0  41:33:08 0.0% oracle/2
    2848 root     1183M  333M sleep   59    0  59:51:40 0.0% crsd.bin/47
    2200 root      138M   24M sleep   59    0  76:02:33 0.0% orarootagent.bi/25
    2220 root       85M   33M sleep  159    -  37:14:53 0.0% osysmond.bin/11
    2936 oracle     10G 5195M cpu1   101    -  11:26:20 0.0% oracle/1
    2932 oracle     10G 5193M sleep  101    -  11:29:55 0.0% oracle/1
    2246 oracle    122M   56M sleep  100    -  50:10:03 0.0% ocssd.bin/34
  22762 oracle    120M   42M sleep   59    0  23:11:09 0.0% oraagent.bin/23
    2806 oracle    503M   58M sleep   59    0  16:32:58 0.0% oracle/1
    2980 root       92M   24M sleep   59    0  38:27:58 0.0% orarootagent.bi/11
  18900 oracle     10G 8338M sleep   59    0   0:49:59 0.0% oracle/1
  18894 oracle     10G 8336M sleep   59    0   0:49:49 0.0% oracle/1
  18898 oracle     10G 8347M sleep   59    0   0:49:43 0.0% oracle/1
    2926 oracle     10G   66M sleep   59    0  12:22:57 0.0% oracle/1
  18880 oracle     10G 8350M sleep   59    0   0:50:12 0.0% oracle/1
    2199 oracle     86M   19M sleep   59    0  26:51:28 0.0% gipcd.bin/10
  18972 oracle     10G   37M sleep   59    0   0:00:00 0.0% oracle/1
  18141 oracle     10G  157M sleep   59    0   0:00:01 0.0% oracle/1
  18110 oracle     10G  221M sleep   59    0   0:00:01 0.0% oracle/2
  18890 oracle     10G 8337M sleep   59    0   0:49:49 0.0% oracle/1
  18904 oracle     10G 8335M sleep   59    0   0:50:00 0.0% oracle/1
  18968 oracle     10G   37M sleep   59    0   0:00:00 0.0% oracle/1
  18137 oracle     10G  160M sleep   59    0   0:00:01 0.0% oracle/1
  NPROC USERNAME  SWAP   RSS MEMORY      TIME  CPU
     497 oracle     14G   12G    33% 553:54:21 5.2%
      48 root     2703M  600M   1.6% 292:55:12 0.1%
       4 gnocadmi 3244K 6360K   0.0%   0:00:07 0.0%
       1 noaccess   99M   43M   0.1%   2:30:40 0.0%
       5 hpsmh      16M 2608K   0.0%   0:00:00 0.0%
       1 smmsp    1772K 3164K   0.0%   0:00:57 0.0%
       1 daemon   1404K 4156K   0.0%   0:40:32 0.0%

Customer Saying Physical Memory used is max 35 % Used, but from the logic i am calculating its 96% Used

You aren't measuring the same thing. You customer is only looking to RAM used by processes in the current zone, while your command is not detailed enough to figure out what is using the RAM.

To have a clearer view about how the RAM is used, run this command from the global zone:

echo ::memstat | mdb -k
1 Like

Thanks, But wanted to know does my code shared giving idea that this total amount of Physical memory is being used?

That depends on how you define used memory. If you use ZFS, file system cache memory will be reported as used by your command but if you use UFS, it won't. You really should run the command I suggested and post its output to figure it out.

1 Like