Application State Monitoring using WLST

There are scenarios when you would want to monitor the Application state of the currently deployed applications in the Domain using the WebLogic Server Runtime Mbeans. Properties like Application State.
This can be achieved through many ways like the Admin Console, JMX code, WLST scripts etc. WLST allows us to automate the monitoring.

WebLogic Server runtime MBeans are arranged in a hierarchical data structure. When connected to an Administration Server, you access the runtime MBean hierarchy by entering the serverRuntime or the domainRuntime command. The serverRuntime command places WLST at the root of the server runtime management objects, ServerRuntimeMBean; the domainRuntime command, at the root of the domain-wide runtime management objects, DomainRuntimeMBean. When connected to a Managed Server, the root of the runtime MBeans is ServerRuntimeMBean. The domain runtime MBean hierarchy exists on the Administration Server only; you cannot use the domainRuntimecommand when connected to a Managed Server.

The below post depicts the usage of WLST to monitor the Application State deployed in the domain.
Steps:
1. Script to monitor Application Runtime States
a. Save the below script ApplicationStatus.py on to your local machine.
**************************************************************************

 

connect('weblogic','weblogic','t3://localhost:8001')
domainRuntime()
cd('AppRuntimeStateRuntime/AppRuntimeStateRuntime')
AppList = cmo.getApplicationIds()
print '####### Application ####### Application Staten'
print '***********************************************n'
for App in AppList:
print '#######',App ,' #######', cmo.getIntendedState(App)
print '***********************************************n'

 

 

**************************************************************************
2. Execute the WLST Script
a. Set the CLASSPATH by running the setDomainEnv script from the
Alternatively you can set the CLASSPATH by specifying the –cp argument while executing the WLST Script
For Ex: java –cp $BEA_HOME/wlserver_10.3/server/lib/weblogic.jar weblogic.WLST ApplicationStatus.py

Downloads

You can download the WLST script from the below link.

ApplicationStatus.py

Note: Rename the file as ApplicationStatus.py

References:

http://download.oracle.com/docs/cd/E11035_01/wls100/config_scripting/monitoring.html

Regards,
Wonders Team. 🙂

11 comments

  1. Hi Team,

    I am getting SyntaxError: invalid syntax for line8 :

    print ‘##########’,App ,’#########’,cmo.getIntendedState(App)

    Please help me to resolve the same…

    Thanks & Regards,
    Ashok

    1. Hi Ashok,

      I have pasted the download link for the WLST script in the post.

      Download and execute the same.

      Cheers,
      Anandraj

    2. I know the reply is too late , writing if for people who might visit it now and getting the same issue..
      You need to take care of indentation, give a space before print statement.

  2. Use string concatination

    print ‘##########’+App+ ’#########’+cmo.getIntendedState(App)

    1. Hi Sagar,

      Your comment doesnt appear properly?
      Are you facing issues executing the script?

  3. Hi Admin,

    I am getting following error message, could you please tell me how to resolve that.
    error message:
    “WLST detected that the RuntimeMBeanServer is not enabled. This might happen if the RuntimeMBeanServer is disabled via the JMXMBean.
    Please ensure that this MBeanServer is enabled. Online WLST cannot function without this MBeanServer.”

  4. Hi,
    thnx for sharing!
    Would you happen to know the java version of this task?

    e.g.

    java weblogic.Deployer -url t3://localhost:7001 -username admin -password admin -name app

    1. Hi Peter,

      It depends on the class weblogic.Deployer.
      You can use jdk 1.5 or 1.6.

      Thanks

    1. you can use the mail utility to do it.. check other wlst scripts, it has the steps.

Comments are closed.