It's all about the answers!

Ask a question

Dynamically populating the CLM_WAS_CONFIG script with system memory


Karl Athanasiou (3121317) | asked Mar 26 '15, 5:48 p.m.
All,
I think the answering this might benefit alot of people who need to automate the deployment or the CLM Suite via WAS.

In the clm_was_config script you set the JVM arguments in the following code block:


#########################################################
# Java Virtual Machine configurations                   #
#########################################################

servers = AdminTask.listServers('[-serverType APPLICATION_SERVER ]')
if (servers != ['']):
    servers = servers [0:len(servers)].split(lineSeparator)
    for server in servers:
        print "Setting configuration for Application Server " + AdminConfig.showAttribute(server, "name")
        jvm = AdminConfig.list('JavaVirtualMachine', server)
       
        try:
            _excp_ = 0
            result = AdminConfig.modify(jvm, [['initialHeapSize', 4G],['maximumHeapSize', 4G]])
            print "Set initial and max heap size to "heap
        except:
            _type_, _value_, _tbck_ = sys.exc_info()
            result = `_value_`
            _excp_ = 1
        #endTry
        if (_excp_ ):
            print "Error modifying JVM heap size for Appserver "+AdminConfig.showAttribute(server, "name")
            print "Error = "+result
        #endIf
       
        #########################################################
        # Set recommended JVM args                              #
        #########################################################
        try:
            _excp_ = 0
            os_arch = java.lang.System.getProperty('os.arch')
            os_name = java.lang.System.getProperty('os.name')
            is_64 = os_arch.find('64')
            is_Solaris = os_name.find('SunOS')
            is_MacOS = os_name.find('Darwin')
            is_AIX = os_name.find('AIX')
            if (is_64 != -1):
                if ((is_Solaris != -1) or (is_MacOS != -1)):
                    result = AdminConfig.modify(jvm, [['genericJvmArguments', '-Xmx[heap]m -Xms[heap]m -Xmn512m -XX:MaxPermSize=768M -XX:ReservedCodeCacheSize=512M -XX:CodeCacheMinimumFreeSpace=2M']])
                    print "Set JVM args -Xmx4g -Xms4g -Xmn512m -XX:MaxPermSize=768M -XX:ReservedCodeCacheSize=512M -XX:CodeCacheMinimumFreeSpace=2M"
                elif (is_AIX != -1):
                    result = AdminConfig.modify(jvm, [['genericJvmArguments', '-Xmx4g -Xms4g -Xmn512m -Xgcpolicy:gencon -Xnocompressedrefs']])
                    print "Set JVM args -Xmx4g -Xms4g -Xmn512m -Xgcpolicy:gencon -Xnocompressedrefs"
                else:
                    result = AdminConfig.modify(jvm, [['genericJvmArguments', '-Xmx2g -Xms2g -Xmn512m -Xgcpolicy:gencon -Xcompressedrefs -Xgc:preferredHeapBase=0x100000000 -verbose:gc -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=1G']])
                    print "Set JVM args -Xmx4g -Xms4g -Xmn512m -Xgcpolicy:gencon -Xcompressedrefs -Xgc:preferredHeapBase=0x100000000 -verbose:gc -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=1G"
                #endIf
            else:
                result = AdminConfig.modify(jvm, [['genericJvmArguments', '-Xmx1200m']])
                print "Set JVM args -Xmx1200m"
            #endIf
        except:
            _type_, _value_, _tbck_ = sys.exc_info()
            result = `_value_`
            _excp_ = 1
        #endTry
        if (_excp_ ):
            print "Error setting JVM args"
            print "Error = "+result
        #endIf

now what this does is sets your min/max heaps and sets your JVM arguments..
What I am attempting to do is set a dynamically populated variable so when I execute  this script the min/max is set with 50 percent of my system memory...
Would someone who is more familiar with Jython and wsadmin be willing to lend a hand?

What I have come up with is very clumsy and has too many steps..
My os is RHEL..
cat /proc/meminfo |grep -i memtotal | awk '{print $2}'
That displays my total available memory in kb..
so I set that as a system variable called sysmem

I then divide that by 1024 then 1024 again for Gb and then by 2
I am attempting to read that file into a variable that I then use for all of my settings.

There has to be a more elegant way..
Any help would be GREATLY appreciated

regards,
Karl

Be the first one to answer this question!


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.