Tuesday, November 09, 2010

ad4j/jam agent implementation methods for app server /standalone JVMs


ad4j agent can used to monitor any JVM. Be it an application server or a standalone JVM(Java applications).
This article explains the method to monitor standalone Java programs which do not have away of loading a servlet or another class. jamagent has "jamagent.jamrun" class that can be used for this purpose.

 For an application server, 11g jamagent.war can be deployed using one of the following two modes:
1. manual deployment of war file
2. automated deployment of war file on Target Weblogic Server

For an application server, 10g jamagent can be deployed using following mode:
1. manual deployment of war/ear file

For standalone JVM, 10g/11g, follow given steps:
1. Include the file jamagent.zip(jamagent.war in 11g) in the CLASSPATH
2. Change the java command line parameters to call the wrapper jamagent.jamrun as mentioned below.

Original command looks like:
%java $JVM_OPTIONS $TARGET_CLASS $TARGET_CLASS_PARAMS
Here JVM_OPTIONS are the JVM properties and options e.g. Xmx512M -Dweblogic.name
TARGET_CLASS is the program which being examined
TARGET_CLASS_PARAMS are parameters passed to the class

Modified command would be:
%java $JVM_OPTIONS jamagent.jamrun [$JAMAGENT_PARAMS_LIST] $TARGET_CLASS $TARGET_CLASS_PARAMS

ad4j/jam agent will use default parameters. If you want to change any of them, you can specify them as
name=value pairs. To specify a different manager/console and port you will specify
jamconshost=<hostname where manager/console is running>, jamconsport=<listen port of manager/console>

e.g. For Weblogic server,
Original command is:
% $JAVA_HOME/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} \
-Dweblogic.Name=${SERVER_NAME} \
-Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} \
-Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" \
weblogic.Server
The class being called is weblogic.Server. There are no parameters.

Modified command would be:
We are going to insert out class and parameters before that, so it will look like :
%$JAVA_HOME/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} \
-Dweblogic.Name=${SERVER_NAME} \
-Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} \
-Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" \
jamagent.jamrun weblogic.Server

If you want to change some JAM parameters you can specify them as
%$JAVA_HOME/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} \
-Dweblogic.Name=${SERVER_NAME} \
-Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} \
-Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" \
jamagent.jamrun jamconshost=abc jam_jvm_id=5001 weblogic.Server

Ensure that JAM Agent Libraries/Classes is added to the Classpath
Also ensure that jam/jamagent/WEB-INF/classes directory is added to the CLASSPATH.
It is best to do this just before the call to java.
Here we find a couple of lines above the call to Java.
# Start WebLogic server
CLASSPATH="${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}${CLASSPATH}"
We change it to
# Start WebLogic server
CLASSPATH="${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}${CLASSPATH}${CLASSPATHS
EP}/u01/app/em/jamagent/deploy/jamagent.zip"


Target Parameters
What about the -Dweblogic and other properties : You need to insert jamagent.jamrun just before
the calling program and it's parameters. This should happen after all the JVM options and
properties have been specified.

JAM Agent Input Parameters Description
jamconshost - em_console_host The host where JAM manager/console is running
jamconsport - 3600 The port ad4j manager/console is listening on
jamconsretr - 300 Seconds to wait before retrying broken console connection
jamtimeout - 900 Seconds to timeout for long operations
jamloglevel - 3 Level of logging. Valid values are 1-5.
jamjvmid - Server Port Unique Identifier for JVM, Default of 5555 for unrecognized
Servers
jammaxbackoff - 10 Amount of time to wait for long operations
jamdelaystartup - 0 Number of seconds to delay target program
jamisdaemon - false jamisdaemon=true will prevent the agent from exiting
Note: this parameter jamisdaemon=true should be set to true for jamagent to not to exit.

No comments: