Created
March 15, 2021 12:48
-
-
Save iogbole/3bdc62a914ccd6909656d1d66f4b8068 to your computer and use it in GitHub Desktop.
dynamic attach
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -lt "1" ] | |
then echo "usage <uniqueString> [arg1,...]" | |
echo | |
echo "eg: ./simpleattach.sh wildfly appdynamics.controller.hostName=192.168.57.104,appdynamics.controller.port=8090,appdynamics.agent.applicationName=SimpleJBoss,appdynamics.agent.tierName=SimpleJBossOSX_T1,appdynamics.agent.nodeName=SimpleJBossOSX_T1_Server1" | |
exit | |
fi | |
echo $* | |
################### | |
# Set these | |
################### | |
AGENT="-jar /Users/israel/development/AppAgents/AppServerAgent-4.5.11/javaagent.jar" | |
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home | |
TOOLS_JAR=-Xbootclasspath/a:$JAVA_HOME/lib/tools.jar | |
NODE_NAME=$1; shift | |
# Look for node name | |
JAVA_PROCESS=$(ps -ef |grep java |grep $NODE_NAME) | |
echo attaching | |
## get the PID | |
PID=$(echo $JAVA_PROCESS | sed "s/java .*/java/"| cut -d' ' -f2) | |
# Attach the agent | |
if [ -z "$PID" ] | |
then : | |
else | |
echo java $TOOLS_JAR $AGENT $PID $* | |
java $TOOLS_JAR $AGENT $PID $* | |
fi | |
#sleep 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment