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. 🙂

21 comments

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

    Please suggest me..with the correct syntax.

    1. Hi Suresh,

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

      Download and execute the same.

      Cheers,
      Anandraj

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

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

  4. Hi,

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

    comma & single codes are missing in that .

    Thanks
    Pawan

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

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

    please send me do you have any scripts

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

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

  9. Problem invoking WLST – Traceback (innermost last):
    (no code object) at line 0
    File “/oracle/ServerStatus.py”, line 17
    serverName=server.getName();
    ^
    SyntaxError: invalid syntax

    getting this error while running the script. please suggest.

Comments are closed.