Showing posts with label WLST. Show all posts
Showing posts with label WLST. Show all posts

Tuesday, May 31, 2016

WLST script to get coherence server status


If coherence is installed on weblogic server, we can monitor the status of the coherence server using below WLST script. In this script I am passing connection details as a parameter, you can follow any other approach or simply provide details in "connect()" function.

save below script as getCoherenceHealth.py 

#redirect wlst's own output to null, print lines in the script itself
redirect('/dev/null', 'false')

wlsuser = sys.argv[1]
wlspassword = sys.argv[2]
wlsurl = sys.argv[3]
#targetServer = sys.argv[4]

connect(wlsuser,wlspassword,wlsurl)

servers = cmo.getCoherenceServers()
domainRuntime()
stoppedServers = []

for server in servers:
    try:
        cd('/CoherenceServerLifeCycleRuntimes/' + server.getName())
        currentState = cmo.getState()
        if currentState == 'RUNNING':
            print server.getName() + ': ' + 'RUNNING'
        else:
            print server.getName() + ': ' + 'DOWN (' + currentState + ')'

    except WLSTException, e:
        print server.getName() + ': ' + 'SHUTDOWN'
        stoppedServers.append(server.getName())

disconnect()
#rm ./wlst.log
exit()


you can call this script by passing required arguments:
java -cp $WL_HOME/server/lib/weblogic.jar weblogic.WLST getCoherenceHealth.py $WebUSER $WebPass $WL_URL

Tuesday, February 26, 2013

Delete Messages from JMS Queue in weblogic using WLST


Set classpaths required for WLST from MW_HOME/wlserver_10.3/server/bin/
. ./setWLSEnv.sh
start WLST by typing
java weblogic.WLST

connect('weblogic', 'welcome1', 't3://localhost:7001')
serverRuntime()

cd('/JMSRuntime/<TargetServerName>.jms/JMSServers/<JMSServerName>/Destinations/<JMSModuleName>!<QueueName>')

{ex.- wls:/fmw_domain/serverRuntime>cd('/JMSRuntime/AdminServer.jms/JMSServers/JMSServer1/Destinations/SystemModule1!Queue1')
}

cmo.deleteMessages('')
{This command delete all messaged in queue and will return the number of messages deleted.}

If you want to delete a particular message from the queue, use below command:

cmo.deleteMessages("JMSMessageID IN('ID:<126965.1361894150054.0>')")
Results will be:
1
It will delete a message having id ID:<126965.1361894150054.0>
here is the message ID which we can get from "summary of JMS Message" from Admin Console.