Search code examples
javapassengerjrubyjmxappdynamics

Enable JMX beans on Passenger Enterprise 5.0.4


Hello Benevolent community of stackoverflow, I have a web service stack that runs on Red hat, Nginx, Jruby with sinatra, and Passenger Enterprise. My ultimate goal is to enable JMX metrics which can be pushed into my App Dynamics controller (hosted by SaaS).

The App Dynamics installation is relatively easy to configure though the metrics is not coming through. I reckoned JMX is not enabled and I am trying to find the script that initializes the JVM for passenger enterprise to start java. I have been unsuccessful on tracking down exactly where to input the additional parameters to enable JMX.

Here are all my current java applications

root     19260     1  0 Mar20 ?        00:05:12 /usr/lib/jvm/jre/bin/java -Xmx500m -Xss2048k -Djffi.boot.library.path=/opt/jruby-1.7.12/lib/jni -Xbootclasspath/a:/opt/jruby-1.7.12/lib/jruby.jar -classpath : -Djruby.home=/opt/jruby-1.7.12 -Djruby.lib=/opt/jruby-1.7.12/lib -Djruby.script=jruby -Djruby.shell=/bin/sh org.jruby.Main mojo_copytruncate.rb
nobody   20996 20861  4 17:02 ?        00:02:42 java -Xmx500m -Xss2048k -Djffi.boot.library.path=/opt/jruby-1.7.12/lib/jni -Xbootclasspath/a:/opt/jruby-1.7.12/lib/jruby.jar -classpath : -Djruby.home=/opt/jruby-1.7.12 -Djruby.lib=/opt/jruby-1.7.12/lib -Djruby.script=jruby -Djruby.shell=/bin/sh org.jruby.Main /opt/passenger/passenger-enterprise-server-5.0.4/helper-scripts/rack-loader.rb

What I am interested is getting the JMX metrics from the rack-loader.rb.

Here is how the process look like when I trace back on PPID 20861

root     20861 20858  0 17:02 ?        00:00:09 PassengerAgent server
nobody   20996 20861  4 17:02 ?        00:02:42 java -Xmx500m -Xss2048k -Djffi.boot.library.path=/opt/jruby-1.7.12/lib/jni -Xbootclasspath/a:/opt/jruby-1.7.12/lib/jruby.jar -classpath : -Djruby.home=/opt/jruby-1.7.12 -Djruby.lib=/opt/jruby-1.7.12/lib -Djruby.script=jruby -Djruby.shell=/bin/sh org.jruby.Main /opt/passenger/passenger-enterprise-server-5.0.4/helper-scripts/rack-loader.rb

I have no idea where to look for the config in PassengerAgent server...


Solution

  • Found my own solution.

    Since PassengerAgent starts by using a ruby script called rack-loader.rb, I should attach the java agent whenever a RVM is used. This solution fits my scenario since our stack is entirely Ruby based and there isn't anything else that runs RVM. To pass the java agent, I created a script called appdynamics.sh in my /etc/profile.d/ folder.

    Inside I wrote

    export AGENT_HOME=YOUR_AGENT_FILE_PATH.jar
    export JRUBY_OPTS=-J-javaagent:$AGENT_HOME
    

    Restart your terminal and it should load this as environmental variable. Metrics came in just fine.