A quick tutorial for middleware products

Friday, April 10, 2015

On April 10, 2015 by Kamlesh   6 comments
WLST Script for checking the health status of Weblogic Domain (Admin/Managed node)

After long time writing something about WLST
WLST has some good features like we can monitor the weblogic domain, monitor JMS Cluster, Datasource target and untarget etc.
In this post I am explaining about how to monitor Weblogic domain like Server State, Server Health, Listen Port, Listen Addresses etc. by WLST script.

Step by step explaining how to prepare the wlsstatus.py file and how to run it.

1)  Prepare the wlsstatus.py file and save it in somewhere in your machine.


############################################################################
# This script is for checking the Health Status of the servers
#  Author: @Middlewaregeek.blogspot.in
############################################################################
#       Connect to the Admin Server
from java.io import FileInputStream
import java.lang
import os
import string

username = 'weblogic'

password = 'weblogic'

url='t3://localhost:7001'

connect(username,password,url)

domainRuntime()

cd('ServerRuntimes')

servers=domainRuntimeService.getServerRuntimes()
for server in servers:
     serverName=server.getName();
     print '**************************************************'
     print '##############' , serverName,'###############'
     print '**************************************************'
     print '##### Server State         #####', server.getState()
     print '##### Server ListenAddress #####', server.getListenAddress()
     print '##### Server ListenPort    #####', server.getListenPort()
     print '##### Server Health State    #####', server.getHealthState()


2) Set the class path by using setDomainEnv script or go to the below path and execute wlsstatus.py file.

$WL_HOME/wlserver_10.3/common/bin

Then execute below command

$ ./wlst.sh <location of .py file >/wlsstatus.py


3) You should get following output.



Initializing WebLogic Scripting Tool (WLST) ...

*sys-package-mgr*: skipping bad jar, '/WL_HOME/wlserver_10.3/common/lib/mssqlserver.jar'
Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://localhost:7001 with userid
Successfully connected to Admin Server 'admin' that belongs to domain 'XYZ'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainRuntime)

**************************************************
############## MS1 ###############
**************************************************
##### Server State         ##### RUNNING
##### Server ListenAddress ##### Listening Address
##### Server ListenPort    ##### 7001
##### Server Health State    #####  Component:ServerRuntime,State:HEALTH_OK,MBean:MS1,ReasonCode:[]
**************************************************
############## MS2 ###############
**************************************************
##### Server State         ##### RUNNING
##### Server ListenAddress ##### Listening Address
##### Server ListenPort    ##### 7001
##### Server Health State    #####
Component:ServerRuntime,State:HEALTH_OK,MBean:MS2,ReasonCode:[]
**************************************************
############## MS3  ###############
**************************************************
##### Server State         ##### RUNNING
##### Server ListenAddress ##### Listening Address
##### Server ListenPort    ##### 7001
##### Server Health State    #####  Component:ServerRuntime,State:HEALTH_OK,MBean:MS3,ReasonCode:[]
**************************************************
############## admin ###############
**************************************************
##### Server State         ##### RUNNING
##### Server ListenAddress ##### Listening Address
##### Server ListenPort    ##### 7001
##### Server Health State    ##### Component:ServerRuntime,State:HEALTH_OK,MBean:admin,ReasonCode:[]
**************************************************
############## MS4  ###############
**************************************************
##### Server State         ##### RUNNING
##### Server ListenAddress ##### Listening Address
##### Server ListenPort    ##### 7001
##### Server Health State    ##### Component:ServerRuntime,State:HEALTH_OK,MBean:MS4,ReasonCode:[]


Regards,

Middlewaregeek


6 comments:

  1. buddy this only prints status of servers which are already running - how to get status of those servers also which are not running and are shutdown / crashed

    ReplyDelete
  2. Hi,

    Yes this is only printing the status of servers which are running, my managed server was down and it is not showing up in the list. Is there a way we can get the status of servers that are not running

    ReplyDelete
  3. Hi Team,

    I need to encrypt the password in the file wlsstatus.py. Is there any way i could be able to do it?

    Regards,
    Jay

    ReplyDelete
  4. how to get the Server status output to my email id /distribution list and where we can configure in the script?????

    ReplyDelete
  5. This is realy a Nice blog post read on of my blogs It is really helpful article please read it too my blog FACEBOOK IMAGES NOT LOADING. you can visits our websites or toll free no +1-866-558-4555. solve your problem fastly.

    ReplyDelete
  6. It is really helpful article please read it too my blog FACEBOOK IMAGES NOT LOADING.

    ReplyDelete