### Script to create WebLogic Domain(s) from csv file
02.### Reusable Definitions
03.def buildDomain():
04. ### Read Basic Template
05. readTemplate(WL_HOME+"/common/templates/domains/wls.jar")
06. cd('Servers/AdminServer')
07. set('ListenAddress', adminServerAddress)
08. set('ListenPort', int(adminServerPort))
09. ### Create Admin User
10. cd('/')
11. cd('Security/base_domain/User')
12. delete('weblogic','User')
13. create(adminUser,'User')
14. cd(adminUser)
15. set('Password',adminPassword)
16. set('IsDefaultAdmin',1)
17. ### Write Domain
18. setOption('OverwriteDomain', 'true')
19. writeDomain(domainLocation+'/'+domainName)
20. closeTemplate()
21.def printConfirmation():
22. ### Print Confirmation
23. print ""
24. print "Created Domain With Following Values"
25. print "Domain Name = %s " % domainName
26. print "Domain Location = %s " % domainLocation
27. print "Admin User = %s " % adminUser
28. print "Admin Password = %s " % adminPassword
29. print "Admin Server Address = %s " % adminServerAddress
30. print "Admin Server port = %s " % adminServerPort
31.### Executable Script
32.### CreateDomain.py
33.import sys
34.### Define constants
35.WL_HOME = "/products/beaSB/wlserver_10.0"
36.### Read the command-line arguments
37.argslength = len(sys.argv)
38.if argslength < 2 :
39. print '==>Insufficient arguments'
40. print '==>Syntax: java weblogic.WLST CreateDomain.py csv.file'
41. exit()
42.else:
43. ### Read the csv file
44. fileName = sys.argv[1]
45. print('Reading File \"' + fileName + '\"' )
46. f = open(fileName)
47. try:
48. for line in f.readlines():
49. ### Strip the comment lines
50. if line.strip().startswith('#'):
51. continue
52. else:
53. ### Split the comma seperated values
54. items = line.split(',')
55. items = [item.strip() for item in items]
56. if len(items) != 6:
57. print "==>Bad line: %s" % line
58. print "==>Syntax: domainName, domainLocation, adminUser, adminPassword, adminServerAddress, adminServerPort"
59. else:
60. (domainName, domainLocation, adminUser, adminPassword, adminServerAddress, adminServerPort) = items
61.
62. ### Call the definition buildDomain
63. buildDomain()
64. ### Call the definition printConfirmation
65. printConfirmation()
66. except Exception, e:
67. print "==>Error Occured"
68. print e
69.exit()
Labels
- news (101)
- Linux (72)
- tips (36)
- ubuntu (32)
- hardware (24)
- videos (24)
- howtos (21)
- kde (20)
- open source (20)
- solaris (18)
- solaris interview questions (18)
- external links (10)
- fedora (10)
- windows (10)
- debian (8)
- kernel (8)
- solaris interview questions and answers (8)
- MCSE Videos (6)
- commands (6)
- sun (6)
- linus torvalds (5)
- Sun Solaris 10 CBT (4)
- network administration (4)
- web design (4)
- solaris-express (3)
- backup (2)
- virtualization (1)
WLST Scripting: Know More on it: Eg.
Labels: WLST
Monitoring JDBC Connection pool using WLST
Here is a sample:
def jdbcConnectionPoolStatus(server_name):
try:
cd('/ServerRuntimes/'+server_name+'/JDBCConnectionPoolRuntime')
print '---------------------- JDBC Connection pool ---------------------'
jdbcPool = ls()
for jdbcname in jdbcPool.split():
if jdbcname != 'drw-':
cd('/ServerRuntimes/Desktop_managedServer_1/JDBCConnectionPoolRuntime/'+jdbcname)
print 'Connection pool ' + jdbcname + ' is ' + cmo.getState()
except:
print "This Server has no JDBC Connection Pool"
Labels: WLST
JConsole JMX to Weblogic
Hello,
We found a workaround that doesn't need to compile and run a proxy.
Just set JAVA_HOME and BEA_HOME and run:
RedHat
jconsole -J-Djava.class.path=$JAVA_HOME/lib/jconsole.jar:/usr/bea40/wlserver_10.3/server/lib/wljmxclient.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote
Windows
jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%BEA_HOME%\wlserver_10.3\server\lib\wljmxclient.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote
Connection string:
service:jmx:rmi:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.domainruntime
----------------------------------------
1. After having the same issue, it turned out that it is just a CLASSPATH issue when using jConsole from the latest SUN JVM:
a) Working for connect string starting with 'service:jmx:rmi:///jndi/iiop://...' only.
set JAVA_HOME=D:\SUN_jdk1.6.0_13
set PATH=%JAVA_HOME%\bin;%PATH%
jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%bea_home%\wlserver_10.3\server\lib\wljmxclient.jar
b) Working for connect string starting with 'service:jmx:rmi:///jndi/iiop://...' and 'service:jmx:iiop:///jndi/iiop://...' .
set JAVA_HOME=D:\SUN_jdk1.6.0_13
set PATH=%JAVA_HOME%\bin;%PATH%
jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%bea_home%\wlserver_10.3\server\lib\weblogic.jar
NOTE: The RMI or IIOP in the connect string!
c) I tried the following URLs that worked fine:
* service:jmx:rmi:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.runtime
* service:jmx:iiop:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.runtime
* service:jmx:rmi:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.domainruntime
* service:jmx:iiop:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.domainruntime
2. In addition, the parameter -J-Djmx.remote.proto.provider.pkgs=weblogic.management.remote can be set if the current version of the JVM has any issue:
jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%bea_home%\wlserver_10.3\server\lib\wljmxclient.jar -J-Djmx.remote.proto.provider.pkgs=weblogic.management.remote
I hope this helps a bit!
Labels: WLST
Monitoring JDBC Connection pool using WLST : Betterway
try:
mBeans=home.getMBeansByType("JDBCConnectionPoolRuntime")
print '---------------------- JDBC Connection pool ---------------------'
print
for bean in mBeans:
if server_name != bean.getObjectName().getLocation():
continue
print bean.getName() + " is " + str(bean.getState())
except:
print "This server has no Messaging Bridge"
Labels: WLST
Monitoring Messaging Bridges
try:
mBeans=home.getMBeansByType("MessagingBridgeRuntime")
print '---------------------- Messaging Bridge ---------------------'
print
for bean in mBeans:
if server_name != bean.getObjectName().getLocation():
continue
print bean.getName() + " is " + str(bean.getDescription()) + " and " + str(bean.getState())
except:
print "This server has no Messaging Bridge"
Labels: WLST
Application Status through WLST
Here is a way.
try:
cd('/ServerRuntimes/'+server_name+'/ApplicationRuntimes')
print '---------------------- Application status ---------------------'
apps = ls()
for appname in apps.split():
if appname != 'drw-':
cd('/ServerRuntimes/'+server_name+'/ApplicationRuntimes/'+appname)
if getMBean('ComponentRuntimes'):
# we may not have a component runtime, so check first
cd('/ServerRuntimes/'+server_name+'/ApplicationRuntimes/'+appname+'/ComponentRuntimes')
components=ls()
for component in components.split():
if not component.endswith('.jar'):
if component != 'drw-':
cd('/ServerRuntimes/'+server_name+'/ApplicationRuntimes/'+appname+'/ComponentRuntimes/'+component)
status=str(get('Name'))+': '
istate=cmo.getDeploymentState()
if istate == 0:
istate='UNPREPARED'
if istate == 1:
istate='PREPARED'
if istate == 2:
istate='ACTIVE'
if istate == 3:
istate='NEW'
print component + ' has status : ' + istate
except WLSTException,e:
# this typically means the server is not active, just ignore
print "This Server has no Application"
Labels: WLST