Site icon UnixArena

LDOM – How to find the physical Memory size ?

LDM MEMORY SCRIPT

In UnixArena,we have talked more about LDOM aka Oracle VM for SPARC.But this article will provide the solution to identify the installed physical memory of the server from control domain. There is no direct command available to find out the total physical memory and un-allocated memory  from control domain.Once you have set the resources limit to control domain, all the hardware related commands and monitoring tools will display what we have  allocated to it. You can use prtidag or top command to verify it.

For an example, If you have SPARC T4-4 server, which normally comes with 256yGB physical Memory. Once you have set 16GB memory to control domain, prtdiag will display only 16GB. How can you identify the un-allocated physical memory ? If you are new to the environment, how can you identify the total  physical memory ?

Option:1

  1. Login to ILOM and to find the physical memory of the server. (#value1)
  2. Use the “ldm list” to know the currently allocated memory for primary domain and guest domains.(#value2)
  3. Subtract the physical memory from allocated memory.  (Un-allocated memory= value1-value2)

Option:2

  1. Use “ldm list-devices -a” command to know the total physical memory. (You need to add the all pieces of memory addresses from this command) (#value1)
  2. Use the “ldm list” to know the currently allocated memory for primary domain and guest domains.(#value2)
  3. Subtract the physical memory from allocated memory.  (Un-allocated memory= value1-value2)

If you go with Option#2, You need to calculate the values like below to find the (value#1 ), total physical memory.

root@UACD1:~# ldm list-devices -a memory
MEMORY
    PA                   SIZE            BOUND
    0xa00000             32M             _sys_
    0x2a00000            96M             _sys_
    0x8a00000            374M            _sys_
    0x20000000           256M            primary
    0x30000000           7424M           Guest1
    0x200000000          8G              Guest2
    0x400000000          512M            Guest3
    0x420000000          3328M           Guest1
    0x4f0000000          4352M           Guest4
    0x600000000          8G              Guest5
    0x800000000          2560M           Guest1
    0x8a0000000          5632M           Guest5
    0xa00000000          5376M           Guest2
    0xb50000000          256M            Guest1
    0xb60000000          2560M           Guest4
    0xc00000000          3840M           Guest4
    0xcf0000000          1280M
    0xd40000000          3G              Guest5
    0xe00000000          1792M           Guest6
    0xe70000000          2G              Guest5
    0xef0000000          4352M
    0x1000000000         2G              Guest5
    0x1080000000         2816M           Guest5
    0x1130000000         3328M           Guest5
    0x1200000000         256M            Guest1
    0x1210000000         7936M           Guest6
    0x1400000000         8G              Guest1
    0x1600000000         256M            primary
    0x1610000000         256M            primary
    0x1620000000         256M            primary
    0x1630000000         256M            primary
    0x1640000000         256M            primary
    0x1650000000         256M            primary
    0x1660000000         6656M
    0x1800000000         4G              Guest5
    0x1900000000         2G              primary
    0x1980000000         1280M           Guest5
    0x19d0000000         768M            primary
    0x1a00000000         2G              Guest3
    0x1a80000000         6G              Guest5
    0x1c00000000         6G              Guest1
    0x1d80000000         2G
    0x1e00000000         2560M           Guest6
    0x1ea0000000         5632M           Guest7
    0x2000000000         8G              Guest5
    0x2200000000         2G              Guest2
    0x2280000000         4G              Guest4
    0x2380000000         512M            Guest6
    0x23a0000000         256M            primary
    0x23b0000000         1280M           Guest6
    0x2400000000         2816M           Guest3
    0x24b0000000         256M            Guest5
    0x24c0000000         512M            Guest3
    0x24e0000000         2304M           Guest5
    0x2570000000         2G              Guest3
    0x25f0000000         256M            Guest5
    0x2600000000         6912M           Guest6
    0x27b0000000         1280M
    0x2800000000         6G              Guest6
    0x2980000000         256M            Guest5
    0x2990000000         1792M           Guest6
    0x2a00000000         2560M           Guest6
    0x2aa0000000         256M            Guest2
    0x2ab0000000         1280M           Guest4
    0x2b00000000         512M            Guest2
    0x2b20000000         1536M           Guest1
    0x2b80000000         256M            Guest4
    0x2b90000000         512M            Guest3
    0x2bb0000000         1280M           Guest6
    0x2c00000000         512M            Guest3
    0x2c20000000         7680M           Guest7
    0x2e00000000         8G
    0x3000000000         7936M           Guest5
    0x31f0000000         256M            Guest8
    0x3200000000         5632M           Guest3
    0x3360000000         2560M           Guest1
    0x3400000000         8G              Guest8
    0x3600000000         2G              Guest7
    0x3680000000         2G
    0x3700000000         512M            Guest7
    0x3720000000         3584M
    0x3800000000         7936M           Guest8
    0x39f0000000         256M            primary
    0x3a00000000         7424M           Guest5
    0x3bd0000000         512M            Guest1
    0x3bf0000000         256M            primary
    0x3c00000000         1792M           Guest3
    0x3c70000000         256M            Guest7
    0x3c80000000         256M            Guest5
    0x3c90000000         1792M
    0x3d00000000         2G              primary
    0x3d80000000         256M            Guest7
    0x3d90000000         1G
    0x3dd0000000         8960M           primary
root@UACD1:~#

To eliminate the above complexity, i have developed one small script .

This script can provide you the below information.

  1. Total Physical memory
  2. Allocated Physical Memory
  3. Un-allocated Physical Memory
  4. Primary and Guest Domains memory segments

Here is the sample output of the script.

root@UACD:~# ./ldm.mem.sh
----------------------------------
Total Physical Memory = 1024.0000 GB
----------------------------------

---------------------------------------
Total Allocated Physical Memory = 584 GB
---------------------------------------

------------------------------------------
Total Unallocated Physical Memory = 440.0000 GB
------------------------------------------

---------------Memory Allocations for Guest & Primary Domain-----------------
primary
    RA               PA               SIZE
    0x30000000       0x30000000       8G
------------------------------------------------------------------------------
GUEST1
    RA               PA               SIZE
    0x30000000       0x230000000      64G
------------------------------------------------------------------------------
GUEST2
    RA               PA               SIZE
    0x80000000       0x300000000000   256G
------------------------------------------------------------------------------
GUEST3
    RA               PA               SIZE
    0x80000000       0x80000000000    256G
------------------------------------------------------------------------------

What else you need ? Just grab the script and use it .

[box type=”note” ]You have to run the script from control domain as root user.[/box]

Copy the below script to your control domain and run it like above after setting the execute permission.

#!/usr/bin/bash
# Solaris LDOM (Oracle VM for SPARC)- Total Memory calculation script
ARCHI=$(echo `uname -m`)
if [ "$ARCHI" = "sun4v"  ];then
MBSEG=$(echo `/usr/sbin/ldm list-devices -a memory  |awk ' { print $2 } ' |sort -nr |grep -v SIZE |grep M |tr -d M |awk '{sum+=$1}END{print sum}' |sed '/^$/d' ` )
GBSEG=$(echo `/usr/sbin/ldm list-devices -a memory  |awk ' { print $2 } ' |sort -nr |grep -v SIZE |grep G |tr -d G |awk '{sum+=$1}END{print sum}' |sed '/^$/d' ` )
if [ -z "$MBSEG" ];
then
TOTALPHYMEM="$GBSEG"
else
if [ -z "$GBSEG" ];
then
TMBSEG=$(echo "scale=4;$MBSEG/1024" |bc )
TOTALPHYMEM="$TMBSEG"
else
TMBSEG=$(echo "scale=4;$MBSEG/1024" |bc )
TOTALPHYMEM=$(echo "$TMBSEG" "+" "$GBSEG" |bc)
fi
fi
echo "----------------------------------"
echo "Total Physical Memory = $TOTALPHYMEM GB"
echo "----------------------------------"
GBSEGUSED=$(echo `/usr/sbin/ldm list |awk ' { print $6 } ' |grep -v MEMORY |grep G|tr -d G |awk '{sum+=$1}END{print sum}' |sed '/^$/d' ` )
MBSEGUSED1=$(echo `/usr/sbin/ldm list |awk ' { print $6 } ' |grep -v MEMORY |grep M|tr -d M |awk '{sum+=$1}END{print sum}'|sed '/^$/d' ` )
if [ -z "$MBSEGUSED1" ]; then
TOTALPHYMEMUSED="$GBSEGUSED"
else
if [ -z "$GBSEGUSED" ]; then
MBSEGUSED=$(echo "scale=4;$MBSEGUSED1/1024" |bc )
TOTALPHYMEMUSED="$MBSEGUSED"
else
MBSEGUSED=$(echo "scale=4;$MBSEGUSED1/1024" |bc )
TOTALPHYMEMUSED=$(echo "$MBSEGUSED" "+" "$GBSEGUSED" |bc)
fi
fi
echo
echo "---------------------------------------"
echo "Total Allocated Physical Memory = $TOTALPHYMEMUSED GB"
echo "---------------------------------------"
echo
echo "------------------------------------------"
echo "Total Unallocated Physical Memory = $(echo "$TOTALPHYMEM" "-" "$TOTALPHYMEMUSED" |bc ) GB"
echo "------------------------------------------"
echo
echo "---------------Memory Allocations for Guest & Primary Domain-----------------"
ldm list-domain -o memory |egrep -v "NAME|MEMORY" |sed '/^$/d'
echo "------------------------------------------------------------------------------"
echo
echo "Credits:"
echo "========"
echo "Lingeswaran R"
echo "www.UnixArena.com"
echo "------------------------------------------------------------------------------"
else
echo "This server is not based on sun4v Architecture"
echo "-------------------------------------------------------------------------------"
echo "Credits:"
echo "********"
echo "Lingeswaran R"
echo "www.UnixArena.com"
echo "------------------------------------------------------------------------------"
fi

Hope this script will be useful for you.

Share it ! Comment it !! Be Sociable !!!

Exit mobile version