def appStatus(server_name):
try:
print '---------------------- Application status---------------------'
mBeans=adminHome.getMBeansByType("ApplicationRuntime")
for bean in mBeans:
if server_name != bean.getObjectName().getLocation():
continue
components= bean.lookupComponents()
for componentRTList in components:
#ejbRTList=componentRTList.getMBeansByType("EJBComponentRuntime")
app = componentRTList.getParent().getName()
istate=componentRTList.getDeploymentState()
if istate == 0:
istate='UNPREPARED'
if istate == 1:
istate='PREPARED'
if istate == 2:
istate='ACTIVE'
if istate == 3:
istate='NEW'
print "%65s %65s %7s" % (str(componentRTList.getName()), app, istate)
except:
print "This Server has no Applications"
Showing posts with label WLST. Show all posts
Showing posts with label WLST. Show all posts
Wednesday, May 26, 2010
Application Status Checking with WLST
Friday, August 21, 2009
Deployment using WLST
http://blogs.oracle.com/jamesbayer/
Good link for WLST Scripts
http://unni-at-work.blogspot.com/
Thursday, August 13, 2009
JDBC Connection pool Status using Jython
try:
poolrtlist=home.getMBeansByType('JDBCConnectionPoolRuntime')
print '---------------------- JDBC CONNECTION POOLS ---------------------'
print 'Name Maxcapacity ActiveCurrent ActiveHighCount WaitSecondsHighCount \
WaitingCurrentCount State'
print ' '
for poolRT in poolrtlist:
pname = poolRT.getName()
pmaxcapacity = poolRT.getAttribute("MaxCapacity")
paccc = poolRT.getAttribute("ActiveConnectionsCurrentCount")
pachc = poolRT.getAttribute("ActiveConnectionsHighCount")
pwshc = poolRT.getAttribute("WaitSecondsHighCount")
pwfccc = poolRT.getAttribute("WaitingForConnectionCurrentCount")
pstate = poolRT.getAttribute("State")
print pname,' ',pmaxcapacity,' ',paccc,' ',pachc,' '\
,pwshc,' ',pwfccc,' ',pstate
print ' '
except:
print "This Server has no JDBC Connection Pool"
poolrtlist=home.getMBeansByType('JDBCConnectionPoolRuntime')
print '---------------------- JDBC CONNECTION POOLS ---------------------'
print 'Name Maxcapacity ActiveCurrent ActiveHighCount WaitSecondsHighCount \
WaitingCurrentCount State'
print ' '
for poolRT in poolrtlist:
pname = poolRT.getName()
pmaxcapacity = poolRT.getAttribute("MaxCapacity")
paccc = poolRT.getAttribute("ActiveConnectionsCurrentCount")
pachc = poolRT.getAttribute("ActiveConnectionsHighCount")
pwshc = poolRT.getAttribute("WaitSecondsHighCount")
pwfccc = poolRT.getAttribute("WaitingForConnectionCurrentCount")
pstate = poolRT.getAttribute("State")
print pname,' ',pmaxcapacity,' ',paccc,' ',pachc,' '\
,pwshc,' ',pwfccc,' ',pstate
print ' '
except:
print "This Server has no JDBC Connection Pool"
Wednesday, July 22, 2009
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"
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"
Tuesday, July 21, 2009
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"
mBeans=home.getMBeansByType("MessagingBridgeRuntime")
print '---------------------- Messaging Bridge ---------------------'
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"
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"
mBeans=home.getMBeansByType("JDBCConnectionPoolRuntime")
print '---------------------- JDBC Connection pool ---------------------'
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"
Wednesday, July 15, 2009
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"
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"
WLST Scripting: Know More on it: Eg.
### 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()
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()
Monday, July 13, 2009
WLST Scripting: Know More on it
Here is a small script to get you started.
import java.lang.System as System
connect(userName,passWord,URL)
cd ('Servers')
servers = cmo.getServers()
cd('/')
runtime()
def isManagedServerRunning(server_name):
cd('/ServerRuntimes/'+server_name+'/ServerLifeCycleRuntime/')
print "Current state of server "+server_name+ " : " + cmo.getState()
def printHeapDetails(server_name):
cd('/')
cd('ServerRuntimes/'+server_name+'/JVMRuntime/'+server_name)
hf = float(get('HeapFreeCurrent'))/1024
hs = float(get('HeapSizeCurrent'))/1024
hf = hf/1024
hs = hs/1024
print 'HeapFreeCurrent - ' + `hf` + 'MB'
print 'HeapSizeCurrent - ' + `hs` + 'MB'
def jdbcConnectionPoolStatus(server_name):
cd('/')
cd('/ServerRuntimes/Desktop_managedServer_1/JDBCConnectionPoolRuntime/DSSReportingPool')
print "Current State of DSSReportingPool is : " + cmo.getState()
for myServers in servers:
print "-----------------------------------"
print 'Status of ' + myServers.getName()
print "-----------------------------------"
isManagedServerRunning(myServers.getName())
printHeapDetails(myServers.getName())
jdbcConnectionPoolStatus(myServers.getName())
exit()
More info on this can be availed at
1) http://weblogicserver.blogspot.com/search?updated-min=2009-01-01T00%3A00%3A00-08%3A00&updated-max=2010-01-01T00%3A00%3A00-08%3A00&max-results=5
2) http://weblogicserver.blogspot.com/2009/03/check-for-resourceconfiguration.html
import java.lang.System as System
connect(userName,passWord,URL)
cd ('Servers')
servers = cmo.getServers()
cd('/')
runtime()
def isManagedServerRunning(server_name):
cd('/ServerRuntimes/'+server_name+'/ServerLifeCycleRuntime/')
print "Current state of server "+server_name+ " : " + cmo.getState()
def printHeapDetails(server_name):
cd('/')
cd('ServerRuntimes/'+server_name+'/JVMRuntime/'+server_name)
hf = float(get('HeapFreeCurrent'))/1024
hs = float(get('HeapSizeCurrent'))/1024
hf = hf/1024
hs = hs/1024
print 'HeapFreeCurrent - ' + `hf` + 'MB'
print 'HeapSizeCurrent - ' + `hs` + 'MB'
def jdbcConnectionPoolStatus(server_name):
cd('/')
cd('/ServerRuntimes/Desktop_managedServer_1/JDBCConnectionPoolRuntime/DSSReportingPool')
print "Current State of DSSReportingPool is : " + cmo.getState()
for myServers in servers:
print "-----------------------------------"
print 'Status of ' + myServers.getName()
print "-----------------------------------"
isManagedServerRunning(myServers.getName())
printHeapDetails(myServers.getName())
jdbcConnectionPoolStatus(myServers.getName())
exit()
More info on this can be availed at
1) http://weblogicserver.blogspot.com/search?updated-min=2009-01-01T00%3A00%3A00-08%3A00&updated-max=2010-01-01T00%3A00%3A00-08%3A00&max-results=5
2) http://weblogicserver.blogspot.com/2009/03/check-for-resourceconfiguration.html
Monday, March 31, 2008
Weblogic Admin Utility
1) Open Console or terminal in case of Unix
2) Run command setWLSEnv.bat(setWLSEnv.sh)
3) java weblogic.Admin -url AdminHost:7001 -username weblogic
2) Run command setWLSEnv.bat(setWLSEnv.sh)
3) java weblogic.Admin -url AdminHost:7001 -username weblogic
Subscribe to:
Posts (Atom)