I was recently asked to retrieve a selection of JMX MBean attribute values from Weblogic Application Server, and format the data as XML to be read by Nagios. JBoss Application Server provides a nice frontend within their administration console in which to naviate the MBean hierarchy, and find the MBean names you need.
Oracle doesn’t do this when it comes to Weblogic 10.3. Instead, you can either use educated guesswork in combination with some useful documentation. Or you can use WLST – the Weblogic Scripting Tool.
Using the Weblogic Scripting Tool
The first thing to do is find the binary. This is located here:
%BEA_HOME%/common/bin/wlst.bat <-- Windows
%BEA_HOME%/common/bin/wlst.sh <-- Unix
Start the executable, and wait until you receive a prompt. There is a list of common commands you will need:
connect('username','password','host:port')
serverRuntime()
cd('beanName')
ls()
As you can see, you will be familiar with the commands if you have ever used a unix command prompt before. Be aware that we execure the commands like functions, within brackets, with a number of arguments.
Example
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline> connect('weblogic','weblogic','localhost:7001')
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'devserver' that belongs to domain 'vfdomain'.
Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.
wls:/vfdomain/serverConfig> serverRuntime()
Location changed to serverRuntime tree. This is a read-only tree with ServerRuntimeMBean as the root.
For more help, use help(serverRuntime)
wls:/vfdomain/serverRuntime> ls()
dr-- ApplicationRuntimes
dr-- AsyncReplicationRuntime
dr-- ClusterRuntime
dr-- ConnectorServiceRuntime
dr-- DefaultExecuteQueueRuntime
dr-- EntityCacheCumulativeRuntime
dr-- EntityCacheCurrentStateRuntime
dr-- EntityCacheHistoricalRuntime
dr-- ExecuteQueueRuntimes
dr-- JDBCServiceRuntime
dr-- JMSRuntime
dr-- JTARuntime
snip....
-r-- ActivationTime 1267615098514
-r-- AdminServer true
-r-- AdminServerHost 127.0.0.1
-r-- AdminServerListenPort 7001
-r-- AdminServerListenPortSecure false
-r-- AdministrationPort 9002
snip....
The first list of items are child MBeans. The second list are attributes.
We can navigate to our JDBC connections like so:
wls:/vfdomain/serverRuntime> cd('JDBCServiceRuntime/myserver/JDBCDataSourceRuntimeMBeans/mydatasource')
wls:/vfdomain/serverRuntime/DBCServiceRuntime/myserver/JDBCDataSourceRuntimeMBeans/mydatasource> ls()
snip...
-r-- ConnectionDelayTime 97
-r-- ConnectionsTotalCount 144
-r-- CurrCapacity 10
-r-- CurrCapacityHighCount 11
-r-- DeploymentState 2
-r-- Enabled true
-r-- FailedReserveRequestCount 0
-r-- FailuresToReconnectCount 0
-r-- HighestNumAvailable 12
-r-- HighestNumUnavailable 0
-r-- LastTask null
-r-- LeakedConnectionCount 0
-r-- ModuleId mydatasource
-r-- Name mydatasource
-r-- NumAvailable 10
-r-- NumUnavailable 0
-r-- PrepStmtCacheAccessCount 7836
-r-- PrepStmtCacheAddCount 3808
-r-- PrepStmtCacheCurrentSize 99
snip...





