Quantcast
Channel: Middleware wonders!! » wlst
Viewing all 14 articles
Browse latest View live

ConfigToScript command

$
0
0
ConfigToScript

The WLST command ConfigToScript converts an existing server configuration (config directory) to an executable WLST python script.The syntax for this command is :
configToScript([configPath], [pyPath], [overwrite], [propertiesFile], [createDeploymentScript])

- configPath : Optional value. This is the path to the config directory that contains the configuration of the domain that you want to convert.  The default location is domain/config directory.
- pyPath : Optional value. This is the path and filename to which you want to write the converted WLST script. This argument defaults to domain/config/config.py.
- overwrite : Optional value. This is a boolean value specifying whether the script file should be overwritten if it already exists. This argument defaults to true, indicating that the script file is overwritten.
- propertiesFile : Optional value. This is a path to the directory in which you want WLST to write the properties files. This argument defaults to the pathname specified for the scriptPath argument.
- createDeploymentScript : Optional value. This is a boolean value specifying whether WLST creates a script that performs deployments only. This argument defaults to false, indicating that a deployment script is not created. The file named deploy.py will be created.
Here is an example in weblogic server 10.3, where I have created WLST scripts which include a properties file, python script which has configurations of the domain, file to store the passwords used in the domain by the servers.
From the command prompt, start the WLST.cmd file from the path D:\BEA103\wlserver_10.3\common\bin. WLST will start in offline mode.
Execute the command configToScript as below:
configToScript(‘D:/BEA103/user_projects/domains/example_domain’,'D:/Files/MyScripts’,'true’,'D:/Files/MyScripts/config.py.properties’,'true’)
Below are the files that will be created in the D:/Files/MyScripts directory:
-    c2sConfigexample_domain
-    c2sSecretexample_domain
-    config.py
-    config.py.properties
-    deploy.py

A short Article on CMO’s — WLST variables

$
0
0

WLST, CMO’s and Built-in Variables

CMO is the WLST in built variable. These are like our JAVA keywords having a dedicated meaning and functionality. CMO stands for Current Management Object. While programming in WLST we can use cmo to point the current MBean (object) instance you are navigating into. The cmo value is changed when we navigate to different hierarchy of MBeans under different MBean trees in WebLogic (except jndi tree). Please refer the following example on the same:-

…………………..

………………..

connect(username, password, url)

edit()

startEdit()

cd(‘/Servers/server1′)

s1=cmo

cd(‘/Servers/server2′)

s2=cmo

print ‘Listenport of server1 -> ‘ + s1.getListenPort()

print ‘Listenport of server2 -> ‘ + s2.getListenPort()

…………………..

………………..

On observing above we can conclude that cmo can be used for invoking operations on the respective MBean object.

Similar to CMO, we have many other WLST in-built variables helping us to make the WLST programming simple and efficient. Following is the link listing all these attributes:

http://download.oracle.com/docs/cd/E12839_01/web.1111/e13813/reference.htm#i1003217

For example, we have the storeUserConfig() to Create a user configuration file and an associated key file.

Note: Make sure that in your WLST variables you don’t store any of your own information. If you do so then WLST will overwrite these variables during your interaction like connect, startEdit etc. Hence, make sure you understand these WLST variables, use them in your scripts, do not use them to store your information and be comfortable with the WLST programming.

Delete Messages From JMS Queue Using WLST

$
0
0

Connect to the server using WLST by entering the command java weblogic.WLST
Enter the command connect()
Enter the username, password, and the admin server url you want to connect to.

Change the location to serverRuntime by entering the command serverRuntime().
Traverse to the below location:
- cd(‘JMSRuntime’)
- cd(‘AdminServer.jms’)
- cd(‘JMSServers’)
- cd(‘FEJMSServer’)
- cd(‘Destinations’)
- cd(‘FRModule!FRQ’)
- ls()

It shows all the attributes and functions of Queue1.

wls:/lab_domain/serverRuntime/JMSRuntime/AdminServer.jms/JMSServers/FEJMSServer/Destinations/FRModule!FRQ> ls()
dr–   DurableSubscribers

-r–   BytesCurrentCount  11
-r–   BytesHighCount  11
-r–   BytesPendingCount  0
-r–   BytesReceivedCount 0
-r–   BytesThresholdTime  0
-r–   ConsumersCurrentCount 0
-r–   ConsumersHighCount  0
-r–   ConsumersTotalCount  0
-r–   ConsumptionPaused   false
-r–   ConsumptionPausedState  Consumption-Enabled
-r–   DestinationInfo

-r–   DestinationType  Queue
-r–   DurableSubscribers  null
-r–   InsertionPaused  false
-r–   InsertionPausedState  Insertion-Enabled
-r–   MessagesCurrentCount  3
-r–   MessagesDeletedCurrentCount  0
-r–   MessagesHighCount  3
-r–   MessagesMovedCurrentCount  0
-r–   MessagesPendingCount  0
-r–   MessagesReceivedCount 0
-r–   MessagesThresholdTime  0
-r–   Name   FRModule!FRQ
-r–   Paused  false
-r–   ProductionPaused  false
-r–   ProductionPausedState   Production-Enabled
-r–   State  advertised_in_cluster_jndi
-r–   Type   JMSDestinationRuntime

-r-x   closeCursor  Void : String(cursorHandle)
-r-x   deleteMessages   Integer : String(selector)
-r-x   getCursorEndPosition     Long : String(cursorHandle)
-r-x   getCursorSize  Long : String(cursorHandle)
-r-x   getCursorStartPosition  Long : String(cursorHandle)
-r-x   getItems     javax.management.openmbean.CompositeData[] : String(cursorHandle),Long(start),Integer(count)
-r-x   getMessage   javax.management.openmbean.CompositeData : String(cursorHandle),Long(messageHandle)
-r-x   getMessage   javax.management.openmbean.CompositeData : String(cursorHandle),String(messageID)
-r-x   getMessage   javax.management.openmbean.CompositeData : String(messageID)
-r-x   getMessages   String : String(selector),Integer(timeout)
-r-x   getMessages   String : String(selector),Integer(timeout),Integer(state)
-r-x   getNext   javax.management.openmbean.CompositeData[] : String(cursorHandle),Integer(count)
-r-x   getPrevious   javax.management.openmbean.CompositeData[] : String(cursorHandle),Integer(count)
-r-x   importMessages  Void : javax.management.openmbean.CompositeData[],Boolean(replaceOnly)
-r-x   moveMessages  Integer : String(java.lang.String),javax.management.openmbean.CompositeData,Integer(java.lang.Inte
ger)
-r-x   moveMessages   Integer : String(selector),javax.management.openmbean.CompositeData
-r-x   pause   Void :
-r-x   pauseConsumption   Void :
-r-x   pauseInsertion  Void :
-r-x   pauseProduction  Void :
-r-x   preDeregister  Void :
-r-x   resume  Void :
-r-x   resumeConsumption  Void :
-r-x   resumeInsertion  Void :
-r-x   resumeProduction  Void :
-r-x   sort   Long : String(cursorHandle),Long(start),String[](fields),Boolean[](ascending)

For deleting messages, type the below command:

wls:/lab_domain/serverRuntime/JMSRuntime/AdminServer.jms/JMSServers/FEJMSServer/Destinations/FRModule!FRQ> cmo.deleteMessages(“JMSMessageID IN(‘ID:<840637.1277114817339.0>’)”)
Results will be:
1
It will delete a message having id ID:<840637.1277114817339.0>

Creating Datasource using WLST

$
0
0

connect(‘weblogic’,'weblogic’,'t3://localhost:7001′)
edit()
startEdit()
cd(‘/’)
cmo.createJDBCSystemResource(‘PegaRULES’)
cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES’)
cmo.setName(‘PegaRULES’)
cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDataSourceParams/PegaRULES’)
set(‘JNDINames’,jarray.array([String('jdbc/PegaRULES')], String))
cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES’)
cmo.setUrl(‘jdbc:sqlserver://localhost:1433′)
cmo.setDriverName(‘com.microsoft.sqlserver.jdbc.SQLServerDriver’)
cmo.setPassword(‘pega612′)
cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCConnectionPoolParams/PegaRULES’)
cmo.setTestTableName(‘SQL SELECT 1\r\n\r\n’)
cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES/Properties/PegaRULES’)
cmo.createProperty(‘user’)
cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES/Properties/PegaRULES/Properties/user’)
cmo.setValue(‘pega612′)
cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES/Properties/PegaRULES’)
cmo.createProperty(‘databaseName’)
cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDriverParams/PegaRULES/Properties/PegaRULES/Properties/databaseName’)
cmo.setValue(‘prpc612′)
cd(‘/JDBCSystemResources/PegaRULES/JDBCResource/PegaRULES/JDBCDataSourceParams/PegaRULES’)
cmo.setGlobalTransactionsProtocol(‘OnePhaseCommit’)
cd(‘/SystemResources/PegaRULES’)
set(‘Targets’,jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))
activate()
dumpStack()
exit()

Remote Administration Of Domain Through WLST

$
0
0

For administration of the whole domain and all the servers in the domain, we can use WLST commands. This is the best way for a monitoring and managing the complete domain using nodemanager.

To start the admin server using WLST, ensure that the admin server is associated to a machine. Once done, start the WLST tool.

Start the nodemanager using the command startNodeManager() as seen in the image.

Note: Nodemanager starts and runs irrespective of the WLST tool. Even if you exit from WLST, the nodemanager will still be running.

Now you need to connect to the nodemanager using the nmConnect() command. This needs to be done because you need to start the the servers through node manager.

Example:  nmConnect(‘weblogic’, ‘weblogic’, ‘localhost’, ’5556′, ‘example_domain’,'D:/BEA103/user_projects/domains/example_domain’,'plain’)
- The above command takes username, password, hostname, port, domain name, domain directory and nodemanager type (SSL, Plain) as arguments.

1) To start the admin server through WLST using nodemanager, type the below command:
- nmStart(‘AdminServer’)

2) To check the status of the admin/managed servers, type the command:
- nmServerStatus(‘AdminServer’)
- nmServerStatus(‘MS1′)

3) To stop/kill the server, enter the command:
- nmKill(‘AdminServer’)

Steps to start the managed servers remotely:

- On the remote machine, start the WLST tool and connect to the local running admin server:

Once connected, do the nmEnroll from the remote machine:
nmEnroll(‘D:/BEA103/wlserver_10.3/common/nodemanager’)

Now to start the managed servers from the remote machine, connect to the nodemanager using nmConnect as above and do the nmStart on the managed servers.

The servers status can be checked from the remote machine.

If you have any queries, do get back to us.

Best Regards,
Wonders Team!

Monitoring JDBC Datasource Runtime Attributes using WLST

$
0
0

Step 1 :- Set the environment

C:\bea103\user_projects\domains\prpc612\bin>setDomainEnv.bat

Step 2:- Connect to server and browse to the JDBCDataSourceRuntime MBean

C:\bea103\user_projects\domains\prpc612>java weblogic.WLST

Initializing WebLogic Scripting Tool (WLST) …

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline> connect()
Please enter your username [weblogic] :
Please enter your password [weblogic] :
Please enter your server URL [t3://localhost:7001] :t3://localhost:7003
Connecting to t3://localhost:7003 with userid weblogic …
Successfully connected to managed Server ‘MS0′ that belongs to domain ‘prpc612′.

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.

wls:/prpc612/serverConfig> serverRuntime()
Location changed to serverRuntime tree. This is a read-only tree with ServerRunt
imeMBean as the root.
For more help, use help(serverRuntime)
wls:/prpc612/serverRuntime> cd(‘JDBCServiceRuntime’)
wls:/prpc612/serverRuntime/JDBCServiceRuntime> cd(‘MS0′)
wls:/prpc612/serverRuntime/JDBCServiceRuntime/MS0> cd(‘JDBCDataSourceRuntimeMBeans’)
wls:/prpc612/serverRuntime/JDBCServiceRuntime/MS0/JDBCDataSourceRuntimeMBeans> cd(‘MyDs’)
gaRules> cmo.getActiveConnectionsCurrentCount()
1

The other JDBC Datasource Runtime attributes that can be monitored are listed below.

wls:/prpc612/serverRuntime/JDBCServiceRuntime/MS0/JDBCDataSourceRuntimeMBeans/PegaRules> ls()
dr– JDBCDriverRuntime
dr– LastTask
dr– WorkManagerRuntimes

-r– ActiveConnectionsAverageCount 1
-r– ActiveConnectionsCurrentCount 0
-r– ActiveConnectionsHighCount 5
-r– ConnectionDelayTime 627
-r– ConnectionsTotalCount 5
-r– CurrCapacity 5
-r– CurrCapacityHighCount 4
-r– DeploymentState 2
-r– Enabled true
-r– FailedReserveRequestCount 0
-r– FailuresToReconnectCount 0
-r– HighestNumAvailable 5
-r– HighestNumUnavailable 0
-r– LastTask null
-r– LeakedConnectionCount 0
-r– ModuleId PegaRules
-r– Name PegaRules
-r– NumAvailable 5
-r– NumUnavailable 0
-r– PrepStmtCacheAccessCount 11852
-r– PrepStmtCacheAddCount 420
-r– PrepStmtCacheCurrentSize 50
-r– PrepStmtCacheDeleteCount 370
-r– PrepStmtCacheHitCount 11432
-r– PrepStmtCacheMissCount 420
-r– Properties {serverName=localhost, SID=prpc612, portNumber=1521, user=SYSTEM}
-r– ReserveRequestCount 11844
-r– State Running
-r– Type JDBCDataSourceRuntime
-r– VersionJDBCDriver oracle.jdbc.OracleDriver
-r– WaitSecondsHighCount 0
-r– WaitingForConnectionCurrentCount 0
-r– WaitingForConnectionFailureTotal 0
-r– WaitingForConnectionHighCount 0
-r– WaitingForConnectionSuccessTotal 4
-r– WaitingForConnectionTotal 0
-r– WorkManagerRuntimes null

-r-x clearStatementCache Void :
-r-x dumpPool Void :
-r-x dumpPoolProfile Void :
-r-x forceShutdown Void :
-r-x forceSuspend Void :
-r-x poolExists Boolean : String(name)
-r-x preDeregister Void :
-r-x reset Void :
-r-x resume Void :
-r-x shrink Void :
-r-x shutdown Void :
-r-x start Void :
-r-x suspend Void :
-r-x testPool String :

Automating application deployment on Weblogic Server.

$
0
0

In this article we will demonstrate three ways of deployment and undeployment on Weblogic Server

1. Using WLST
2. Using JMX
3. Using build script.
Application Deployment using WLST


connect(‘weblogic’,'weblogic’,'t3://localhost:7001′)
edit()
startEdit()
deploy(‘CookieApp’,'D:/Replications/CookieApp’,targets=’AdminServer’)
save()
activate()
exit()

Application Undeployment using WLST

connect(‘weblogic’,'weblogic’,'t3://localhost:7001′)
edit()
startEdit()
undeploy(‘CookieApp’)
save()
activate()
exit()

Application Deployment using JMX


import java.io.*;
import weblogic.deploy.api.tools.*;
import weblogic.deploy.api.spi .*;
import weblogic.deploy.api.spi.DeploymentOptions;
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.enterprise.deploy.spi.status.ProgressObject;
import javax.enterprise.deploy.spi.status.DeploymentStatus;
import javax.enterprise.deploy.shared.ModuleType;
import javax.enterprise.deploy.spi.Target;
public class DeployUsingJMX
{
public static void main(String ar[]) throws Exception
{
String aLocation=”D:/Replications/CookieApp”;
String aName=”CookieApp”;
WebLogicDeploymentManager deployManager=SessionHelper.getRemoteDeploymentManager( “t3″,”localhost”,”7001″,”weblogic”,”weblogic”);
System.out.println(“\n\t WebLogicDeploymentManager: “+deployManager);
DeploymentOptions options = new DeploymentOptions();
System.out.println(“\n\t DeploymentOptions: “+options);
options.setName(aName);
Target targets[]=deployManager.getTargets();
int i=0;
for (i=0;i
{
System.out.println(“\n\t “+targets[i]);
}
Target deployTargets[]=new Target[1];
deployTargets[0]=targets[0];
System.out.println(“For test purpose we are deploying on Admin Server”+targets[0]);
ProgressObject processStatus=deployManager.distribute(deployTargets, new File(aLocation), null,options);
DeploymentStatus deploymentStatus=processStatus.getDeploymentStatus() ;
System.out.println(“deploymentStatus.getMessage(): “+deploymentStatus.getMessage() );
TargetModuleID[] targetModuleIDs=deployManager.getAvailableModules(ModuleType.WAR, deployTargets);
if(targetModuleIDs != null)
{
System.out.println(“\n\t targetModuleIDs [] = “+targetModuleIDs);
for (int j=0;j
{
System.out.println(“\n\t “+targetModuleIDs[j]);
deployManager.start(targetModuleIDs);
}
}
}
}

 

Application Un-Deployment using JMX

import java.io.*;
import weblogic.deploy.api.tools.*;
import weblogic.deploy.api.spi .*;
import weblogic.deploy.api.spi.DeploymentOptions;
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.enterprise.deploy.spi.status.ProgressObject;
import javax.enterprise.deploy.spi.status.DeploymentStatus;
import javax.enterprise.deploy.shared.ModuleType;
import javax.enterprise.deploy.spi.Target;
public class UndeployUsingJMX
{
public static void main(String ar[]) throws Exception
{
WebLogicDeploymentManager deployManager=SessionHelper.getRemoteDeploymentManager(“t3″,”localhost”,”7001″,”weblogic”,”weblogic”);
System.out.println(“\n\t WebLogicDeploymentManager: “+deployManager);
DeploymentOptions options = new DeploymentOptions();
System.out.println(“\n\t DeploymentOptions: “+options);
TargetModuleID[] targetModuleIDs=deployManager.getAvailableModules(ModuleType.WAR, deployManager.getTargets());
if(targetModuleIDs != null)
{
System.out.println(“targetModuleIDs length: “+targetModuleIDs.length);
for(int i=0;i
{
System.out.println(“\n undeploying targetModuleIDs["+i+"]: “+targetModuleIDs[i]);
ProgressObject processStatus=deployManager.undeploy(new TargetModuleID[]{targetModuleIDs[i]});
DeploymentStatus deploymentStatus=processStatus.getDeploymentStatus() ;
System.out.println(“deploymentStatus.getMessage(): “+deploymentStatus.getMessage() );
}
}
}
}

Application Deployment and Undeployment using ant wldeploy task.

<?xml version=”1.0″ encoding=”ISO-8859-1″ ?>

<project name=”DeploymentBuild” default=”all” basedir=”.”>

<property name=”wl.home” value=”C:/bea103/wlserver_10.3″ />
<property name=”deploy.name” value=”CookieApp” />
<property name=”deploy.source” value=”D:/Replications/CookieApp” />
<property name=”wls.username” value=”weblogic” />
<property name=”wls.password” value=”weblogic” />
<property name=”wls.hostname” value=”localhost” />
<property name=”wls.port” value=”7001″ />
<property name=”deploy.target” value=”AdminServer” />

<path id=”wlappc.classpath”>
<fileset dir=”${wl.home}/server/lib”>
<include name=”*.jar”/>
</fileset>
</path>

<taskdef name=”wldeploy” classpathref=”wlappc.classpath” classname=”weblogic.ant.taskdefs.management.WLDeploy”/>

<target name=”deploy”>
<wldeploy action=”deploy”
name=”${deploy.name}”
source=”${deploy.source}”
user=”${wls.username}”
nostage=”true”
password=”${wls.password}”
verbose=”true”
adminurl=”t3://${wls.hostname}:${wls.port}”
targets=”${deploy.target}” />
</target>

<target name=”undeploy”>
<wldeploy action=”undeploy”
name=”${deploy.name}”
user=”${wls.username}”
password=”${wls.password}”
verbose=”true”
adminurl=”t3://${wls.hostname}:${wls.port}”
targets=”${deploy.target}” />
</target>

</project><?xml version=”1.0″ encoding=”ISO-8859-1″ ?>

<project name=”DeploymentBuild” default=”all” basedir=”.”>

<property name=”wl.home” value=”C:/bea103/wlserver_10.3″ />
<property name=”deploy.name” value=”CookieApp” />
<property name=”deploy.source” value=”D:/Replications/CookieApp” />
<property name=”wls.username” value=”weblogic” />
<property name=”wls.password” value=”weblogic” />
<property name=”wls.hostname” value=”localhost” />
<property name=”wls.port” value=”7001″ />
<property name=”deploy.target” value=”AdminServer” />

<path id=”wlappc.classpath”>
<fileset dir=”${wl.home}/server/lib”>
<include name=”*.jar”/>
</fileset>
</path>

<taskdef name=”wldeploy” classpathref=”wlappc.classpath” classname=”weblogic.ant.taskdefs.management.WLDeploy”/>

<target name=”deploy”>
<wldeploy action=”deploy”
name=”${deploy.name}”
source=”${deploy.source}”
user=”${wls.username}”
nostage=”true”
password=”${wls.password}”
verbose=”true”
adminurl=”t3://${wls.hostname}:${wls.port}”
targets=”${deploy.target}” />
</target>

<target name=”undeploy”>
<wldeploy action=”undeploy”
name=”${deploy.name}”
user=”${wls.username}”
password=”${wls.password}”
verbose=”true”
adminurl=”t3://${wls.hostname}:${wls.port}”
targets=”${deploy.target}” />
</target>

</project>

 

References:-

http://download.oracle.com/docs/cd/E13222_01/wls/docs92/config_scripting/reference.html

Monitoring WebLogic Server Runtime using WLST

$
0
0

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


Application State Monitoring using WLST

$
0
0

There are scenarios when you would want to monitor the Application state of the currently deployed applications in the Domain using the WebLogic Server Runtime Mbeans. Properties like Application State.
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 Application State deployed in the domain.
Steps:
1. Script to monitor Application Runtime States
a. Save the below script ApplicationStatus.py on to your local machine.
**************************************************************************

connect('weblogic','weblogic','t3://localhost:8001')
domainRuntime()
cd('AppRuntimeStateRuntime/AppRuntimeStateRuntime')
AppList = cmo.getApplicationIds()
print '####### Application ####### Application State\n'
print '***********************************************\n'
for App in AppList:
print '#######',App ,' #######', cmo.getIntendedState(App)
print '***********************************************\n'

 

**************************************************************************
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 ApplicationStatus.py

Downloads

You can download the WLST script from the below link.

ApplicationStatus.py

Note: Rename the file as ApplicationStatus.py

References:

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

Regards,
Wonders Team. :)

All Server States using WLST

$
0
0

This is an extension to my earlier post which gives the runtime attributes about the alive servers.

http://weblogic-wonders.com/weblogic/2011/03/16/weblogic-server-runtime-using-wlst/

However there could be scenarios where you might want to keep a track of all the server states like RUNNING, SHUTDOWN  etc  in the domain.

The below WLST script provides a list of all the servers in the domains and their respective server states. To check the servers which are in shutdown state.

Steps:-

1. Script to monitor all the Server States in the domain.

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

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

username = 'weblogic'

password = 'weblogic1'

URL='t3://localhost:7001'

connect(username,password,URL)

domainConfig()

serverList=cmo.getServers();

domainRuntime()

cd('/ServerLifeCycleRuntimes/')

for server in serverList:

name=server.getName()

cd(name)

serverState=cmo.getState()

if serverState=='SHUTDOWN':

print '**** Shutdown Servers ****'

print 'Server *****'+ name +'***** State *****'+serverState

break

print 'Server *****'+ name +'***** State *****'+serverState

cd('..')

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

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

 

Downloads

You can download the WLST script from the below link.

serverStateAll.py

Note: Save the script as AllServerStatus.py

References:

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

Regards,

Wonders Team.

Configuring SSL on Weblogic Server using WLST Script

$
0
0

Copyright 2013 - http://www. Weblogic-Wonders.com

Create a certs folder in your C Drive and copy the setWLSEnv.cmd from your
WL_HOME\bin to this location. Run the script from the command line to set the environment.

C:\certs>setWLSEnv.cmd

Generate Key Pair

C:\certs>keytool -genkey -alias mykey -keyalg RSA -keysize 1024 -dname “CN=local
host, OU=Customer Support, O=BEA Systems Inc, L=Denver, ST=Colorado, C=US” -keyp
ass password -keystore identity.jks -storepass password

Self Sign the certificates

C:\certs>keytool -selfcert -v -alias mykey -keypass password -keystore identity.
jks -storepass password -storetype jks
New certificate (self-signed):
[
[
Version: V3
Subject: CN=localhost, OU=Customer Support, O=BEA Systems Inc, L=Denver, ST=Co
lorado, C=US
Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5

Key: Sun RSA public key, 1024 bits
modulus: 108342965006068643588893180491570939949736584519654598627176377967838
26940447697831537132527381459459266829807329604009020938875414181382044292466705
89819838780374644650699373537069348379731906983832802029884351785733351834411699
83101988490742211602827902735858231021288915845653840773351114087084563504850163

public exponent: 65537
Validity: [From: Tue Sep 10 20:15:56 IST 2013,
To: Mon Dec 09 20:15:56 IST 2013]
Issuer: CN=localhost, OU=Customer Support, O=BEA Systems Inc, L=Denver, ST=Col
orado, C=US
SerialNumber: [ 522f30a4]

]
Algorithm: [SHA1withRSA]
Signature:
0000: 2F 39 D1 80 63 BC FD 49 D0 EC CC 1B B7 D4 B0 01 /9..c..I……..
0010: C4 CE 50 F3 B1 3D 3D 37 F2 3F 08 B5 12 D9 45 D5 ..P..==7.?….E.
0020: FC FA FA AB 07 28 DD 97 86 CE A2 CA C3 8D 78 95 …..(……..x.
0030: 6C 34 37 D5 DE BE 53 8E 33 7F 11 85 3F D2 0C A0 l47…S.3…?…
0040: 17 8D 38 E0 FB BD 5E 73 8F CE 2A 5B F2 6E 69 6B ..8…^s..*[.nik
0050: 09 9D 76 AD 55 5F D6 DD 07 97 59 95 A7 D8 7C B5 ..v.U_....Y.....
0060: A1 A2 E8 D2 B5 14 30 45 7B 36 9E 55 E8 7E 2C 48 ......0E.6.U..,H
0070: D6 F2 69 B3 C7 03 B9 8D 3A 22 E1 49 3E 09 B4 21 ..i.....:".I>..!

]
[Storing identity.jks]

Export your public key

C:\certs>keytool -export -v -alias mykey -file rootCA.der -keystore identity.jks
-storepass password
Certificate stored in file

Create a trust store.

C:\certs>keytool -import -v -trustcacerts -alias mykey -file rootCA.der -keystor
e trust.jks -storepass password
Owner: CN=localhost, OU=Customer Support, O=BEA Systems Inc, L=Denver, ST=Colora
do, C=US
Issuer: CN=localhost, OU=Customer Support, O=BEA Systems Inc, L=Denver, ST=Color
ado, C=US
Serial number: 522f30a4
Valid from: Tue Sep 10 20:15:56 IST 2013 until: Mon Dec 09 20:15:56 IST 2013
Certificate fingerprints:
MD5: 59:49:CD:AD:13:B0:98:A2:16:88:6B:3B:13:1A:C8:58
SHA1: A8:B5:7A:B8:A1:19:40:EB:8F:18:6D:33:EE:8C:1B:62:6E:94:BF:05
Signature algorithm name: SHA1withRSA
Version: 3
Trust this certificate? [no]: yes
Certificate was added to keystore
[Storing trust.jks]

Execute the WLST Script

C:\certs>java weblogic.WLST setupSSL.py

connect('weblogic','weblogic123','t3://localhost:7001')
edit()
startEdit()
cd('/Servers/AdminServer')
cmo.setCustomIdentityKeyStoreFileName("C:\\certs\\identity.jks")
set('CustomIdentityKeyStorePassPhrase', 'password')
cmo.setCustomTrustKeyStoreFileName("C:\\certs\\trust.jks")
set('CustomTrustKeyStorePassPhrase', 'password')
cmo.setKeyStores('CustomIdentityAndCustomTrust')
cmo.setCustomIdentityKeyStoreType('JKS')
cmo.setCustomTrustKeyStoreType('JKS')
cd('/Servers/AdminServer/SSL/AdminServer')
cmo.setServerPrivateKeyAlias('mykey')
set('ServerPrivateKeyPassPhrase', 'password')
cd('/Servers/AdminServer/SSL/AdminServer')
cmo.setEnabled(true)
cmo.setListenPort(7002)
save()
activate()
exit()

You should see this message in the stdout once the script runs successfully.

<10 Sep, 2013 8:43:19 PM IST> tity certificate and private key stored under the alias mykey from the JKS keyst
ore file C:\certs\identity.jks.>
<10 Sep, 2013 8:43:20 PM IST> certificates from the JKS keystore file C:\certs\trust.jks.>

The post Configuring SSL on Weblogic Server using WLST Script appeared first on Middleware wonders!!.

WLST Script to start and stop Datasource

$
0
0

Copyright 2013 - http://www. Weblogic-Wonders.com

 

Script to start Datasource

connect('weblogic','weblogic123','t3://localhost:7001')
domainRuntime()
cd('ServerRuntimes/AdminServer/JDBCServiceRuntime/AdminServer/JDBCDataSourceRuntimeMBeans/PegaRULES')
objArray = jarray.array([], java.lang.Object)
strArray = jarray.array([], java.lang.String)
invoke('start', objArray, strArray)
exit()

Script to stop Datasource

connect('weblogic','weblogic123','t3://localhost:7001')
domainRuntime()
cd('ServerRuntimes/AdminServer/JDBCServiceRuntime/AdminServer/JDBCDataSourceRuntimeMBeans/PegaRULES')
objArray = jarray.array([], java.lang.Object)
strArray = jarray.array([], java.lang.String)
invoke('shutdown', objArray, strArray)
exit()

The post WLST Script to start and stop Datasource appeared first on Middleware wonders!!.

WLST Script to rotate server log file

$
0
0

Copyright 2013 - http://www. Weblogic-Wonders.com

You can use the script below to rotate server log files using WLST
connect('weblogic','weblogic123','t3://localhost:7001')
serverRuntime()
cd('LogRuntime/AdminServer')
cmo.forceLogRotation()
print 'Log file rotated'

The post WLST Script to rotate server log file appeared first on Middleware wonders!!.

WLST Script to deploy jar file on Weblogic Server

$
0
0

Copyright 2013 - http://www. Weblogic-Wonders.com

print 'deploying jar...'
connect('weblogic','weblogic123','t3://localhost:7001')
try:
    undeploy('app')
    print 'Redeploying'
except Exception:
    print 'Deploy'
status = deploy(appName='app', path='app.jar',targets='AdminServer,', libraryModule='true')
print status

The post WLST Script to deploy jar file on Weblogic Server appeared first on Middleware wonders!!.

Viewing all 14 articles
Browse latest View live