Posted on August 18th, 2009 by roland

Jmx4Perl provides an alternative way of accessing Java JEE Server management interfaces that are based on JMX (Java Management Extensions). It is an agent-based approach where a small Java Web application (approx. 150k) deployed on the application server provides HTTP/JSON-based access to JMX MBeans registered within the application server. It is set up from a handful of Perl modules, which can be integrated seamlessly in your own Perl programs. It includes a sample Nagios check command utilizing JMX::Jmx4Perl as well as the jmx4perl tool, which allows for access to JMX information via the command line. j4psh is a readline based JMX shell with context sensitive command completion and syntax highlighting.

Benefits of this approach compared to the traditional way of accessing JMX remotely via JSR 160 connectors are:

  • No Java installation required on the Nagios host
  • Fast plugin startup times because no JVM needs to be launched
  • Support for bulk operations
  • Fine grained security policies possible
  • No special JEE Server startup options required in order to access JMX information remotely
  • JSON serialization allows deep access into Java objects
  • Firewall friendly communication via HTTP

Jmx4perl can be operated in a proxy mode where a dedicated proxy server accesses the target platform via JSR-160 JMX remoting. This allows for an agentless operation without the need of installing any extra software on the target server.

Beside these technical advantages, the JMX Nagios Plugin check_jmx4perl provides also a rich feature set:

  • Access to JMX attributes and return values of JMX operations for monitoring purposes
  • Incremental mode for monitoring the velocity of value changes, e.g. the growth rate of the thread count
  • Relative monitoring of values by providing a base value attribute, e.g. for checking that the memory used is below 80% of the available memory
  • Deep access to arbitrary Java bean attributes, e.g. the statistics values of a JSR77 Stats object
  • Alias names for common attributes and operations
  • Selective access to a predefined set of MBeans by providing an access policy file to the agent servlet
  • Configuration via configuration file with a sophisticated syntax, which also allows for multiple JMX checks in one Nagios check (multi-check)

This plugin has been tested on JBoss 4.2.3 GA & 5.1.0 GA, Oracle Weblogic 9.2 MP3 &, IBM Websphere 6.1 & 7.0, Jonas 4.10.3 (with Jetty 5.1.10 and Tomcat 5.5.26), Apache Geronimo 2.1.4 (Jetty 6 and Tomcat 6), Glassfish 2.1 & v3, Apache Tomcat 4.1.39, 5.5.27 & 6.0.18 and Jetty 5.1.15 & 6.1.18 (with JMX enabled). Beside these, it should work on any Servlet Container running on at least Java 1.5.

check_jmx4perl is part of a larger distribution, jmx4perl. In addition to this Nagios plugin, jmx4perl contains tools for exploring and examing the available JMX MBeans on the JEE-Server so that it is easy to discover the MBeans and attributes worth monitoring.

A Mule agent for deploying on the Mule ESB Server is available, too.

You can find Jmx4Perl at CPAN.

17 Responses to “Jmx4Perl”

  1. John Tangney Says:
    July 17th, 2010 at 11:49

    I just came across Jmx4Perl. I haven’t had a chance to try it yet, but it sounds like a great solution to our nagios/tomcat monitoring needs. Thanks! –johnt


  2. OMD Version 0.44 erschienen » klimmbimm Says:
    November 15th, 2010 at 17:57

    [...] … kann verschiedene Java Application Server überwachen ohne Java auf dem Nagios Server zu benötigen. Mehr Infos auf [...]

  3. 17 Nagios-Fliegen mit einer Klappe: OMD 0.44 | - Technische Tips Says:
    December 22nd, 2010 at 0:11

    [...] jmx4perl und check_jmx4perl aus den Labs der Fa. Consol überprüfen J2EE-Server (z.B. jBoss/Tomcat) über das JMX-Protokoll. Das Addon benötigt keine Java Installation, aber anscheinend etwas Konfiguration. Bei mir läuft es noch nicht. [...]

  4. Marcus Mönnig Says:
    February 10th, 2011 at 21:45

    Is it possible to combine —delta and –base with check_jmx4perl?

    E.g. I would like to show CPU load in % within the last interval. I think I would need to put the delta for current and last values of “java.lang, type=OperatingSystem|ProcessCpuTime” in relation to the delta for current and last value of “java.lang, type=Runtime|Uptime”, but can I do a delta on the base value, too?


    roland Reply:

    @Marcus Mönnig, using a delta on the uptime doesn’t make much sense IMO since this is simply the duration between two checks (except of course if the server went down in the meantime). What you can do is to normalize the used cpu time to e.g. a second, so that it shows you the user+system time of your Java process:

    check_jmx4perl -u http://localhost:8080/jolokia -m java.lang:type=OperatingSystem -a ProcessCpuTime  --unit ns --delta 60 -w 1000000000

    The check above gives you the time spent of your process within one minute (use –delta 1 for getting checking the nanoseconds spent in a real second)

    Please note, that this value is not the CPU load, but the user+system time you Java process consumed. And it is measure in nanoseconds, although this doesn’t mean it has this accuracy.

    And finally to answer your question ;-): No, it is not possible to combine –delta and –base (and it is not yet planned)


    Marcus Moennig Reply:

    @roland, Thanks! This works fine for me, though it now would be nice to divide that by the number of processors (in case you were still looking for a reason to combine delta and base… ).


  5. anishkumar Says:
    May 26th, 2011 at 9:06

    Hi guys,

    I just searching monitoring tool for java application — i hope it will works great–do any have the documentation for this how to configure this plugin in nagios!!!!


  6. Daniel Wittenberg Says:
    June 15th, 2011 at 23:24

    We’re running various WebSphere apps, and looking to gather various performance metrics and not having much luck. I can do basic queries for HeapMemory, Operating system, config info, etc. but things I’ve been asked to look at I can’t find: 1) Application metrics – Latency – Threshold_violotions – processCPUUtil – processCPUUtilAbs – Live Session Count – Throughput – Exceptions

    I’ve been told by some folks that there’s a PerfMBean to query but I’ve not had much luck with that. Anyone else doing WebSphere have a list of items they are monitoring?

    Thanks! Dan


    Daniel Wittenberg Reply:

    @Daniel Wittenberg, So anyone actually use WebSpehre have any examples they want to share on how to get the queries to work with jmx4perl or check_jmx4perl?



  7. Ray Reid Says:
    September 28th, 2011 at 16:52

    Try to get check_jmx4perl working to monitor Glassfish.

    Best result that I get is : UNKNOWN – An MBean name and a attribute/operation must be provided

    /usr/local/nagios/etc/nrpe.cfg command[check_status]=/usr/local/nagios/libexec/check_jmx4perl –url http://:8080/jolokia –alias MEMORY_HEAP_USED –base MEMORY_HEAP_MAX –critical :80

    /usr/local/nagios/etc/objects/commands.cfg command_line $USER1$/check_jmx4perl -u http://$HOSTADDRESS$:$ARG1$/jolokia .config $USER1$/jmx4perl/jmx4perl.cfg .check $ARG2$ .warning $ARG3$ .critical $ARG4$

    /usr/local/nagios/etc/objects/server.cfg check_jmx4perl_config!8080!memory_heap!70!90

    Anyone got any document to get this working with Glassfish? I mostly followed :


    roland Reply:

    Hi Ray,

    your command definition in commands.cfg looks strange. You should use ‘–’ instead of ‘.’ as prefix to the options. I guess, this is a copy&paste issue.


  8. Paul Dubuc Says:
    February 15th, 2012 at 17:33

    Is there any way to inhibit the output of performance data for a particular check. I use many checks at a time and am trying to use PNP4Nagios to collect and graph performance data, but some of the data I am not interested in graphing (only notification) so I want to exclude it from the output so PNP doesn’t collect it.

    Thanks, Paul Dubuc


    Pierre Cheynier Reply:

    @Paul Dubuc Hi,

    Great command !

    But, I’ve got same problem. Many check like those working with a string don’t have to return perfdata.

    Moreover, there is an issue where you specify “relative” thresholds like “100:” (OK state is from 100 to +infinite), the output-ed perfdata is : metric=150,100:,200: This is not correct, you should avoid to print the min/max value in this case.



  9. Jmx4Perl 1.05 Says:
    May 12th, 2012 at 12:33

    [...] minor issues (mostly build related) and adds a "pwd" command to the JMX shell j4psh. URL:Jmx4Perl – ConSol* Labs Reply With Quote « Web Ping | – [...]

  10. Webcast “Java Monitoring in der Praxis – Jmx4Perl / Jolokia” – ConSol* Labs Says:
    September 25th, 2012 at 16:19

    [...] dem Plugin hier beheimateten check_jmx4perl im Speziellen. Roland Huß als Referent unt Author von jmx4perl und Gerhard Laußer als Moderator erklären 45 Minuten, wie man Nagios am besten mit JEE Servern [...]

  11. Manual installing Nagios on Ubuntu 2 | Loftjob Says:
    October 8th, 2012 at 21:34

    [...] Download jmx4perl [...]

  12. Andreas Seemueller Says:
    June 10th, 2013 at 16:24

    Thanks for the great plugin. But I have one question:

    If I use the pre-defined check “thread_inc” I sometimes get negative results. This happens of course if the number of running threads is less than before within one minute. The problem is that the plugin return CRITICAL as soon as there is a negative value. But from my point of view this should be OK.

    For example: thread_inc return -20 and the WARN threshold is set to +50. As -20 is less than +50 the Result is OK for me but CRITICAL for check_jmx4perl. I’m running version 1.07

    With best regards



Leave a Reply