Share

Thursday, December 31, 2015

Websphere Application Server heap size monitoring with wsadmin

In Middleware infrastructure, These two issues are very common.

1. Connection Pool Overflow
 2. OutOfMemory(OOM)

Both of them will lead the application to the rock bottom and application unavailability, So its always recommended to have on eye on both of these key factors, by having some kind of Run time Monitoring and alerting system tools. (Tivoli, Wily, Nagios etc..)

Sometime, We will not be having the sufficient monitoring tool to capture this OutOfMemory and Connection Pool Overflow.

That's when, we fall back into the efficient and easiest way,  which is scripting tools,  like WLST and WSADMIN etc.

Hope you have read our another post about "Connection Pool Overflow monitoring and Alerting System" if not click here

Now, here is the Jython script designed to help monitor the "HeapSize"  which can let us able to proactively measure and take action for OOM issue.

As mentioned earlier in our post, You can have some kind of scheduling tools like Autosys (or) Cron and run it in a frequent interval along with Shell/Perl script and generate an email (or) ticket.

Let me know if there is any help required in designing of Shell/perl (or) in the scheduling part.

Latest version of this code can be found here

TheCode
Running_JVMS=AdminControl.queryNames("*:type=Server,*").split(java.lang.System.getProperty("line.separator"))
ignorelist=['nodeagent','dmgr']
for JVM in Running_JVMS:
        ServerName=AdminControl.invoke(JVM ,"getName()")
        if ServerName not in ignorelist:
                JVMName=AdminControl.completeObjectName('type=JVM,process='+ServerName+',*')
                JVMObject=AdminControl.makeObjectName(JVMName)
                perf=AdminControl.completeObjectName('type=Perf,process='+ServerName+',*')
                perfObject=AdminControl.makeObjectName(perf)
                Obj=AdminControl.invoke_jmx(perfObject,"getStatsObject",[JVMObject,java.lang.Boolean('false')],['javax.management.ObjectName','java.lang.Boolean'
])
                current=Obj.getStatistic('HeapSize').getCurrent()
                used=Obj.getStatistic('UsedMemory').getCount()
                usage=float(used)/float(current)*100
                uptime=float(Obj.getStatistic('UpTime').getCount())/60/60/24
                print "--------------------------------------------"
                print "ServerName      :", ServerName
                print "uptime(in days) :", int(uptime)
                print "--------------------------------------------"
                print "CurrentUsage    :", current
                print "Usedmemory      :", used
                print "Usage in Percent:", int(usage)
                print "--------------------------------------------"



Save this with .py extention and run it with wsadmin

The Result
bash-3.00# ./wsadmin.sh -username wasadmin -password wasadmin -lang jython -f ./python_scripts/getHeapStatus.py
WASX7209I: Connected to process "dmgr" on node mwiCellManager01 using SOAP connector;  The type of process is: DeploymentManager
--------------------------------------------
ServerName      : mwi_server01
uptime(in days) : 13
--------------------------------------------
CurrentUsage    : 119936
Usedmemory      : 85675
Usage in Percent: 71
--------------------------------------------
--------------------------------------------
ServerName      : mwi_server02
uptime(in days) : 50
--------------------------------------------
CurrentUsage    : 483392
Usedmemory      : 319485
Usage in Percent: 66
--------------------------------------------



Hope it helps.

For any question related to this. Please feel free to reach us via comment.
Always you can write an email to us at admin@mwinventory.in

Cheers and Have a great and prosperous new year. Best wishes from teammwi.