Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install jccjmx

How to install jccjmx

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install jccjmx
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1 Available View build log
Windows (64-bit)
0.1 Available View build log
Mac OS X (10.5+)
0.1 Available View build log
Linux (32-bit)
0.1 Available View build log
Linux (64-bit)
0.1 Available View build log
 
Links
License
Sun Public License
Lastest release
version 0.1 on May 23rd, 2012

Abstract

SSH-tunnel friendly monitoring of embedded Java Runtimes using MBeans, Java Management Extensions (JMX) and Remote Method Invocation (RMI) for Python and PyLucenet.

Rationale

jccjmx is a convenience helper for JCC and PyLucene to create a JMX RMI connector at runtime. The usual way to a connector with vmargs '-Dcom.sun.management.jmxremote' (or similar) works only on startup. Also this opens two ports (one for the connector and one for the RMI registry). The RMI registry port is assigned dynamically which makes firewall rules or SSH/SSL tunnels impossible.

jccjmx allows you to start a RMI and JMX connector programmatically without restarting your Python application. The platform MBean server provides live monitoring of JRE's memory usage (heap, caches), JRE's CPU usage, Java threads, attached Python threads and more. The JDK is shipped with two GUI programs for monitoring: jconsole and jvisualvm.

jccjmx is based on Daniel Fuchs' examples from his blog at Sun (now Oracle). I've modified his code and ported it from a premain agent to a standalone class.

Usage

The import order is crucial! You must import and init lucene and jccjmx in the correct order. Otherwise your process will segfault.

>>> import lucene
>>> import jccjmx

Initialize the VM for both packages. The second initVM() just adds the CLASSPATH of jccjmx.

>>> lucene.initVM() # doctest: +ELLIPSIS
<jcc.JCCEnv object at 0x...>
>>> jccjmx.initVM() # doctest: +ELLIPSIS
<jcc.JCCEnv object at 0x...>

Create an agent that listens on port 12345. You should create just one instane of JccJmxAgent during the life time of your application.

>>> agent = jccjmx.JccJmxAgent(12345)

By default the agent is bound to 127.0.0.1. You can specificy another hostname or IP address with jccjmx.JccJmxAgent("hostname", portnumber).

A RMI is created immediately and bound to "*:port" but no agent is listening yet. You have to activate is explicitly. This allows you to delay the agent.

System Message: WARNING/2 (<string>, line 54); backlink

Inline emphasis start-string without end-string.
>>> agent.isActive()
False
>>> agent.start()
>>> agent.isActive()
True
>>> agent.stop()
>>> agent.isActive()
False

In order to connect from a remote host you need to know the service URL:

>>> agent.getServiceURL()
u'service:jmx:rmi://127.0.0.1:12345/jndi/rmi://127.0.0.1:12345/jmxrmi'

From a remote host:

$ ssh -L12345:127.0.0.1:12345 server $ jconsole service:jmx:rmi://127.0.0.1:12345/jndi/rmi://127.0.0.1:12345/jmxrmi

Security

The RMI registry is always bound to all possible network devices. This shouldn't be an issue but I can't guarantee it.

jccjmx doesn't use SSL to authenticate clients and encrypt the connection. It's up to you to use an encrypted tunnel. Future versions of jccjmx may support SSL.

Trouble shooting

Connection refused

You may get a connection refused error when the RMI hostname isn't set correctly. jccjmx sets the system property unless it is already set. You can force a correct hostname with e.g.

-Djava.rmi.server.hostname=127.0.0.1
IPv4 vs. IPv6

Java prefers IPv6 connections over IPv4 connections and usually binds to IPv6 TCP. If you are having trouble with a mixed network you can force the JRE to prefer IPv4 with

-Djava.net.preferIPv4Stack=true

Authors

Christian Heimes Daniel Fuchs (original author of the JMX agent)

Subscribe to package updates

Last updated May 23rd, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.