wsadmin script to print running server status with heap usage

Objective:

This python/jython (wsadmin) script will help you to print the “Running Server List” per everyNode registered under Cell(dmgr) with up time and heap usage. This script can be used in websphere application server 6.1 and above.

 

Compatibility: WAS6.1 and above

 

Script:
Running_Nodes=AdminControl.queryNames('*:type=Server,name=nodeagent,*').split(java.lang.System.getProperty("line.separator"))


print "CELLNAME: ", AdminControl.getCell()
print "HOST:     ", AdminControl.getHost()

ignorelist=['dmgr','nodeagent']
for nod in Running_Nodes:
        NodeName=AdminControl.invoke(nod ,"getNodeName()")
        Running_JVMS=AdminControl.queryNames('*:type=Server,node='+NodeName+',*').split(java.lang.System.getProperty("line.separator"))
        print "====================================================================="
        print "NODENAME:",NodeName
        print "====================================================================="
        print "--------------------------------------------"
        print "<< Running JVMs under the Node >>"
        print "--------------------------------------------"
        for Serv in Running_JVMS:
                print  AdminControl.invoke(Serv,"getName()")
        print "--------------------------------------------"

        print ""
        print ""
        print "--------------------------------------------"
        print "<< Server Runtime Information >>"
        print "--------------------------------------------"

        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 "--------------------------------------------"
print ""
print "====================================================================="


Result:

bash-3.00# ./wsadmin.sh -lang jython -username wsadmin -password wsadmin -f getHeapSizeV3.py
WASX7209I: Connected to process "dmgr" on node MWICellManager01 using SOAP connector;  The type of process is: DeploymentManager


CELLNAME:  MWICell
HOST:      as1.mwi.com


=====================================================================
NODENAME:   MWINode01
=====================================================================
--------------------------------------------
<< Running JVMs under the Node >>
--------------------------------------------
MWI_SERVER01
MWI_SERVER02
nodeagent
--------------------------------------------

--------------------------------------------
<< Server Runtime Information >>
--------------------------------------------
ServerName      : MWI_SERVER01
uptime(in days) : 27
--------------------------------------------
TotalMemory    : 122176
Usedmemory      : 87480
Usage in Percent: 71
--------------------------------------------
--------------------------------------------
ServerName      : MWI_SERVER02
uptime(in days) : 64
--------------------------------------------
TotalMemory    : 483904
Usedmemory      : 412135
Usage in Percent: 85
--------------------------------------------

=====================================================================

=====================================================================
NODENAME:   MWINode02
=====================================================================
--------------------------------------------
<< Running JVMs under the Node >>
--------------------------------------------
MWI_SERVER03
MWI_SERVER04
nodeagent
--------------------------------------------

--------------------------------------------
<< Server Runtime Information >>
--------------------------------------------
ServerName      : MWI_SERVER03
uptime(in days) : 251
--------------------------------------------
TotalMemory    : 58432
Usedmemory      : 50091
Usage in Percent: 85
--------------------------------------------
--------------------------------------------
ServerName      : MWI_SERVER04
uptime(in days) : 36
--------------------------------------------
TotalMemory    : 120704
Usedmemory      : 101834
Usage in Percent: 84
--------------------------------------------

=====================================================================

 

Hope it helps

Hey There You can check out the Websphere Connection Pool monitoring script we created here

 

For more exclusive posts like this in web, middleware and DevOps technologies. Leave your name and mail id. Trust us, we hate spam like you do.

Loading

Thanks

A K S A R A V

Write to us at [email protected]

 Follow us on Facebook or Twitter

 To Join our Community in Whatsapp – Click here