Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Allows you to enable remote JMX (Java Management Extensions) monitoring capabilities for Trinidad.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 trinidad_jmx_remote_extension.gemspec
README.md

Trinidad JMX Remote Extension

This extension allows you to enable remote JMX (Java Management Extensions) monitoring capabilities for Trinidad.

The extension sets up a Tomcat lifecycle listener which fixes the ports used by JMX/RMI to static ones (known ahead of time) thus making things much simpler if you need to connect JConsole or any similar tool to a remote Trinidad instance running behind a firewall.

Please note that only the ports are configured via the listener, the remainder of the configuration is via the standard system properties for configuring JMX.

Install

Along with Trinidad in your application's Gemfile:

  group :server do
    platform :jruby do
      gem 'trinidad', :require => false
      gem 'trinidad_jmx_remote_extension', :require => false
    end
  end

And then execute:

$ bundle

Or install it yourself as:

$ gem install trinidad_jmx_remote_extension

Setup

Like all extensions it is setup in the configuration file e.g. trinidad.yml :

---
  # ...
  extensions:
    jmx_remote:
      useLocalPorts: true # bind to localhost than setup a ssh tunnel
      # assuming you'll setup the tunnel you shall remember these ports :
      rmiRegistryPortPlatform: 9993
      rmiServerPortPlatform: 9994

Now your server should be setup, do not forget to restart Trinidad ... You might want to disable JMX authentication (at first) and set the RMI hostname e.g. by :

$ jruby -J-Dcom.sun.management.jmxremote.ssl=false -J-D-Dcom.sun.management.jmxremote.authenticate=false -J-Djava.rmi.server.hostname=<trinidad-host-name> -S trinidad -e production

Next you will need to make sure you can SSH into the remote machine locally.

Local Setup

SSH tunnel (those ports) into the machine where Trinidad is running :

$ ssh -N -L9993:localhost:9993 -L9994:localhost:9994 user@remotehost

Download the catalina-jmx-remote.jar into your current working directory :

$ wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.32/bin/extras/catalina-jmx-remote.jar

You shall use the same catalina-jmx-remote.jar locally as the extension is using on the remote Trinidad machine, this guide reflects the .jar distributed with the latest version of the gem. When in doubt simply gem install the same version locally and copy the .jar from the unpacked gem e.g. using :

$ jruby -rubygems -e "require 'trinidad_jmx_remote_extension'; puts Trinidad::Extensions::JmxRemote::JAR_PATH"

Now open jconsole, assuming your JMX connection string looks like this : service:jmx:rmi://localhost:9994/jndi/rmi://localhost:9993/jmxrmi

$ jconsole -debug -J"-Djava.class.path=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/jconsole.jar:catalina-jmx-remote.jar" service:jmx:rmi://localhost:9994/jndi/rmi://localhost:9993/jmxrmi

This is assuming a standard JDK installation (non Apple Java) ...

For more details, this guide has been inspired by the following excellent post : http://danielkunnath.com/post/9969130766/dancing-with-jmx-jconsole-tomcat-6-ssh

Copyright

Copyright (c) 2012 Karol Bucek. See LICENSE (http://en.wikipedia.org/wiki/MIT_License) for details.

Something went wrong with that request. Please try again.