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. :)

Comments

comments

20 Thoughts on “Monitoring WebLogic Server Runtime using WLST

  1. Ashok on March 18, 2011 at 3:09 pm said:

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

    Please suggest me..with the correct syntax.

  2. Administrator on March 22, 2011 at 2:19 am said:

    Hi Ashok,

    We will mail you the script.

    Cheers!
    Faisal

  3. Suresh on March 23, 2011 at 2:37 am said:

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

  4. 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?

  5. ./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)

  6. Hi,

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

    comma & single codes are missing in that .

    Thanks
    Pawan

  7. Please subscribe me… this site is very useful to us

    thanks

    lokesh

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

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

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

    please send me do you have any scripts

  11. Chandra on August 21, 2014 at 2:35 pm said:

    Hi i have tested this script.. but it comes as State:HEALTH_OK,ReasonCode:[]
    in all cesses.. i have observed that my servers have gone to overloaded state but still the script gives the same response. Any suggestions ..

  12. Please let me know if this script can monitor and give status for multiple domains located on a server.

Leave a Reply

Post Navigation