# List the Java Virtual Machines that are currently instantiated
# by this installation of WAS
# This script works on WAS version 6.1

# If you print AdminConfig.types()
# you will not see any JVM type
# You will see a JavaVirtualMachine type.
# Report some information about every JVM
# in the cell IF (and only if)
# it is currently running
# Some parts of this code are probably WAS VERSION DEPENDENT

a = "JVM"  #You may need to change this type depending on your version of WAS

alive = AdminControl.queryNames("type="+a+",*").splitlines()
if len(alive ) > 0:
    print "\nThere are",len(alive),a+("(s)"),"instantiated at this time"
    print "Required attributes\n",AdminConfig.required('JavaVirtualMachine')
    print "Optional and required attributes\n",AdminConfig.attributes('JavaVirtualMachine')
    for x in alive:
                print x
                oName = AdminControl.makeObjectName(x)
                print "- - - physical memory - - ->",AdminControl.getAttribute_jmx(oName,"maxMemory")
                print "- - - current heap size - - ->",AdminControl.getAttribute_jmx(oName,"heapSize")
                print "- - - available on heap - - ->",AdminControl.getAttribute_jmx(oName,"freeMemory")
                print "- - - Java version - - ->",AdminControl.getAttribute_jmx(oName,"javaVersion")
                print "- - - Java vendor - - ->",AdminControl.getAttribute_jmx(oName,"javaVendor")
                print "- - - how many heap dumps allowed to disk - - ->",AdminControl.getAttribute_jmx(oName,"maxHeapDumpsOnDisk")
                print "- - - available statistics - - ->",AdminControl.getAttribute_jmx(oName,"stats")

AdminConfig.reset()
