Recently, I was working on a project that involved JBoss AS7. JBoss AS7 has a very handy command-line interface that enables browsing management beans by using Linux commands, such as, cd, ls etcetera. It also has the ability to use the tab button for completion. Afterwards, you start to wonder if this is also possible when browsing management beans in a WebLogic environment. Of course, there is the WebLogic Scripting Tool (WLST), with which we can build (Jython) scripts in order to access the WebLogic runtime environment. Sometimes we want to access some runtime information on the fly, and a tool such as the JBoss AS7 command-line interface lets you do that, i.e., connect to a server and start browsing the management beans of interest (of course, one can also use a tool such as jconsole). After some browsing I stumbled upon this site, which introduced (to me) tools that enable the server command-line monitoring we are looking for. The site discusses jmx4perl (that includes the sought after command-line interface) and the agent jolokia.

To set-up jmx4perl (on Linux) we can follow these steps. First download a jmx4perl distribution. Next, execute the following commands:

tar xvfz jmx4perl-1.05.tar.gz
cd jmx4perl-1.05
perl Build.PL

Install 'jmx4perl' ? (y/n) [y ]y
Install 'check_jmx4perl' ? (y/n) [y ]n (can be used with a nagios agent)
Install 'cacti_jmx4perl' ? (y/n) [y ]n (can be used with a cacti agent)
Install 'j4psh' ? (y/n) [y ]y (this is the command-line interface)
Use Term::ReadLine::Gnu ? (y/n) [n ]n
Install 'jolokia' ? (y/n) [y ]n (this we will deploy separately to WebLogic as a web application)

It could be that the perl Build.PL command complains about necessary (extra) dependencies. The before mentioned site has packaged these dependencies in an easy to use tar:

wget http://download.op5.com/tmp/jmx4perl_dependencies.tar.gz
tar xvfz jmx4perl_dependencies.tar.gz
rpm -Uvh perl-ExtUtils-ParseXS-2.20.02-1.el5.rf.noarch.rpm
rpm -Uvh perl-ExtUtils-CBuilder-0.2603.01-1.el5.rf.noarch.rpm
rpm -Uvh perl-Module-Build-0.3607-1.el5.rf.noarch.rpm

During the creation of the build script a message might appear that there are still some dependencies missing, which can be installed by running

./Build installdeps

Next, we can build, test and install the packages

./Build
./Build test
./Build install

The following step we need to perform is deploying the Jolokia agent to the WebLogic Server. A distribution of Jolokia can be downloaded here. Download the .war file and deploy it to the WebLogic Server we want to monitor. When the agent is deployed successfully, it can be accessed by using: http://192.168.1.50:7001/jolokia-war-1.0.3, which will show something like:

{"timestamp":1336387435,"status":200,"request":{"type":"version"},"value":{"protocol":"6.1","agent":"1.0.3","info":{"product":"weblogic","vendor":"Oracle","version":"12.1.1.0"}}}

It is also possible to access management beans by entering the right URL, for example by using: http://192.168.1.50:7001/jolokia-war-1.0.3/read/com.bea:Name=jolokia-war-1.0.3,ServerRuntime=AdminServer,Type=ApplicationRuntime, which will lead to the following output:

{"timestamp":1336387635,"status":200,"request":{"mbean":"com.bea:Name=jolokia-war-1.0.3,ServerRuntime=AdminServer,Type=ApplicationRuntime","type":"read"},"value":{"WseeRuntimes":[],"ApplicationName":"jolokia-war-1.0.3","Parent":{"objectName":"com.bea:Name=AdminServer,Type=ServerRuntime"},"EAR":false,"CoherenceClusterRuntime":null,"ApplicationVersion":null,"Type":"ApplicationRuntime","WseeV2Runtimes":[],"LibraryRuntimes":null,"ClassRedefinitionRuntime":null,"WorkManagerRuntimes":[{"objectName":"com.bea:ApplicationRuntime=jolokia-war-1.0.3,Name=default,ServerRuntime=AdminServer,Type=WorkManagerRuntime"}],"MinThreadsConstraintRuntimes":[],"HealthState":{"critical":false,"subsystemName":null,"state":0,"reasonCode":[],"mBeanType":null,"mBeanName":null},"Name":"jolokia-war-1.0.3","ActiveVersionState":2,"KodoPersistenceUnitRuntimes":[],"OptionalPackageRuntimes":[],"PersistenceUnitRuntimes":[],"RequestClassRuntimes":[],"ComponentRuntimes":[{"objectName":"com.bea:ApplicationRuntime=jolokia-war-1.0.3,Name=AdminServer_\/jolokia-war-1.0.3,ServerRuntime=AdminServer,Type=WebAppComponentRuntime"}],"QueryCacheRuntimes":[],"MaxThreadsConstraintRuntimes":[]}}

To use the jmx4perl command-line interface we can use

[oracle@axis-into-ict ~]$ j4psh 

[j4psh] : connect http://192.168.1.50:7001/jolokia-war-1.0.3
Connected to 192.168.1.50:7001 (http://192.168.1.50:7001/jolokia-war-1.0.3).

[192.168.1.50:7001] :
quit    history cd      ls      error   help    servers connect
[192.168.1.50:7001] :

By hitting the tab button we can see the available commands. To get information about the Jolokia deployment we can use:

[192.168.1.50:7001 com.bea] : cd Name=jolokia-war-1.0.3,Type=App
Name=jolokia-war-1.0.3,Type=AppDeployment           Name=jolokia-war-1.0.3,Type=Application
[192.168.1.50:7001 com.bea] : cd Name=jolokia-war-1.0.3,Type=AppDeployment
[192.168.1.50:7001 com.bea:Name=jolokia-war-1.0.3, ...] :

A good explanation of how the WebLogic Server MBeans are organized is provided here. WebLogic Server follows a convention in which object names for child MBeans contain part of its parent MBean object name. WebLogic Sever naming conventions encode its MBean object names as follows:

com.bea:Name=name,Type=type[,TypeOfParentMBean=NameOfParentMBean][,TypeOfParentMBean1=NameOfParentMBean1]...

In the preceding MBean object name convention:

  • com.bea: – is the JMX domain name.
  • Name – is the unique string provided when the resource was created that the MBean represents. In the example above the name is created during the deployment of the application, which is this case equals jolokia-war-1.0.3.
  • Type – is, for configuration MBeans and run-time MBeans, the short name of the MBean’s type. The short name is the unqualified type name without the MBean suffix. For example, for an MBean that is an instance of the AppDeploymentMBean, use AppDeployment.
  • TypeOfParentMBean – To create a hierarchical namespace, WebLogic Server MBeans use one or more instances of this attribute in their object names. The levels of the hierarchy are used to indicate scope. For example, the ApplicationRuntimeMBean that is a child of the AdminServer ServerRuntimeMBean uses ServerRuntime=AdminServer in its object name: com.bea:ApplicationRuntime=jolokia-war-1.0.3,Name=default,ServerRuntime=AdminServer,Type=WorkManagerRuntime.

When we have reached the MBean of interest use cat (and tab) to see the available attributes, for example,

[192.168.1.50:7001 com.bea:Name=jolokia-war-1.0.3, ...] : cat
InstallDir                             LocalInstallDir                        OnDemandContextPaths                   AutoDeployedApp
SubDeployments                         PlanDir                                Parent                                 AbsolutePlanDir
Type                                   VersionIdentifier                      LocalSourcePath                        RootStagingDir
AbsolutePlanPath                       DeploymentOrder                        LocalPlanDir                           InternalApp
BackgroundDeployment                   SecurityDDModel                        ApplicationName                        AppMBean
DeploymentPrincipalName                PlanPath                               CompatibilityName                      Name
DeploymentPlan                         DeploymentPlanExternalDescriptors      LocalPlanPath                          OnDemandDisplayRefresh
SourcePath                             StagingMode                            Notes
AbsoluteSourcePath                     ModuleType                             AbsoluteInstallDir
ValidateDDSecurityData                 ApplicationIdentifier                  Targets

[192.168.1.50:7001 com.bea:Name=jolokia-war-1.0.3, ...] : cat Targets
    [
      {
        objectName => 'com.bea:Name=AdminServer,Type=Server'
      }
    ]

To obtain runtime information about created resources such as, for example, a save-and-forward agent, we can use

[192.168.1.50:7001 com.bea] : cd Name=SAFAgent@AdminServer,ServerRuntime=AdminServer,Type=JMSServerRuntime
[192.168.1.50:7001 com.bea:Name=SAFAgent@AdminServer, ...] : cat
BytesCurrentCount                      MessagesCurrentCount                   DestinationsHighCount                  PagingAllocatedWindowBufferBytes
MessagesHighCount                      MessagesPagedInTotalCount              MessagesThresholdTime                  BytesPendingCount
PendingTransactions                    ConsumptionPaused                      MessagesPendingCount                   InsertionPausedState
ProductionPausedState                  ConsumptionPausedState                 BytesHighCount                         BytesPagedInTotalCount
BytesPagedOutTotalCount                InsertionPaused                        MessagesPageableCurrentCount           DestinationsTotalCount
SessionPoolsCurrentCount               BytesReceivedCount                     DestinationsCurrentCount               HealthState
Transactions                           SessionPoolsHighCount                  Parent                                 Name
Type                                   PagingAllocatedIoBufferBytes           BytesPageableCurrentCount              PagingPhysicalWriteCount
SessionPoolRuntimes                    BytesThresholdTime                     Destinations                           ProductionPaused
MessagesPagedOutTotalCount             SessionPoolsTotalCount                 MessagesReceivedCount

[192.168.1.50:7001 com.bea:Name=SAFAgent@AdminServer, ...] : cat *Curr*
 BytesCurrentCount               0
 SessionPoolsCurrentCount        0
 MessagesCurrentCount            0
 MessagesPageableCurrentCount    0
 DestinationsCurrentCount        1
 BytesPageableCurrentCount       0

Note the use of the wild cards in the previous command. To obtain some information about the Java Virtual Machine we can use

[192.168.1.50:7001 com.bea] : cd Name=AdminServer,ServerRuntime=AdminServer,Type=JRockitRuntime
[192.168.1.50:7001 com.bea:Name=AdminServer, ...] : cat
Uptime                         HeapFreeCurrent                FreeHeap                       JvmProcessorLoad               TotalNumberOfThreads
OSName                         HeapSizeCurrent                JavaVendor                     LastGCEnd                      Concurrent
NumberOfDaemonThreads          UsedPhysicalMemory             HeapFreePercent                TotalHeap                      UsedHeap
ThreadStackDump                FreePhysicalMemory             JVMDescription                 PauseTimeTarget                JavaVMVendor
Type                           Version                        Vendor                         AllProcessorsAverageLoad       Name
TotalNurserySize               JavaVersion                    GcAlgorithm                    TotalPhysicalMemory            Parallel
Incremental                    OSVersion                      LastGCStart                    Generational                   GCHandlesCompaction
NumberOfProcessors             HeapSizeMax                    Parent                         TotalGarbageCollectionCount    TotalGarbageCollectionTime

[192.168.1.50:7001 com.bea:Name=AdminServer, ...] : cat *Total*
 TotalNurserySize                103269328
 TotalHeap                       536870912
 TotalPhysicalMemory             3158638592
 TotalGarbageCollectionCount     321
 TotalNumberOfThreads            42
 TotalGarbageCollectionTime      15324

[192.168.1.50:7001 com.bea:Name=weblogic.socket.M...] : pwd
com.bea:Name=weblogic.socket.Muxer,ServerRuntime=AdminServer,Type=ExecuteQueueRuntime

[192.168.1.50:7001 com.bea:Name=weblogic.socket.M...] : cat *Count
 ExecuteThreadCurrentIdleCount   0
 PendingRequestCurrentCount      0
 ServicedRequestTotalCount       3
 ExecuteThreadTotalCount         3

The last two entries show information about the execute queue and the use of the pwd command.

References

[1] Jolokia Download.
[2] JMX4Perl Download.
[3] Open Source Monitoring.
[4] Developing Custom Management Utilities With JMX for WebLogic Server.