# -------------------------------------------------------------------------- # Enable Wily for the specified JVM Instance # -------------------------------------------------------------------------- def _splitlist(s): """Given a string of the form [item item item], return a list of strings, one per item. WARNING: does not yet work right when an item has spaces. I believe in that case we'll be given a string like '[item1 "item2 with spaces" item3]'. """ if s[0] != '[' or s[-1] != ']': raise "Invalid string: %s" % s #endIf return s[1:-1].split(' ') #endDef _splitlist def wsadminToList(inStr): inStr = inStr.rstrip(); outList=[] if (len(inStr)>0 and inStr[0]=='[' and inStr[-1]==']'): tmpList = inStr[1:-1].split(" ") else: tmpList = inStr.split("\n") #splits for Windows or Linux #endIfElse for item in tmpList: item = item.rstrip(); #removes any Windows "\r" if (len(item)>0): outList.append(item) #endIf #endFor return outList #endDef wsadminToList def installCustomService ( server, cs_attribs ): serverName = AdminConfig.showAttribute(server, "name" ) customServices = AdminConfig.getid("/Cell:"+cellName+"/Node:"+nodeName+"/Server:"+serverName+"/CustomService:/" ) customServices = wsadminToList(customServices) # Find displayName attribute customServiceDisplayName = "" for attrib in cs_attribs: name = attrib[0] if (cmp(name, "displayName") == 0): customServiceDisplayName = attrib[1] #endIf #endFor if (len(customServiceDisplayName) == 0): print "---> ERROR in installCustomService - displayName attribute not set" sys.exit() #endIf found = "false" for customService in customServices: displayName = AdminConfig.showAttribute(customService, "displayName" ) if (cmp(displayName, customServiceDisplayName) == 0): found = "true" print " "+displayName+" CustomService object exists! Modifying ......" AdminConfig.modify(customService, cs_attribs ) print " Done." break #endIf #endFor if (cmp(found, "false") == 0): print " Creating "+customServiceDisplayName+" Custom Service ......" AdminConfig.create("CustomService", server, cs_attribs ) print " Done." #endIf #endDef # Uncomment the line below for Debugging this script. # wsadminlib.enableDebugMessages() serverName = ""; for arg in sys.argv: if (arg.startswith("-appServerName=")): serverName = arg[15:] #endIf #endFor for arg in sys.argv: if (arg.startswith("-nodeName=")): nodeName = arg[10:] #endIf #endFor genericArgument = "-XX:-UseSplitVerifier -javaagent:/wily/wily/Introscope95/AgentNoRedef.jar -Dcom.wily.introscope.agentProfile=/wily/wily/Introscope95/core/config/profiles/" + serverName + "-IntroscopeAgent.profile" wilyCustomServiceClassName = "com.wily.introscope.api.websphere.IntroscopeCustomService" wilyCustomServiceClassPath = "/wily/wily/Introscope95/common/WebAppSupport.jar" wilyCustomServiceDisplayName = "Introscope Custom Services" cellConfigId = AdminConfig.getid('/Cell:/') cellName=AdminConfig.showAttribute(cellConfigId, 'name') nodeConfigId = AdminConfig.getid('/Node:/') #nodeName = AdminConfig.showAttribute(nodeConfigId, 'name') #nodeName = 'iedm2c16Node03' # The command below should be used for AIX server environment #serverConfigId = AdminConfig.getid('/Server:' + serverName + '/') serverConfigId = AdminConfig.getid('/Cell:' + cellName + '/Node:' + nodeName + '/Server:' + serverName + '/') # The command below should be used for WebSphere in local developer environment #serverConfigId = AdminConfig.getid('/Server:/') serverName = AdminConfig.showAttribute(serverConfigId, 'name') print "Server Name " + serverName # Add Generic JVM arguments # the pdefs come back as a string [item item item] jvmId = None pdefs = _splitlist(AdminConfig.showAttribute(serverConfigId, 'processDefinitions')) pdef = None for p in pdefs: if -1 != p.find("JavaProcessDef"): pdef = p break #endIf #endFor if pdef: # found Java ProcessDef jvmId = _splitlist(AdminConfig.showAttribute(pdef, 'jvmEntries'))[0] #endIf currentGenericJvmArguments = AdminConfig.showAttribute(jvmId,'genericJvmArguments') findSplitVerifier = currentGenericJvmArguments.find("-XX:-UseSplitVerifier") if -1 != currentGenericJvmArguments.find("UseSplitVerifier"): print "-XX:UseSplitVerifier already set" else: print "Add generic arguments" AdminConfig.resetAttributes(jvmId, [['genericJvmArguments', currentGenericJvmArguments + ' ' + genericArgument]] ) #endIf installCustomService(serverConfigId,[['displayName',wilyCustomServiceDisplayName],['classname',wilyCustomServiceClassName],['classpath',wilyCustomServiceClassPath],['enable','true']]) # ----------------------------------------------------------------------------- # Save all configuration changes AdminConfig.save() print "Script finished."
run the command in DMGR bin dir:
./wsadmin.sh -conntype SOAP -host iedm2c16 -port 8881 -f /tmp/EnableWily.py -appServerName=ABPD -nodeName=iedm2d16Node04
./wsadmin.sh -conntype SOAP -host iedm2c16 -port 8881 -f /tmp/EnableWily.py -appServerName=ABPD -nodeName=iedm2c16Node03