Tuesday, August 4, 2009

Configuring Wily Introscope Startup Classes using WLST

A lot of corporate app server environments have custom start and stop scripts for the managed server, either with or without the nodemanager.

The snippets of the script below is intended for WebLogic 10:

  • Determine if you would like to enable introscope based on a config file, parameter to the script, etc.
  • For the IntroscopeAgent.profile, either create a standard template that all servers can point to or custom ones - I personally configured it so that if the file doesn't currently exist, I create .profile using a template. If I wanted to monitor custom probes, I would have added them to the .profile which would no longer get overridden by the startup script.

  • Set the classpath and java args within a shell script
# Figure out what we need to add to JAVA_OPTIONS. Let's call it INTROSCOPE_ARGS.
INTROSCOPE_ARGS="-javaagent:(directory-to-client-installation's-agent)/Agent.jar -Dcom.wily.introscope.agentProfile=${managedServerName}.profile
-Dweblogic.classloader.preprocessor=com.wily.introscope.api.weblogic.PreProcessor -Dcom.wily.introscope.agent.agentName=${managedServerName}"
  • In Java 1.5+, we can use the -javaagent flag instead of having to generate the auto probe connector every time we upgrade the version of java. For older version of java, you would want to use something along the lines of:
INTROSCOPE_ARGS="-Xbootclasspath/p:${INTROSCOPE_AUTO_PROBE_CONNECTOR}:(directory-to-client-installation's-agent)/Agent.jar -Dcom.wily.introscope.agentProfile=${managedServerName}.profile -Dweblogic.classloader.preprocessor=com.wily.introscope.api.weblogic.PreProcessor -Dcom.wily.introscope.agent.agentName=${managedServerName}"

CLASSPATH="/prod/prop/introscope/agent/WebAppSupport.jar:${CLASSPATH}"

Now that we have that taken care of, (depending on the args passed) we can move onto the WLST portion. We need to have the startup class for Introscope targetted to the managed server inorder to obtain the JMX metrics. If we leave it targetted to a server that has Introscope disabled, it's a bit messy as it will throw a ClassNotFoundException during startup.

The WLST script should simply target the startupclass when necessary and untarget it if Introscope is disabled.


try:
connect(username,password,URL)
edit()
startEdit()
cd('/')
startup_class = getMBean('/Deployments/Introscope Startup Class')
if startup_class == None:
print "Creating new startup class as one does not exist"
cmo.createStartupClass('Introscope Startup Class')
cd('/Deployments/Introscope Startup Class')
cmo.setClassName('com.wily.introscope.api.weblogic.IntroscopeStartupClass')

cd('/Deployments/Introscope Startup Class')

if (function=='enable'):
cmo.addTarget(getMBean('/Servers/'+managedServerName))
if (function=='disable'):
cmo.removeTarget(getMBean('/Servers/'+managedServerName))
activate()
disconnect()
rc = 0

except Exception, e:
print '[error] %s' % (e)
rc = 1
sys.exit(rc)

You should pass the 'function' to the script to determine if it is to 'enable' or 'disable' Introscope setup. It should also be aware of the managedServerName of interest so that it can traverse to the appropriate MBean. We only target/untarget and create the startup class if it doesn't exist and never delete it so that other managed servers which have Introscope enabled doesn't have their JMS impacted.

Greetings!

Hello,

After ~5 years of WebLogic administration, I figured it's time for me to give back to the community. Any thoughts/questions/comments are welcome :-)