Enable PMI using wsadmin
Using wsadmin, we can invoke operations on Perf Mbean to...
- obtain the PMI data
- set or obtain PMI monitoring levels
- enable data counters
First enable PMI data by invoking setInstrumentationLevel operation on PerfMBean.
The following operations in Perf MBean can be used in wsadmin:
If an MBean is a StatisticProvider, and if we pass its ObjectName to getStatsObject, you get the Statistic data for that MBean. MBeans with the following MBean types are statistic providers:
- DynaCache
- EJBModule
- EntityBean
- JDBCProvider
- J2CResourceAdapter
- JVM
- MessageDrivenBean
- ORB
- Server
- SessionManager
- StatefulSessionBean
- StatelessSessionBean
- SystemMetrics
- ThreadPool
- TransactionService
- WebModule
- Servlet
- WLMAppServer
- WebServicesService
- WSGW
Obtain the Perf MBean ObjectName
set perfName [$AdminControl completeObjectName type=Perf,*]
set perfOName [$AdminControl makeObjectName $perfName]
Invoke getStatisticSet operation
Find the statistic set that is currently in effect:
$AdminControl invoke $perfName getStatisticSetThis method returns one of the following values:
- basic
- extended
- all
- none
Invoke setStatisticSet operation
Enable monitoring using a statistic set.
set params [java::new {java.lang.Object[]} 1]
$params set 0 [java::new java.lang.String extended]
set sigs [java::new {java.lang.String[]} 1]
$sigs set 0 java.lang.String
$AdminControl invoke_jmx $perfOName setStatisticSet $params $sigsThe valid statistic set values are:
- basic
- extended
- all
- none
Invoke getConfig operation
Find information about the statistics for a given component.
set jvmName [$AdminControl completeObjectName type=JVM,*]
set params [java::new {java.lang.Object[]} 1]
$params set 0 [java::new javax.management.ObjectName $jvmName]
set sigs [java::new {java.lang.String[]} 1]
$sigs set 0 javax.management.ObjectName
$AdminControl invoke_jmx $perfOName getConfig $params $sigsThis method returns the following:
Stats type=jvmRuntimeModule, Description=The performance data from the Java virtual machine run time.
{name=UpTime, ID=4, type=CountStatistic, description=The amount of time (in seconds) that the Java virtual machine has been running., unit=SECOND, level=low, statisticSet=basic, resettable=false, aggregatable=true}
{name=UsedMemory, ID=3, type=CountStatistic, description=The amount of used memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, level=low, statisticSet=basic, resettable=false, aggregatable=true}
{name=FreeMemory, ID=2, type=CountStatistic, description=The free memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, level=low, statisticSet=all, resettable=false, aggregatable=true}
{name=HeapSize, ID=1, type=BoundedRangeStatistic, description=The total memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, level=high, statisticSet=basic, resettable=false, aggregatable=true}
Invoke getCustomSetString operation
This operation provides the current monitoring spec in a string format:
$AdminControl invoke $perfName getCustomSetStringThe output looks similar to the following:
jvmRuntimeModule=4,3,1: systemModule=2,1: threadPoolModule=4,3: thread PoolModule>HAManager.thread.pool=4,3: threadPoolModule>MessageListenerTh readPool=4,3: threadPoolModule>ORB.thread.pool=4,3: threadPoolModule>Servlet.Engine.Transports=4,3: threadPoolModule>TCS_DEFAULT=4,3: transactionModule=4,19,16,18,3,7,6,1,14This output indicates that statistic ID's 1, 3, and 4 are enabled in the JVM component. The description of the statistic IDs can be found using the above getConfig operation or using the API documentation. The output contains the current monitoring spec for the entire server. The individual modules are separated by a :, and > is used as a separator within the module.
Invoke setCustomSetString operation
This operation can be used to enable or disable statistics selectively. In the following command the statistic IDs 1, 2, 3, and 4 are enabled for the JVM module. To enable all the statistic IDs use an asterisk (*).
set params [java::new {java.lang.Object[]} 2]
$params set 0 [java::new java.lang.String jvmRuntimeModule=1,2,3,4]
$params set 1 [java::new java.lang.Boolean false]
set sigs [java::new {java.lang.String[]} 2]
$sigs set 0 java.lang.String
$sigs set 1 java.lang.Boolean
$AdminControl invoke_jmx $perfOName setCustomSetString $params $sigs
Invoke getStatsObject operation
This operation is used to get the statistics for a given MBean.
The following example gets the statistics for the JVM:
set jvmName [$AdminControl completeObjectName type=JVM,*]
set params [java::new {java.lang.Object[]} 2]
$params set 0 [java::new javax.management.ObjectName $jvmName]
$params set 1 [java::new java.lang.Boolean false]
set sigs [java::new {java.lang.String[]} 2]
$sigs set 0 javax.management.ObjectName
$sigs set 1 java.lang.Boolean
$AdminControl invoke_jmx $perfOName getStatsObject $params $sigsStats name=jvmRuntimeModule, type=jvmRuntimeModule# { name=HeapSize, ID=1, description=The total memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, type=BoundedRangeStatistic, lowWaterMark=51200, highWaterMark=263038, current=263038, integral=2.494158617766E12, lowerBound =51200, upperBound=262144 name=FreeMemory, ID=2, description=The free memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, type=CountStatistic, count=53509 name=UsedMemory, ID=3, description=The amount of used memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, type=CountStatistic, count=209528 name=UpTime, ID=4, description=The amount of time (in seconds) that the Java virtual machine has been running., unit=SECOND, type=CountStatistic, count=83050 }
Invoke getInstrumentationLevelString operation
Use invoke, because it has no parameter.
$AdminControl invoke $perfName getInstrumentationLevelStringThis command returns the following:
beanModule=H:cacheModule=H:connectionPoolModule=H:j2cModule=H:jvmRuntimeModule=H:orbPerfModule=H:servletSessionsModule=H:systemModule= H:threadPoolModule=H:transactionModule=H:webAppModule=HYou can change the level (n, l, m, h, x) in the above string and then pass it to setInstrumentationLevel method.
Invoke setInstrumentationLevel operation - enable/disable PMI counters
- Set parameters ("pmi=l" is the simple way to set all modules to the low level).
set params [java::new {java.lang.Object[]} 2]
$params set 0 [java::new java.lang.String pmi=l]
$params set 1 [java::new java.lang.Boolean true]- Set signatures.
set sigs [java::new {java.lang.String[]} 2]
$sigs set 0 java.lang.String
$sigs set 1 java.lang.Boolean- Invoke the method. Use invoke_jmx, because it has a parameter.
$AdminControl invoke_jmx $perfOName setInstrumentationLevel $params $sigsThis command does not return anything.
The PMI level string can be as simple as pmi=level (where level is n, l, m, h, or x), or something like module1=level1:module2=level2:module3=level3 with the same format shown in the string returned from getInstrumentationLevelString.
Invoke getStatsString(ObjectName, Boolean) operation
If we know the MBean ObjectName, we can invoke the method by passing the right parameters. As an example, JVM MBean is used here.
- Get MBean query string. For example, JVM MBean.
set jvmName [$AdminControl completeObjectName type=JVM,*]- Set parameters.
set params [java::new {java.lang.Object[]} 2]
$params set 0 [$AdminControl makeObjectName $jvmName]
$params set 1 [java::new java.lang.Boolean true]- Set signatures.
set sigs [java::new {java.lang.String[]} 2]
$sigs set 0 javax.management.ObjectName
$sigs set 1 java.lang.Boolean- Invoke method.
$AdminControl invoke_jmx $perfOName getStatsString $params $sigsThis command returns the following:
{Description jvmRuntimeModule.desc} {Descriptor {{Node wenjianpc} {Server server 1} {Module jvmRuntimeModule} {Name jvmRuntimeModule} {Type MODULE}}} {Level 7} { Data {{{Id 4} {Descriptor {{Node wenjianpc} {Server server1} {Module jvmRuntimeM odule} {Name jvmRuntimeModule} {Type DATA}}} {PmiDataInfo {{Name jvmRuntimeModul e.upTime} {Id 4} {Description jvmRuntimeModule.upTime.desc} {Level 1} {Comment { The amount of time in seconds the JVM has been running}} {SubmoduleName null} {T ype 2} {Unit unit.second} {Resettable false}}} {Time 1033670422282} {Value {Coun t 638} }} {{Id 3} {Descriptor {{Node wenjianpc} {Server server1} {Module jvmRunt imeModule} {Name jvmRuntimeModule} {Type DATA}}} {PmiDataInfo {{Name jvmRuntimeM odule.usedMemory} {Id 3} {Description jvmRuntimeModule.usedMemory.desc} {Level 1 } {Comment {Used memory in JVM runtime}} {SubmoduleName null} {Type 2} {Unit uni t.kbyte} {Resettable false}}} {Time 1033670422282} {Value {Count 66239} }} {{Id 2} {Descriptor {{Node wenjianpc} {Server server1} {Module jvmRuntimeModule} {Nam e jvmRuntimeModule} {Type DATA}}} {PmiDataInfo {{Name jvmRuntimeModule.freeMemor y} {Id 2} {Description jvmRuntimeModule.freeMemory.desc} {Level 1} {Comment {Fre e memory in JVM runtime}} {SubmoduleName null} {Type 2} {Unit unit.kbyte} {Reset table false}}} {Time 1033670422282} {Value {Count 34356} }} {{Id 1} {Descriptor {{Node wenjianpc} {Server server1} {Module jvmRuntimeModule} {Name jvmRuntimeMod ule} {Type DATA}}} {PmiDataInfo {{Name jvmRuntimeModule.totalMemory} {Id 1} {Des cription jvmRuntimeModule.totalMemory.desc} {Level 7} {Comment {Total memory in JVM runtime}} {SubmoduleName null} {Type 5} {Unit unit.kbyte} {Resettable false} }} {Time 1033670422282} {Value {Current 100596} {LowWaterMark 38140} {HighWaterM ark 100596} {MBean 38140.0} }}}}
Invoke getStatsString (ObjectName, String, Boolean) operation
This operation takes an additional String parameter, and it is used for PMI modules that do not have matching MBeans. In this case, the parent MBean is used with a String name representing the PMI module. The String names available in an MBean can be found by invoking listStatMemberNames. For example, beanModule is a logic module aggregating PMI data over all EJBs, but there is no MBean for beanModule. Therefore, we can pass server MBean ObjectName and a String (beanModule) to get PMI data in beanModule.
- Get MBean query string. For example, server MBean
set mySrvName [$AdminControl completeObjectName type=Server,name=server1, node=wenjianpc,*]- Set parameters.
set params [java::new {java.lang.Object[]} 3]
$params set 0 [$AdminControl makeObjectName $mySrvName]
$params set 1 [java::new java.lang.String beanModule]
$params set 2 [java::new java.lang.Boolean true]- Set signatures.
set sigs [java::new {java.lang.String[]} 3]
$sigs set 0 javax.management.ObjectName
$sigs set 1 java.lang.String
$sigs set 2 java.lang.Boolean- Invoke method.
$AdminControl invoke_jmx $perfOName getStatsString
$params $sigsThis command returns PMI data in all the Enterprise Java Beans within the BeanModule hierarchy because the recursive flag is set to true.
This method is used to get stats data for the PMI modules that do not have direct MBean mappings.
Invoke listStatMemberNames operation
- Get MBean queryString. For example, Server.
set mySrvName [$AdminControl completeObjectName type=Server,name=server1, node=wenjianpc,*]- Set parameter.
set params [java::new {java.lang.Object[]} 1]
$params set 0 [$AdminControl makeObjectName $mySrvName]- Set signatures.
set sigs [java::new {java.lang.String[]} 1]
$sigs set 0 javax.management.ObjectName
$AdminControlinvoke_jmx $perfOName listStatMemberNames $params $sigsThis command returns the PMI module and submodule names, which have no direct MBean mapping. The names are seperated by a space " ". We can then use the name as the String parameter in getStatsString method. For example:
beanModule connectionPoolModule j2cModule servletSessionsModule threadPoolModule webAppModuleCustomize and run the following example Jython script with wsadmin to obtain PMI data:
print "\n---------------------------------------------------------------------------------- " print "Obtain the Perf MBean ObjectName" print "---------------------------------------------------------------------------------- " perfName = AdminControl.completeObjectName ('type=Perf,*') perfOName = AdminControl.makeObjectName (perfName) print perfOName print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke getStatisticSet operation " print "---------------------------------------------------------------------------------- " print AdminControl.invoke (perfName, 'getStatisticSet') print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke setStatisticSet operation" print "---------------------------------------------------------------------------------- " params = ['extended'] sigs = ['java.lang.String'] print AdminControl.invoke_jmx (perfOName, 'setStatisticSet', params, sigs) print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke getConfig operation" print "---------------------------------------------------------------------------------- " jvmName = AdminControl.completeObjectName ('type=JVM,*') params = [AdminControl.makeObjectName (jvmName)] sigs = ['javax.management.ObjectName'] print AdminControl.invoke_jmx (perfOName, 'getConfig', params, sigs) print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke getCustomSetString operation" print "---------------------------------------------------------------------------------- " print AdminControl.invoke (perfName, 'getCustomSetString') print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke setCustomSetString operation" print "---------------------------------------------------------------------------------- " params = ['jvmRuntimeModule=1,2,3,4', java.lang.Boolean ('false')] sigs = ['java.lang.String', 'java.lang.Boolean'] print AdminControl.invoke_jmx (perfOName, 'setCustomSetString', params, sigs) print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke getStatsObject operation" print "---------------------------------------------------------------------------------- " jvmName = AdminControl.completeObjectName ('type=JVM,*') params = [AdminControl.makeObjectName (jvmName), java.lang.Boolean ('false')] sigs = ['javax.management.ObjectName', 'java.lang.Boolean'] print AdminControl.invoke_jmx (perfOName, 'getStatsObject', params, sigs) print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke getInstrumentationLevelString operation" print "---------------------------------------------------------------------------------- " print AdminControl.invoke (perfName, 'getInstrumentationLevelString') print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke setInstrumentationLevel operation - enable/disable PMI counters " print "---------------------------------------------------------------------------------- " params = ['pmi=l', java.lang.Boolean ('true')] sigs = ['java.lang.String', 'java.lang.Boolean'] print AdminControl.invoke_jmx (perfOName, 'setInstrumentationLevel', params, sigs) print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke getStatsString(ObjectName, Boolean) operation" print "---------------------------------------------------------------------------------- " jvmName = AdminControl.completeObjectName ('type=JVM,*') params = [AdminControl.makeObjectName (jvmName), java.lang.Boolean ('true')] sigs = ['javax.management.ObjectName', 'java.lang.Boolean'] print AdminControl.invoke_jmx (perfOName, 'getStatsString', params, sigs) print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke getStatsString (ObjectName, String, Boolean) operation" print "---------------------------------------------------------------------------------- " mySrvName = AdminControl.completeObjectName ('type=Server,name=server1,node=wcsNode,*') params = [AdminControl.makeObjectName (mySrvName), 'beanModule', java.lang.Boolean ('true')] sigs = ['javax.management.ObjectName', 'java.lang.String', 'java.lang.Boolean') print AdminControl.invoke_jmx (perfOName, 'getStatsString', params, sigs) print "---------------------------------------------------------------------------------- \n" print "\n---------------------------------------------------------------------------------- " print "Invoke listStatMemberNames operation" print "---------------------------------------------------------------------------------- " mySrvName = AdminControl.completeObjectName ('type=Server,name=server1,node=wcsNode,*') params = [AdminControl.makeObjectName (mySrvName)] sigs = ['javax.management.ObjectName'] print AdminControl.invoke_jmx (perfOName, 'listStatMemberNames', params, sigs) print "---------------------------------------------------------------------------------- \n"
Java Management Extensions (JMX)
Related tasks
Enable PMI
Monitor performance with Tivoli Performance Viewer (TPV)
Start wsadmin
Set the Performance Monitoring Infrastructure using scripting
Related
Wsadmin tool