wsadmin Script to check the JVM heap size of a WebSphere Server
In response to this StackOverflow question, here’s a simple Jython wsadmin script which will display the JVM min and max heap sizes for the specified Application Server.
# Usage: wsadmin -f getJvmHeap.py server
server = AdminConfig.getid('/Server:'+sys.argv[0]+'/')
jvm = AdminConfig.list('JavaVirtualMachine', server)
print 'initialHeapSize: ' + AdminConfig.showAttribute(jvm, 'initialHeapSize')
print 'maximumHeapSize: ' + AdminConfig.showAttribute(jvm, 'maximumHeapSize')
Update: the above only obtains the heap size if a custom value has been explicitly configured. From this other post, here’s a mechanism which will obtain the maximum heap size otherwise (note there doesn’t appear to be an attribute to obtain the minimum heap size):
jvmName = AdminControl.completeObjectName('WebSphere:type=JVM,process=MyServerName,*')
print AdminControl.getAttribute(jvmName,'maxMemory')