Hi,

Now OpenNMS has switched to a git repo I've been making the effort to
clean the tree to a reasonable state so I can push some of the stuff
in our tree upstream.


The following two patches add command line switches to the opennms
binary to enable various profiling approaches. I've used TIJMP a bit
for looking for memory load but I must admit the OProfile support has
been a lot more useful, especially for the locating CPU bound
hotspots.


The patches are attached, the oprofile one applies after the tijmp
one.

-- 
Alex, homepage: http://www.bennee.com/~alex/
http://www.half-llama.co.uk
commit 4279dc539c75aecbaa08e45cfe851c8fdc553670
Author: Alex Bennee <a...@pitcairn.cambridgebroadband.com>
Date:   Wed Sep 16 14:45:42 2009 +0100

    Add support for the TIJMP profiler to the opennms startup script

diff --git a/opennms-daemon/src/main/filtered/bin/opennms b/opennms-daemon/src/main/filtered/bin/opennms
index 810f457..c18d605 100755
--- a/opennms-daemon/src/main/filtered/bin/opennms
+++ b/opennms-daemon/src/main/filtered/bin/opennms
@@ -99,7 +99,7 @@ fi
 show_help () {
 	cat <<END
 
-Usage: $0 [-n] [-t] [-c timeout] [-v] [-Q] <command> [<service>]
+Usage: $0 [-n] [-t] [-p] [-c timeout] [-v] [-Q] <command> [<service>]
  
   command options: start|stop|restart|status|check|pause|resume|kill
 
@@ -110,6 +110,7 @@ Usage: $0 [-n] [-t] [-c timeout] [-v] [-Q] <command> [<service>]
 
       -n  "No execute" mode.  Don't call Java to do anything.
       -t  Test mode.  Enable JPDA on port 8001.
+      -p  Enable TIJMP profiler
       -c  Controller HTTP connection timeout in seconds.
       -v  Verbose mode.  When used with the "status" command, gives the
           results for all OpenNMS services.  When used with "start", enables
@@ -246,6 +247,12 @@ doStart(){
 		JPDA="-Xdebug -Xnoagent -Djava.compiler=none -Xrunjdwp:transport=dt_socket,server=y,address=8001,suspend=n"
 	fi
 
+	# See: http://www.khelekore.org/jmp/tijmp/
+	if [ $PROFILE -gt 0 ]; then
+		echo "- enabling TIJMP Profiling"
+		JPDA="-Dtijmp.jar=/usr/share/java/tijmp-0.6.jar -agentlib:tijmp ${JPDA}"
+	fi
+
 
 	if [ "$SERVICE" = "" ]; then
 		APP_VM_PARMS="$JPDA $MANAGER_OPTIONS"
@@ -483,12 +490,13 @@ if [ x"$ADDITIONAL_CONTROLLER_OPTIONS" != x"" ]; then
 fi
 
 TEST=0
+PROFILE=0
 NOEXECUTE=""
 VERBOSE=0
 
 NAME="opennms"
 
-while getopts c:ntvQ c; do
+while getopts c:ntvpQ c; do
 	case $c in
 		c)
 			APP_PARMS_CONTROLLER="$APP_PARMS_CONTROLLER -t $OPTARG"
@@ -502,6 +510,9 @@ while getopts c:ntvQ c; do
 		t)
 			TEST=1
 			;;
+		p)
+			PROFILE=1
+			;;
 		v)
 			VERBOSE=1
 			VERBOSE_GC=1
commit f949bb7c6d8a67a9df9da6cc1db6b4b99a6d04d2
Author: Alex Bennee <a...@pitcairn.cambridgebroadband.com>
Date:   Tue Jan 26 13:24:26 2010 +0000

    Enable OProfile profiling support
    
    This patch to the opennms start up script allow a command line flag to
    be passed that will load the OProfile JVMTI module. This module will
    allow OProfile to show more detail as to where hot-spots are than just
    the big chunk of anonymous memory allocated for Java's JIT code.

diff --git a/opennms-daemon/src/main/filtered/bin/opennms b/opennms-daemon/src/main/filtered/bin/opennms
index a4dc9e7..12d23c8 100755
--- a/opennms-daemon/src/main/filtered/bin/opennms
+++ b/opennms-daemon/src/main/filtered/bin/opennms
@@ -99,7 +99,7 @@ fi
 show_help () {
 	cat <<END
 
-Usage: $0 [-n] [-t] [-p] [-c timeout] [-v] [-Q] <command> [<service>]
+Usage: $0 [-n] [-t] [-p] [-o] [-c timeout] [-v] [-Q] <command> [<service>]
  
   command options: start|stop|restart|status|check|pause|resume|kill
 
@@ -110,7 +110,8 @@ Usage: $0 [-n] [-t] [-p] [-c timeout] [-v] [-Q] <command> [<service>]
 
       -n  "No execute" mode.  Don't call Java to do anything.
       -t  Test mode.  Enable JPDA on port 8001.
-      -p  Enable TIJMP profi1ler
+      -p  Enable TIJMP profiling
+      -o  Enable OProfile profiling
       -c  Controller HTTP connection timeout in seconds.
       -v  Verbose mode.  When used with the "status" command, gives the
           results for all OpenNMS services.  When used with "start", enables
@@ -248,11 +249,16 @@ doStart(){
 	fi
 
 	# See: http://www.khelekore.org/jmp/tijmp/
-	if [ $PROFILE -gt 0 ]; then
+	if [ $TPROFILE -gt 0 ]; then
 		echo "- enabling TIJMP Profiling"
 		JPDA="-Dtijmp.jar=/usr/share/java/tijmp-0.6.jar -agentlib:tijmp ${JPDA}"
 	fi
 
+	# See: http://oprofile.sourceforge.net/doc/setup-jit.html
+	if [ $OPROFILE -gt 0 ]; then
+		echo "- enabling OProfile support"
+		JPDA="-agentpath:/usr/lib/oprofile/libjvmti_oprofile.so ${JPDA}"
+	fi
 
 	if [ "$SERVICE" = "" ]; then
 		APP_VM_PARMS="$JPDA $MANAGER_OPTIONS"
@@ -490,13 +496,14 @@ if [ x"$ADDITIONAL_CONTROLLER_OPTIONS" != x"" ]; then
 fi
 
 TEST=0
-PROFILE=0
+TPROFILE=0
+OPROFILE=0
 NOEXECUTE=""
 VERBOSE=0
 
 NAME="opennms"
 
-while getopts c:ntvpQ c; do
+while getopts c:ntvpoQ c; do
 	case $c in
 		c)
 			APP_PARMS_CONTROLLER="$APP_PARMS_CONTROLLER -t $OPTARG"
@@ -511,7 +518,10 @@ while getopts c:ntvpQ c; do
 			TEST=1
 			;;
 		p)
-			PROFILE=1
+			TPROFILE=1
+			;;
+		o)
+			OPROFILE=1
 			;;
 		v)
 			VERBOSE=1
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-devel mailing list

To *unsubscribe* or change your subscription options, see the bottom of this 
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel

Reply via email to