changeset 11:033b9e23a8d3

Add a script to inject an agent Make it easier to inject a native or java agent into a given PID.
author Omair Majid <omajid@redhat.com>
date Wed, 17 Sep 2014 09:58:35 -0400
parents 87ebe109ad98
children 27a770124bd5
files inject
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inject	Wed Sep 17 09:58:35 2014 -0400
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# usage: $0 target-pid jar-or-lib-to-inject [agent options]
+
+TARGET_PID="$1"
+AGENT="$(readlink -f $2)"
+AGENT_OPTIONS="$3"
+
+if [ -z "${JAVA_HOME}" ] ; then
+    JAVA_HOME=/usr/lib/jvm/java
+fi
+
+JAVA="${JAVA_HOME}/bin/java"
+
+${JAVA} -cp "${JAVA_HOME}"/lib/tools.jar:build/attacher.jar Attacher \
+    "${TARGET_PID}" \
+    "${AGENT}" \
+    "${AGENT_OPTIONS}"
+