Sunday, 2 December 2012
Some handy wsadmin tips
List Datasources scoped at a particular cluster
myCluster = a = 'PCUAT001.AppTarget(cells/saturn/clusters/PCUAT001.AppTarget|cluster.xml#ServerCluster_1351877220658)'
print AdminConfig.list('DataSource', myCluster)
Set heap size
for server in AdminControl.queryNames('type=Server,processType=ManagedProcess,*').splitlines(): serverName=server.split(',')[0].split(':')[1].split('=')[1]
nodeName=server.split(',')[3].split('=')[1]
AdminTask.setJVMProperties('[-serverName '+serverName+' -nodeName '+nodeName+' -initialHeapSize 768 -maximumHeapSize 2048]')
AdminConfig.save()
Set connection pools
import re
for dataSource in AdminConfig.list('DataSource').splitlines():
jndi= AdminConfig.showAttribute(dataSource, 'jndiName')
if(re.search("PerformanceDB", jndi)):
connPool=AdminConfig.showAttribute(dataSource, 'connectionPool')
AdminConfig.modify(connPool, '[[maxConnections "200"]]')
AdminConfig.save()
Check if server is up or down
This will only return the servers that are running
for server in AdminControl.queryNames('type=Server,*').splitlines():
name=server.split(',')[0].split(':')[1].split('=')[1]
print name
If you want to filter out the deployment manager and nodeagent to only show the App servers you're interested i, use the ManagedProcess qualifier as below
for server in AdminControl.queryNames('type=Server,processType=ManagedProcess,*').splitlines():
name=server.split(',')[0].split(':')[1].split('=')[1]
print name
Prepared statements cache (and limiting to specific datasources)
import re
for dsName in 'BPEDB PerformanceDB PDWDB TwqlDB TeamWorksDB ProcessDB WPSDB'.split():
for dataSource in AdminConfig.list('DataSource').splitlines():
jndi= AdminConfig.showAttribute(dataSource, 'jndiName')
if(re.search(dsName, jndi)):
print "Setting prepared statement cache "+jndi
AdminConfig.modify(dataSource, '[[statementCacheSize "100"]]')
AdminConfig.save()
Find a running cluster and stop it
for cluster in AdminControl.queryNames('type=Cluster,*').splitlines(): if(re.search("RMRS.WebApp",cluster)):
AdminControl.invoke(cluster, 'stop')
Looking for an AdminConfig Type
import re
for line in AdminConfig.types().splitlines():
if(re.search("Server",line)):
print line
Actually a better way to do it might be
AdminControl.queryNames('type=*Security*,*')
Get the config object of the Mashups Config Service
import re
for rep in AdminConfig.list('ResourceEnvironmentProvider').splitlines():
if(re.search("Mashups_ConfigService",rep)):
mashup_cs=rep
List all of the custom properties for the Mashups Config Service
for prop in AdminConfig.show( AdminConfig.showAttribute(mashup_cs,"propertySet") ).split(): print prop
or
for prop in AdminConfig.show( AdminConfig.showAttribute(mashup_cs,"propertySet") ).split():print prop
Actually, it's a tad more tricky because of square brackets
for a in AdminConfig.show( AdminConfig.showAttribute(mashup_cs,"propertySet") ).split('resourceProperties')[1].split(']]')[0].split('[')[1].split(' '):
Find a running cluster using wildcard search and stop it
cluster = AdminControl.queryNames('type=Cluster,name=*WebApp*,*')
AdminControl.invoke(cluster, 'stop')
The cluster reference appears to remain after it's stopped (which is not the case for the server names) so you're able
to start with AdminControl.invoke(cluster, 'start')
You cant do this with a server though because the object reference dissapears and even if you kept it in a variable
If you try you get an error stating that the object instance doesn't exists
Instead use the fllowing
AdminControl.startServer(servername, nodename , time)
Example...
AdminControl.startServer('RMRS.WebApp.node1.0', 'node1',120)
(Not really sure what time is)
Queue depth
for Q in AdminControl.queryNames('type=*QueuePoint,SIBMessagingEngine=*BPC*,name=*HldQueue*,*').splitlines():
more specifically
q = AdminControl.queryNames('type=*QueuePoint,SIBMessagingEngine=*BPC*,name=*BPEHldQueue*,*').splitlines()[0]
then
AdminControl.getAttribute(q, "depth")
Misc
#----------------------------------------------------------
# Import the regualar expression engine
#----------------------------------------------------------
import re
#----------------------------------------------------------
# Define functions
#----------------------------------------------------------
def heap(serverName, iHeap, mHeap):
print "Configuring int/max heap for "+ serverName +" with "+ iHeap +"/" +mHeap
nodeName=serverName.split('.')[2]
print "<INFO> Setting heap to " + str(iHeap) + " and " + str(mHeap) + " for " + serverName + " on "+ nodeName
AdminTask.setJVMProperties('[-serverName '+serverName+' -nodeName '+nodeName+' -verboseModeGarbageCollection true -initialHeapSize '+str(iHeap)+' -maximumHeapSize '+str(mHeap)+' ]')
print ""
def genArgs(serverName, args):
print "<INFO> Configuring "+ serverName +" with generic JVM args of "+ args
nodeName=serverName.split('.')[2]
AdminTask.setJVMProperties('[-serverName '+serverName+' -nodeName '+nodeName+' -genericJvmArguments "' + args + '"]')
#print AdminTask.showJVMProperties('[-serverName '+serverName+' -nodeName '+nodeName+' ]')
print ""
def threadPools(serverName):
# Get threadpools for this server
for threadPool in AdminConfig.list('ThreadPool', serverName).splitlines():
if(re.search("Default", threadPool)):
print "<INFO> Configuring the Default ThreadPool "+ threadPool
AdminConfig.modify(threadPool, '[[maximumSize "75"] [name "Default"] [minimumSize "75"]]')
print ""
if(re.search("WebContainer", threadPool)):
print "<INFO> Configuring the WebContainer ThreadPool "+ threadPool
AdminConfig.modify(threadPool, '[[maximumSize "75"] [name "WebContainer"] [minimumSize "75"]]')
print ""
def dataSources():
for ds in AdminConfig.list('DataSource').splitlines():
jndi = AdminConfig.showAttribute(ds, "jndiName")
if(re.search("jdbc/TeamWorksDB", jndi)):
print "<INFO> Configuring jdbc/TeamWorksDB for min/max of 100/300 and statement cache of 250"
connPool = AdminConfig.showAttribute(ds, "connectionPool")
AdminConfig.modify(connPool, '[[maxConnections "300"] [minConnections "100"]]')
AdminConfig.modify(ds, '[[statementCacheSize "250"]]')
elif(re.search("jdbc/BPEDB", jndi)):
print "<INFO> Configuring jdbc/BPEDB for min/max of 75/200 and statement cache of 150"
connPool = AdminConfig.showAttribute(ds, "connectionPool")
AdminConfig.modify(connPool, '[[maxConnections "200"] [minConnections "75"]]')
AdminConfig.modify(ds, '[[statementCacheSize "150"]]')
elif(re.search("jdbc/ODS", jndi)):
print "<INFO> Configuring jdbc/ODS for min/max of 75/200 and statement cache of 100"
connPool = AdminConfig.showAttribute(ds, "connectionPool")
AdminConfig.modify(connPool, '[[maxConnections "200"] [minConnections "75"]]')
AdminConfig.modify(ds, '[[statementCacheSize "100"]]')
#----------------------------------------------------------
# Main program
#----------------------------------------------------------
for server in AdminConfig.list("Server").splitlines():
serverName=AdminConfig.showAttribute(server, 'name')
# Search for the cluster memener JVM's
if(re.search("AppTarget", serverName)):
threadPools(server)
#heap(serverName, str(7680), str(7680))
#genArgs(serverName, "-XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=85 -XX:+UseCMSInitiatingOccupancyOnly -XX:NewRatio=3 -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:Paralle
lGCThreads=8 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+DisableExplicitGC -server -d64 -XX:PermSize=768m -XX:+PrintHeapAtGC -XX:MaxPermSize=1024m")
elif(re.search("Messaging", serverName)):
heap(serverName, str(768), str(768))
#genArgs(serverName, "-XX:ParallelGCThreads=2 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -d64 -XX:MaxPermSize=512m")
elif(re.search("WebApp", serverName)):
heap(serverName, str(1024), str(1024))
#genArgs(serverName, "-XX:ParallelGCThreads=2 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -d64 -XX:MaxPermSize=512m")
elif(re.search("Support", serverName)):
heap(serverName, str(768), str(768))
#genArgs(serverName, "-XX:ParallelGCThreads=2 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -d64 -XX:MaxPermSize=512m")
else:
print "No server match for "+serverName
AdminConfig.save()
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment