Some restricted environments do not allow any changes to the JVM startup script. For these environments, you can use the environmental variable JAVA_TOOLS_OPTIONS in a wrapper script that allows you to specify the initialization of tools, specifically, -javaagent.

To create the wrapper script:
  1. Create a wrapper script in the following format:
    {{JAVA_TOOLS_OPTIONS="-javaagent:/opt/appdynamics/appserveragent/javaagent.jar -Dappdynamics.controller.hostName=<controller_host> -Dappdynamics.controller.ssl.enabled=false -Dappdynamics.controller.port=<port> -Dappdynamics.agent.applicationName=<application_name> -Dappdynamics.agent.tierName=<tier_name> -Dappdynamics.agent.nodeName=<node_name>" }}
    export JAVA_TOOLS_OPTIONS

     

    If you need to specify spaces for the application, tier, or node names, use backslashes and quotes around the value, for example: -Dappdynamics.agent.applicationName=\"$APPLICATION_NAME\"

  2. Add the original startup script to the wrapper script.
  3. Make the new script executable, for example chmod 750 wrapperscript.sh.
  4. Run your new wrapper startup script.

 

Full example: startApplicationWithAppDynamics.sh

#!/bin/bash

JAVA_TOOLS_OPTIONS="-javaagent:/opt/appdynamics/appserveragent/javaagent.jar -Dappdynamics.controller.hostName=<controller_host> -Dappdynamics.controller.ssl.enabled=false -Dappdynamics.controller.port=<port> -Dappdynamics.agent.applicationName=<application_name> -Dappdynamics.agent.tierName=<tier_name> -Dappdynamics.agent.nodeName=<node_name>"

export JAVA_TOOLS_OPTIONS

/path/to/original/script/startup.sh $*