Skip to content

Monitoring WebLogic Server Runtime using WLST

There are scenarios when you would want to monitor the properties of your alive servers in the Domain using the WebLogic Server Runtime Mbeans. Properties like Server State, Server Health, Listen Port, Listen Addresses etc.

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 Server State of all the running servers in the domain.

Steps:

1. Script to monitor Server Runtime States

a. Save the below script ServerStatus.py on to your local machine.

**************************************************************************

username = 'weblogic'

password = 'weblogic'

URL='t3://localhost:8001'

connect(username,password,URL)

domainRuntime()

cd('ServerRuntimes')

servers=domainRuntimeService.getServerRuntimes()

for server in servers:

serverName=server.getName();

print ‘**************************************************\n’

print ‘##############    ’, serverName,    ’###############’

print ‘**************************************************\n’

print ‘##### Server State           #####’, server.getState()

print ‘##### Server ListenAddress   #####’, server.getListenAddress()

print ‘##### Server ListenPort      #####’, server.getListenPort()

print '##### Server Health State    #####', server.getHealthState()

**************************************************************************

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 ServerStatus.py

Downloads

You can download the WLST script from the below link.

ServerStatus.py

Note: Save the script as ServerStatus.py

References:

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

Regards,

Wonders Team. :)

16 Comments

  1. Ashok

    I am getting invalid syntax error for line 9: serverName=server.getName();

    Please suggest me..with the correct syntax.

    Posted on 18-Mar-11 at 3:09 pm | Permalink
  2. Administrator

    Hi Ashok,

    We will mail you the script.

    Cheers!
    Faisal

    Posted on 22-Mar-11 at 2:19 am | Permalink
  3. Suresh

    I am also facing the same issue, could you send me the script too..

    Posted on 23-Mar-11 at 2:37 am | Permalink
  4. Administrator

    sure Suresh!

    Posted on 23-Mar-11 at 6:05 am | Permalink
  5. anandraj

    Hi Suresh,

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

    Download and execute the same.

    Cheers,
    Anandraj

    Posted on 23-Mar-11 at 7:07 am | Permalink
  6. Al

    The getHealthState() returns Component:ServerRuntime,State:HEALTH_OK,MBean:ewbsacovn48_e_1,ReasonCode:[] … How can I test to see that HEALTH is OK or in Warning or other condition?

    Posted on 24-Mar-11 at 1:40 pm | Permalink
  7. Administrator

    Kindly post your question to our forum

    http://weblogic-wonders.com/weblogic/forum/#/

    Posted on 06-Apr-11 at 4:40 am | Permalink
  8. ./ServerStatus.py: line 3: username: command not found
    ./ServerStatus.py: line 5: password: command not found
    ./ServerStatus.py: line 9: syntax error near unexpected token `username,password,URL’
    ./ServerStatus.py: line 9: ` connect(username,password,URL)

    Posted on 13-Jul-11 at 3:57 am | Permalink
  9. anandraj

    Hi Naveen,

    Try to download the WLST script from the link provided in the article.

    http://weblogic-wonders.com/weblogic/wp-content/uploads/2011/03/ServerStatus.py_1.txt

    Regards,
    Anandraj

    Posted on 19-Jul-11 at 1:12 pm | Permalink
  10. Pawan

    Hi,

    A small correction in your above ServerStatus.py script which is downloadable.
    print ‘############## ’, serverName, ’###############’

    comma & single codes are missing in that .

    Thanks
    Pawan

    Posted on 01-Nov-11 at 11:22 am | Permalink
  11. Lokesh

    Please subscribe me… this site is very useful to us

    thanks

    lokesh

    Posted on 09-Dec-11 at 10:33 pm | Permalink
  12. Administrator

    sure lokesh!

    Posted on 03-Feb-12 at 4:21 am | Permalink
  13. Per

    It is a nice to show helath of the running servers – but what about those stopped/crashed?

    Posted on 25-Jul-12 at 4:30 am | Permalink
  14. Adi

    How can I auto mail for server HEALTH is in Warning or overlaod other condition state?

    Posted on 04-Dec-12 at 3:48 am | Permalink
  15. Adi

    i need help on health state become warrning and overload i need mail for health status

    please send me do you have any scripts

    Posted on 04-Dec-12 at 3:49 am | Permalink
  16. anandraj

    Hi Adi,

    Apologies for the late reply.

    Am afraid we do not have WLST scripts for the same.

    However you can use the WLDF feature to configure the same via admin console. It is fairly simple.

    Please refer the below post for the same.

    http://weblogic-wonders.com/weblogic/2009/12/01/configuration-wldf-mail-notification-for-runtime-mbean/

    Regards,
    Anandraj

    Posted on 13-Dec-12 at 3:02 pm | Permalink

Post a Comment

Your email is never published nor shared.